Skip to content

Instantly share code, notes, and snippets.

@jimcavoli
Last active June 23, 2016 19:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimcavoli/e8399e7b40ceac4e76646260f1ebf9fa to your computer and use it in GitHub Desktop.
Save jimcavoli/e8399e7b40ceac4e76646260f1ebf9fa to your computer and use it in GitHub Desktop.
Change your bash prompt to an abbreviated PWD, followed by a lyric from Daft Punk's Technologic. Works best with Powerline-patched fonts (sub out the unicode characters if you're not that cool).
bash_prompt_command() {
prompts=("buy it" "use it" "break it" "fix it" "trash it" "change it" "melt/upgrade it"\
"charge it" "pawn it" "zoom it" "press it" "snap it" "work it" "quick/erase it"\
"write it" "get it" "paste it" "save it" "load it" "check it" "quick/rewrite it"\
"plug it" "play it" "burn it" "rip it" "drag and drop it" "zip/unzip it"\
"lock it" "fill it" "curl it" "find it" "view it" "curl it" "jam/unlock it"\
"surf it" "scroll it" "pose it" "click it" "cross it" "crack it" "twitch/update it"\
"name it" "read it" "tune it" "print it" "scan it" "send it" "fax/rename it"\
"touch it" "bring it" "pay it" "watch it" "turn it" "leave it" "stop/format it")
# How many characters of the $PWD should be kept
local pwdmaxlen=20
# Indicate that there has been dir truncation
local trunc_symbol="≈"
local dir=${PWD##*/}
pwdmaxlen=$(( ( pwdmaxlen < ${#dir} ) ? ${#dir} : pwdmaxlen ))
local new_pwd=${PWD/#$HOME/\~}
local pwdoffset=$(( ${#new_pwd} - pwdmaxlen ))
if [ ${pwdoffset} -gt "0" ]; then
new_pwd=${new_pwd:$pwdoffset:$pwdmaxlen}
new_pwd=${trunc_symbol}/${new_pwd#*/}
fi
PS1="\[\033[7m\] $new_pwd\[\033[00m\]<U+E0B0> ${prompts[$(($RANDOM % 55))]} <U+E0B1> "
}
PROMPT_COMMAND=bash_prompt_command
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment