Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Best practice for cd (path) #1969

Closed
ElijahLynn opened this issue Mar 4, 2015 · 14 comments
Closed

Best practice for cd (path) #1969

ElijahLynn opened this issue Mar 4, 2015 · 14 comments
Labels

Comments

@ElijahLynn
Copy link

I have a bunch of aliases that I am converting to abbreviations. While doing so I wondering if I may be fundamentally missing something.

My use case and I am sure many others have this too is that I have like 10 common folders I cd into all the time. So I make an abbreviation called web=cd ~/websites and then cdff=cd ~/.config/fish/functions and so on. Is there a better way to go about this then making an abbr everytime I want to do this?

Thanks!

@ElijahLynn
Copy link
Author

I did play with this a while ago, https://github.com/joelthelion/autojump but didn't find it super intuitive.

@ElijahLynn
Copy link
Author

I actually cannot get autojump to work right now under fish, It just fails with an exit status of 1. I wonder if it is because autojump tries to use the cd command and something wonky is going on with the Fish cd command.

update: opened issue here wting/autojump#357

@ghost
Copy link

ghost commented Mar 4, 2015

Nothing against autojump, but I just don't see what is the big deal. Just type the path followed by a / and fish will cd you there. Now, IMO the best thing is we have autocompletion so it's easy to see everything at a glance.

@ElijahLynn
Copy link
Author

Right but you need to type quite a bit with Fish to take you there (as compared to an alias or abbreviation), even if you skip cd and just and with a /. Yeah, so some kind of autojump like functionality (or better) in Fish would ideal.

@ElijahLynn ElijahLynn changed the title Support request: Best practice for cd (path} Support request: Best practice for cd (path) Mar 4, 2015
@zanchey zanchey changed the title Support request: Best practice for cd (path) Best practice for cd (path) Mar 6, 2015
@Leo2807
Copy link

Leo2807 commented Mar 21, 2015

What I do is: I create symlinks in my home directory so everytime I open a terminal I just have to type the name of the folder I want to go to.

@ridiculousfish ridiculousfish added this to the fish-future milestone Mar 23, 2015
@anordal
Copy link
Contributor

anordal commented Mar 7, 2016

See also #45.

@krader1961
Copy link
Contributor

I've mostly relied on $CDPATH. For example, my $CDPATH currently has two elements that allows me to type things like cd fish[tab] to change to my local fish-shell git repo directory that is under a directory where I anchor all of my third-party git repos.

When I recently proposed a mcd (menu change directory) command (see issue #2847) I realized I could prime the history by explicitly setting $dirprev in my ~/.config/fish/config.fish. This issue made me ponder if adding support for a user defined list of directories that augment the cd history would be useful. Would you be satisfied if you could define a list of up to 26 directories that you could select by typing mcd then an uppercase letter to choose one of those directories?

@ElijahLynn
Copy link
Author

So, after playing with the filename autocomplete support that is offered by fish's git support I really like the ability to just type git add <filename> then tab and it autocompletes the whole path.

I have been using z in the meantime and really like the ability to not have to pre-define anything. Just z <string> and tab and pow, most of the time I am in the directory I was expecting.

I personally see this as something fish should provide by default but maybe it should stay in the contrib space?

@krader1961
Copy link
Contributor

@ElijahLynn: Have you looked whether the $CDPATH variable would address some, if not most, of your needs? You simply set it to an array of directories whose subdirs you wan't to be able to cd to easily. It supports the path completion you mentioned in your git add [tab] example. For example,

set -g CDPATH . ~ ~/.config/fish /usr/share/fish

It's one shortcoming is that the first subdir of a given name in that path is the only one you can select. For example, cd f[tab] will pick the ~/.config/fish/functions directory over /usr/share/fish/functions directory and the latter won't show up in the pager if you press tab twice.

@ElijahLynn
Copy link
Author

Just tried that out and while it is interesting, the ability to not have to specify the directories I want is the key here. I jump around a lot and I want it to be smart about the directories I have been to in the past. It needs to just know.

I also want to be able to enter a few letters of the directory. With $CDPATH I have to still enter the full name, and while the tab completion is nice, the enter key is faster.

@krader1961
Copy link
Contributor

I jump around a lot and I want it to be smart about the directories I have been to in the past. It needs to just know.

The cd command already keeps a history of the directories you've visited for the benefit of the prevd and nextd commands. But I've never cared for that mechanism because it's too hard to reason about. That's why I wrote a mcd (menu change directory, see issue #2847) command to show that history from which you can select a destination by entering a single letter. When the completion pager is exposed as a callable widget (see issue #2805) we should be able to provide a solution much closer to what I think you're looking for.

@ElijahLynn
Copy link
Author

Thanks, I subscribed to #2805.

@krader1961
Copy link
Contributor

Okay, I'm going to close this since I think we've exhausted the possible solutions that don't involve an enhancement to the core fish code and those enhancements are already being discussed in other issues.

@krader1961 krader1961 removed this from the fish-future milestone Mar 24, 2016
@ElijahLynn
Copy link
Author

Deal!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants