I upvoted for this alone: Another neat short hand is !$ which is an alias for the last argument of the previous command. This can be handy if one creates a new directory and wants to change into it without typing the the directory again. So commands would be mkdir -p make/new/directory cd !$ You've no idea how many years I've been thinking "This is Linux fer gawd's sake. Surely there must be some easy way to make a n…
How to navigate directories faster with Bash (2015)
131–140 of 179 posts
Re: How to navigate directories faster with Bash (2015)
#132Or you just use a shell like fish that already comes with a lot of useful defaults. No need to customize everything by yourself, just use what other smart people already created. https://fishshell.com/
Re: How to navigate directories faster with Bash (2015)
#133Earlier quoted context omitted.
[ESC + .] and [ALT + .] are most definitely news ones for me. Thank you. Always learn something new here!
https://www.gnu.org/software/bash/manual/html_node/Bindable-... is a must read.
No, more having to press C-r multiple times just to get sequential group of commands from history.
Re: How to navigate directories faster with Bash (2015)
#134https://gumroad.com/l/findspot
I experiment with many forms of automation and stick with few of them. Interface complexity has a cost; there's a reason keyboards don't have more keys. For me, Findspot is indispensable.
Re: How to navigate directories faster with Bash (2015)
#135The author missed to mention one of my favorite tricks to change back in to the last visited directory: cd - Hint: Change into directory called '-' can be done by cd ./- I also use the mkcd alias / function: mkcd() { mkdir -p "$@" && cd !$; } This allows creating multiple dirs and cd into the first one. mkcd test1 test2 test3
git checkout -
checks out the previous branch you were on, similar to cd -Re: How to navigate directories faster with Bash (2015)
#136Earlier quoted context omitted.
Beware that using "$@" there might not be what you want, as it passes space-separated arguments to mkdir. What does: "mkd foo bar" do? It creates both directories, and cd's into "bar". Might be worth checking that only one argument has been passed, or use "$*" which instead would treat all arguments as one parameter, and "mkd foo bar" would create a "foo bar" directory instead (and cd to it) YMMV.
All Bash manuals and tutorials should start from explaining this issue. And I really mean it. I can't remember how many times I was bitten by it until I finally read it up.
It's also a good way to "learn by doing", which works for many.
Re: How to navigate directories faster with Bash (2015)
#137Re: How to navigate directories faster with Bash (2015)
#138https://gist.github.com/iwalton3/3f9bfce510f959782404be25cab...
Re: How to navigate directories faster with Bash (2015)
#139The methods listed in the article are almost certainly better if you know exactly which directory you need to go to (like a specific project repo, your bin etc) however often you don’t!
Another interesting tool is Z: https://github.com/rupa/z
Re: How to navigate directories faster with Bash (2015)
#140Would it possible to alias the escape codes make by the up arrow as 'cd ..'
bind '"\e[A":"cd ..\n"'
But would you really want that rather showing previous command?