-
-
Save iwalton3/3f9bfce510f959782404be25cab1c871 to your computer and use it in GitHub Desktop.
Quick "cd from anywhere" alias
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function c { | |
while read -r _ dir | |
do | |
if [[ -e "$dir" ]] | |
then | |
echo "$dir" | |
cd "$dir" | |
break | |
fi | |
done < <(cat ~/.full_history | tail -n 10000 \ | |
| cut -f 3 | sort | uniq -dc | sort -hr | grep "/$1$") | |
} | |
function _c { | |
local IFS=$'\n' | |
COMPREPLY=( $(cat ~/.full_history | tail -n 10000 \ | |
| cut -f 3 | sort | uniq -dc | sort -hr \ | |
| sed 's/.*\///g' | grep "^$2") ) | |
} | |
complete -F _c c | |
tabChar=$'\t' | |
function prompt_command { | |
echo "$(date +%Y-%m-%d--%H-%M-%S)$tabChar$(hostname)$tabChar$PWD$tabChar$(history 1)" >> ~/.full_history | |
} | |
export PROMPT_COMMAND=prompt_command |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment