trellis-cli icon indicating copy to clipboard operation
trellis-cli copied to clipboard

Feature request: Add `$ trellis cd SITE`

Open tangrufus opened this issue 6 years ago • 6 comments

Summary

Add $ trellis cd SITE which $ cd into bedrock (maybe sage as well) directory.

Motivation

So nobody needs to remember local_path

Additional context

cd-ing into Bedrock is easy. However, Trellis has no place for sage directory names (unless a better version of https://github.com/roots/trellis/pull/1030 arrives). Thus, Sage might have to wait.

This is suggested by @Log1x

tangrufus avatar Jan 04 '20 19:01 tangrufus

Is $ trellis cd SITE literal? Meaning you'd type in SITE? (or site) If Sage were supported you'd type trellis cd theme or something?

swalkinshaw avatar Jan 04 '20 19:01 swalkinshaw

I mean the site key. Example:

  • $ trellis cd example.com cd into example.com's local_path
  • $ trellis cd example.com --sage cd into example.com's sage directory

tangrufus avatar Jan 04 '20 20:01 tangrufus

🤦‍♂ of course sorry. Could it be more generic?

  • $ trellis cd example.com
  • $ trellis cd example.com theme

And if you only have a single site:

  • $ trellis cd site
  • $ trellis cd theme

Maybe just "site" could be treated "magically" 🤔

swalkinshaw avatar Jan 05 '20 18:01 swalkinshaw

How about environments?

Example: For the same project, I use valet and my colleagues use vagrant. So, we have 2 local environments.

Also leads to the question - Do we vagrant ssh and cd inside the VM?

tangrufus avatar Jan 05 '20 19:01 tangrufus

cd seems like it should be a local development command only to me but I don't really know how you'd deal with valet vs vagrant. Does it matter if all the command does is cd locally on the host to the local_path?

swalkinshaw avatar Jan 05 '20 22:01 swalkinshaw

That's a great idea. That would be nice to also list all the websites that were added before and also given them an alias. So instead of writing the whole site name, we could call them by the alias.

Example: $ trellis site list

alias | name site1 | this-is-a-very-long-url-for-a-website.com site2 | another-example.com site3 | one-more.com

or maybe we could select the website from a list using the component promptui if we type: $ trellis cd Select a site -> this-is-a-very-long-url-for-a-website.com another-example.com one-more.com

amelotrgr avatar Feb 21 '20 15:02 amelotrgr

Was thinking about this again when I realized that isn't possible to do this the way we want. Processes like trellis can't change the directory of the parent process that spawned it. So we can of course change the working directory within the process that spawns when you run trellis but when the process exits it won't persist.

The only real alternative is to have a command that outputs the path so people can do cd $(trellis path example.com). I don't think that's useful or intuitive enough to justify it's existence so I'm going to close this.

swalkinshaw avatar Nov 13 '22 05:11 swalkinshaw