Skip to content

Instantly share code, notes, and snippets.

@seanfarley
Last active November 10, 2019 01:16
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 seanfarley/9570782e3c02f7cc87783319702d99dd to your computer and use it in GitHub Desktop.
Save seanfarley/9570782e3c02f7cc87783319702d99dd to your computer and use it in GitHub Desktop.
my xonsh prompt translated to zshrc / bashrc
function short_dir {
# zsh for the default
local DIR="%%~"
if [[ "$0" == *"bash"* ]]; then
DIR="\w"
fi
printf "$DIR"
}
function os_icon {
local ICON=""
if grep Ubuntu /etc/lsb-release &>/dev/null; then
ICON=""
elif [[ "$(uname -a)" == *"Darwin"* ]]; then
ICON=""
fi
printf "$ICON"
}
function update_ps1 {
export PS1=$'\n'"┌─ $USER $(os_icon) $(hostname -s) $(short_dir) "$'\n'"└─ "
}
# for bash
export PROMPT_COMMAND="update_ps1"
# for zsh
function precmd() {
eval "$PROMPT_COMMAND"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment