I'm surprised autocd was not mentioned. I saw alias ..='cd ..' # etc ... But not. shopt -s autocd zsh also has this. This seems like the fastest way to navigate since you no longer need to type, or retype, cd.
How to navigate directories faster with Bash (2015)
71–80 of 179 posts
Re: How to navigate directories faster with Bash (2015)
#72Re: How to navigate directories faster with Bash (2015)
#73Re: How to navigate directories faster with Bash (2015)
#74The 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
Re: How to navigate directories faster with Bash (2015)
#75Earlier quoted context omitted.
I'm an old-timer so was introduced to Unix before bash was ubiquitous. Actually it was csh/tcsh which later introduced me to "interactive" command history/editing. With interactive command history/editing, the old tricks to avoid excessive typing became less essential. But I still use some of the old techniques as they continue to save time/typing - particular "$!". And even though I've reduced my reliance on aliases…
Is there a way to tell CTRL-w to break words at / as well as space? I often use it to remove a parameter from a command I've copy-pasted or got from the history, but for the cd use case it removes too much. Edit: ESC followed by backspace seems to work.
Re: How to navigate directories faster with Bash (2015)
#76I 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…
Re: How to navigate directories faster with Bash (2015)
#77up - cd .. # times
upto - find dir in the current path above you and cd to it
down - find dir in the current tree below you including inside any number of subdirectories and cd to it
https://github.com/robmccoll/dotfiles/blob/master/bashrc#L15...
Re: How to navigate directories faster with Bash (2015)
#78Earlier quoted context omitted.
May favorite bash "trick" is: !-1:gs/hello/world which runs the last command with all instances of hello replaced by world. !-1 can be any so called event designator, for instance !n to refer to any specific line number from history or !string for last command containing a particular string. Seriously people, read the man page for bash. Your shell has so many cool features.
And if you only have a single instance to replace, you can use ^old^new^ $ echo "hello hello hello world" hello hello hello world $ ^hello^bonjour^ echo "bonjour hello hello world" bonjour hello hello world
^-t
Re: How to navigate directories faster with Bash (2015)
#79I independently also have a stack of '...', '....' etc aliases almost exactly the same as this! Extremely useful I reckon! Another thing that I've found surprisingly invaluable is an alias (i went for 'ccd') that figures out (via python, so a bit slower on the 1st run) what part of the argument is a valid directory and then cd's you there. It's very handy indeed when working with file paths all the time (a film-vfx-o…
No need for stacks of `..`. Use this instead: function up() { for i in $(seq 1 $1); do cd ..; done } # usage: up # goes up 1 directory up 2 # goes up 2 directories up 42 # goes up 42 directories
function ..() { for i in $(seq 1 $1); do cd ..; done }
.. # goes up 1 dir
.. 2 # goes up 2 dirs
.. 42 # goes up 42 dirsRe: How to navigate directories faster with Bash (2015)
#80I just read the title and thought "Switch to Zsh". Bash is so amazingly clunky in comparison.