From: Mike Frysinger Date: Thu, 29 Dec 2016 23:28:40 +0000 (-0500) Subject: add history to `cd` by default X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=cf68f8b6de8cf24dabbe6bdd7ce107d589665a2e;p=home.git add history to `cd` by default --- diff --git a/.profile.d/aliases.sh b/.profile.d/aliases.sh index f7d6f6e..3ee83b7 100644 --- a/.profile.d/aliases.sh +++ b/.profile.d/aliases.sh @@ -44,11 +44,41 @@ adk_path() { pd() { if [[ $# -eq 0 ]] ; then popd + elif [[ $# -eq 1 && $1 == "--" ]] ; then + dirs -v else pushd "$@" fi } +cd_history() { + if [[ $# -eq 1 ]] ; then + case $1 in + -h) + command dirs "$1" |& tail -1 + command cd "$1" |& tail -1 + return + ;; + --help) + command dirs "$1" + command cd "$1" + return + ;; + -[clpv]) + command dirs "$1" + return + ;; + -[0-9]*) + set -- "$(dirs "+${1:1}")" + ;; + esac + fi + if command cd "$@" ; then + pushd -n "${PWD}" >/dev/null + fi +} +alias cd='cd_history' + if [[ ${TERM} != "dumb" ]] ; then export GREP_COLORS=ne #470810 alias grep='grep --colour=auto -d skip'