3 ms·
I've been using the following in some form for over 3 decades! (now in zsh) alias .=cd In /bin/sh "." sources a script. While this can be common in a sc
by bakul 13y ago
I've been using the following in some form for over 3 decades!
(now in zsh)
alias .=cd
In /bin/sh "." sources a script. While this can be common in a script, one rarely does this interactively so I usurped . for the most common operation!
alias ,=pushd
alias ,,=popd
alias ,.=dirs
Think of cd as a goto, pushd as a call, popd as a return and dirs as a stack trace!
..() { cd ../$* }
cdpath=(. .. ~/src ~)
Use of cdpath can be confusing so it is best to show part of $PWD in the prompt:
PS1="%* %5. %h%(#.#.:) "
This ends the prompt with a # if you are running as superuser.
These aliases/functions are enabled in .zshrc (only if run interactively -- that is, they are included below the following test):
if [[ ! -o interactive ]] ; then return; fi
The "benefit" of Jeroen's mark/unmark is that these paths persist (and can be used from any window running a shell. I have not found much need for that + I can have different $dirs in different windows. Also, given that my shell windows (under screen) persist for a very long time, I don't need symlink's persistence!
Alternatively I define "." to be a function that does arg specific operation (cd if a dir, acroread if .pdf, vi if text etc.).