Skip to content

Instantly share code, notes, and snippets.

@kiselev-nikolay
Created June 18, 2021 06:10
Show Gist options
  • Save kiselev-nikolay/044dc9786d89a727d74c5c6dd4b728c6 to your computer and use it in GitHub Desktop.
Save kiselev-nikolay/044dc9786d89a727d74c5c6dd4b728c6 to your computer and use it in GitHub Desktop.
Bash prompt which I put on my servers. beautiful and requires nothing.
alias i='hostname -I | cut -d " " -f 1'
alias ll='ls -alah'
alias fuck='git update-index --assume-unchanged'
alias unfuck='git update-index --no-assume-unchanged'
function getPS1() {
EXIT_CODE=$?;
printf "\n$(tput setaf 0)$(tput setab 2) $USER@$(i) $(tput sgr 0)";
if [ -d ".git" ]; then
printf "$(tput setaf 0)$(tput setab 5) $(git rev-parse --abbrev-ref HEAD 2> /dev/null)$(tput sgr 0)"
fi
printf "$(tput setaf 0)$(tput setab 4) ${PWD##/home/$USER} $(tput sgr 0)";
printf "$(tput setaf 4)$(tput sgr 0)\n";
[[ EXIT_CODE -eq 0 ]] && printf "$(tput setaf 4)" || printf "$(tput setaf 1)"
printf "$(date +"%T")$(tput sgr 0)"
printf "$(tput bold)  $(tput sgr 0)";
}
export PS1='$(getPS1)'
@kiselev-nikolay
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment