Skip to content

Instantly share code, notes, and snippets.

@nicerobot
Created December 16, 2011 06:01
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 nicerobot/1484716 to your computer and use it in GitHub Desktop.
Save nicerobot/1484716 to your computer and use it in GitHub Desktop.
Abbreviating PROMPT_COMMAND with ${HOME} to ~ replacement pure bash
#!/bin/bash
export PROMPT_COMMAND='PS1X=$(p="${PWD#${HOME}}"; [ "${PWD}" != "${p}" ] && printf "~";IFS=/; for q in ${p:1}; do printf /${q:0:1}; done; printf "${q:1}")'
export PS1='\j \u@\h:${PS1X} $ '
# http://unix.stackexchange.com/a/26860/6128
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment