Last active
November 10, 2019 01:16
-
-
Save seanfarley/9570782e3c02f7cc87783319702d99dd to your computer and use it in GitHub Desktop.
my xonsh prompt translated to zshrc / bashrc
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 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