Wow I’m just blown away by this. Really cool trick to navigate directories fast I’m definitely going to add this to my .zshrc Honestly commandline has made so many things easier for me that I don’t even use regular apps besides my browser for browsing web anyhow using commandline has really made me productive And I always look for automating or making the workflow better Anyways great post thanks for sharing:)
For Zsh, there are better stuff available. For example, you can use `cd + ` to change to a past directory. And instead of aliases for `.....`, you can use: # Expand ... to ../.. function vbe-expand-dot-to-parent-directory-path() { case $LBUFFER in (./..|* ./..) LBUFFER+='.' ;; # In Go: "go list ./..." (..|*[ /=]..) LBUFFER+='/..' ;; (*) LBUFFER+='.' ;; esac } zle -N vbe-expand-dot-to-parent-directory-path bindkey "."…
How to navigate directories faster with Bash (2015)
51–60 of 179 posts
Re: How to navigate directories faster with Bash (2015)
#52Bash is so amazingly clunky in comparison.
Re: How to navigate directories faster with Bash (2015)
#53Re: How to navigate directories faster with Bash (2015)
#54 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 test3Re: How to navigate directories faster with Bash (2015)
#55Earlier quoted context omitted.
Typing Esc then . does the trick too.
Alt + . does the same thing as well, with the added advantage that you can keep pressing alt and then hit . several times to go through all the "last arguments" in your history one by one. Further, holding Alt followed by numeric argument followed by dot, gives you an argument at a specific position. For example, Alt + 1, Alt + . copies the first argument.
Re: How to navigate directories faster with Bash (2015)
#56I'm using this bash script that adds a web-browser like history management (going forward with "+" and backward with "-"). It's been used for a couple of decades now. https://gist.github.com/euske/4f06a6e060131949085c493bd28a0c... edit: url
Re: How to navigate directories faster with Bash (2015)
#57export MARKPATH=$HOME/.marks function jump { cd -P $MARKPATH/$1 2>/dev/null || echo "No such mark: $1" } function ju { cd -P $MARKPATH/$1 2>/dev/null || echo "No such mark: $1" } function mark { mkdir -p $MARKPATH; ln -s $(pwd) $MARKPATH/$1 } function unmark { rm -i $MARKPATH/$1 } function marks { ls -l $MARKPATH | sed 's/ / /g' | cut -d' ' -f9- | sed 's/ -/\t-/g' && echo }
I think the original source is #http://jeroenjanssens.com/2013/08/16/quickly-navigate-your-f...
Another neat trick is to set you .inputrc to vi mode with
set editing-mode vi set keymap vi
and then put this in your .bashrc
bind -m vi-insert -x '"\C-h"':'"pushd . 1>/dev/null 2>/dev/null && cd ../ && echo -e ${LILA} $PWD && ls"' bind -m vi-insert -x '"\C-n"':'"popd 1>/dev/null 2>/dev/null && echo -e ${LILA} $PWD && ls"' bind -m vi-insert -x '"\C-b":"cd $HOME && echo -e ${LILA} $PWD && ls"'
This enables you to go a directory up using ctrl-h and go back using ctrl-n.
Re: How to navigate directories faster with Bash (2015)
#58And ~mylogin is another alias for ones home directory.
And more generally, ~otherdev is an alias for otherdev's home directory.
Re: How to navigate directories faster with Bash (2015)
#59 export CDPATH=.:~/.marks/
function mark {
ln -sr "$(pwd)" ~/.marks/"$1"
}
mark @name # create a bookmark
cd @name # jump to bookmark
cd @ # list bookmarks
cd @n # auto-complete
cd @name/ # can access sub-directories within bookmarks
Works best when bookmarks are prefixed by "@" or other special symbol. Additional advantage is that you can use the same function `cd` to navigate both bookmarked and regular directories.[1]: http://karolis.koncevicius.lt/posts/fast_navigation_in_the_c...
Re: How to navigate directories faster with Bash (2015)
#60Good selection of tips, like Normille I didn't know $! even though I have read Bash's man page through more than once. Note that many of these are not just for Bash. pushd/popd is near universal among shells and CDPATH is standard among SYSV shells. The idea of a shortcut for cd .. and its repetitions is good, but I'd prefer alias p='cd ..', pp='cd ../..' and so on, since I balk at the idea of having to distinguish,…
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…