Last active
November 5, 2024 12:49
-
-
Save TheBigRoomXXL/73f18cd39d667ab5468a69793b5dc1b2 to your computer and use it in GitHub Desktop.
A portable script for a powerline like prompt
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
#!/usr/bin/env bash | |
# A portable script for a powerline like prompt | |
reset='\[\033[0m\]' | |
bg='\[\033[48;2;48;48;48m\]' | |
blue='\[\033[38;2;0;175;255m\]' | |
green='\[\033[38;2;95;215;0m\]' | |
grey='\[\033[38;2;88;88;88m\]' | |
greydark='\[\033[38;2;48;48;48m\]' | |
# Disable PS hijacking by venv | |
VIRTUAL_ENV_DISABLE_PROMPT=1 | |
get_venv() { | |
[ -n "$VIRTUAL_ENV" ] && printf "venv" | |
} | |
get_chevron_1(){ | |
[ -n "$VIRTUAL_ENV" ] && printf " ❯ " | |
} | |
get_identity(){ | |
[ "$(hostname)" != "laptop" ] && printf "$(whoami)@$(hostname)" | |
} | |
get_chevron_2(){ | |
[ "$(hostname)" != "laptop" ] && printf " ❯ " | |
} | |
get_branch() { | |
branch=$(git branch --show-current 2>/dev/null) | |
[ -n "$branch" ] && printf "$branch" | |
} | |
get_chevron_3(){ | |
branch=$(git branch --show-current 2>/dev/null) | |
[ -n "$branch" ] && printf " ❯ " | |
} | |
# You can replace with ▓▒░ if you don't have the powerline fonts | |
PS1="${bg} ${green}\$(get_venv)${grey}\$(get_chevron_1)${green}\$(get_identity)${grey}\$(get_chevron_2)${blue}\w${grey}\$(get_chevron_3)${green}\$(get_branch) ${reset}${greydark}${reset}\n${green}❯${reset} " | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment