4 ms·
"j" for switching directories - hacking "cd" with python
- toisanji 14y agoI already use this all the time for the past few years with the exact same command "j": https://github.com/joelthelion/autojump https://github.com/joelthelion/autojump
- tuananh 14y agoi love this little app. So useful.
- joelthelion 14y agothanks :)
- pajju 14y agoAlso see fasd: Its the best one out there. https://github.com/clvv/fasd https://github.com/clvv/fasd + Fasd (pronounced similar to "fast") is a command-line productivity booster. + Fasd offers quick access to files and directories for POSIX shells. It is inspired by tools like autojump, z and v. + Fasd keeps track of files and directories you have accessed, so that you can quickly reference them in the command line. I've been using this tool, nothing comes close this one. Trust me on this. :)
- pekk 14y agoWhat is better about it? Why should I trust you on this?
- cpa 14y agoFor a simpler worflow than "j" one can use pushd/popd which are builtin in bash. One can push and pop directories one a stack. It's pretty neat! $ cd foo1 $ pushd ~/foo2 [do some work] $ pushd ~/foo3 [do some work] $ popd $ pwd ~/foo2 $ popd $ pwd ~/foo1
- izakage 14y agoThere's also "dirs" to view the directory stack!
- cpeterso 14y agoYou can also: $ cd - to jump to the last directory, like popd without the pushd. I also alias .. to 'cd ..' and ... to 'cd ../..' (and so on).
- SoftwareMaven 14y agopushd without an argument will cycle through the directory stack as well.
- JesseAldridge 14y agoI made a similar tool: https://github.com/JesseAldridge/simplejump https://github.com/JesseAldridge/simplejump One nice feature is you can jump to the nth matching result like so: $ z d $ pwd /Users/jessealdridge/Desktop $ z d 2 $ pwd /Users/jessealdridge/Dropbox
- lobster_johnson 14y agoA great tool with no dependencies other than the shell already exists: https://github.com/rupa/z https://github.com/rupa/z
- hk__2 14y agoYou can also check your most used commands with huffshell (gem install huffshell), it also suggests you some aliases.
- DanielRibeiro 14y agoYou can also just set the $CDPATH: https://news.ycombinator.com/item?id=4466687 https://news.ycombinator.com/item?id=4466687
- Splognosticus 14y agoAlso bash has a built-in incremental history search. http://www.gnu.org/software/bash/manual/bashref.html#Searching http://www.gnu.org/software/bash/manual/bashref.html#Searchi...
- amarsahinovic 14y agoShameless plug: I wrote a similar utility for myself called 'Goto Bookmark' which allows you to bookmark a directory so you can jump to it from anywhere when needed. Bitbucket: https://bitbucket.org/amarsahinovic/gb https://bitbucket.org/amarsahinovic/gb Github mirror: https://github.com/amarsahinovic/gb https://github.com/amarsahinovic/gb
- daemon13 14y agoso autojump, z and fasd - which one is better and why?
- crazydiamond 14y ago`z` is good. `autojmp` is similar. Also try `cetus` ( `gem install cetus`) and `zfm` (written in zsh, https://github.com/rkumar/zfm https://github.com/rkumar/zfm).
- logn 14y agoI tried a similar thing to replicate Eclipse's 'Open Resource' search functionality while I was coding in Vim. https://github.com/hollingsworthd/POSIXplorer https://github.com/hollingsworthd/POSIXplorer You basically enter a search term or regex and it will search recursively down from your current directory to find the file. If >1 results are found it displays a navigable list of files to open, otherwise it immediately loads the file in your $EDITOR (or defaults to vim). It also can search file contents in addition to a path regex, with all the same functionality to browse and open files. OP's script looks neat. I think there are all sorts of things we could do to improve cmdline usability.
- jgross206 14y agoA very, very simple cd "hack" I use is (put this in your .bashrc): function cd() { builtin cd "$*" && ls } it automatically runs "ls" every time you cd somewhere. I find when I'm using someone elses box or SSH'd in somewhere it's really annoying not to have it.
- nviennot 14y agoI find these very useful: https://github.com/nviennot/zsh-config/blob/master/lib/key-bindings.zsh#L7-L12 https://github.com/nviennot/zsh-config/blob/master/lib/key-b... ctrl+f is similar to "forward" in your browser. ctrl+b is similar to "back" in your browser.
- stevekemp 14y agoI've been burned by these kind of tools before, when I started using the CDPATH variable, as supported by bash. Imagine the situation where you have a bunch of domains stored beneath /home/www. For example "/home/www/example.com" and "/home/www/example.org". (This is common for vhosts with a single prefix). I decided I was going to get rid of the archived copies beneath /var/backup - so I decide to run "cd /var/backup; cd example.com; rm -rf *". Because of the path-searching I ended up at my live location, not my (obsolete) backup. Since then I've always decided to navigate manually.
- tkellogg 14y agoWhile we're talking about "smart cd" tools, I should mention my Windows PowerShell tool. https://github.com/tkellogg/Jump-Location https://github.com/tkellogg/Jump-Location
- meonkeys 14y agoIt seems there are many derivatives. Here's one I use and like: https://github.com/meonkeys/j2 https://github.com/meonkeys/j2 .