commit dfc73b4e19fb5c6bfc8f0f2d16537f814ad2d379 (patch)
parent 28eaa4f0184b182d2f2614c7374610d44fb826d3
Author: Alex Karle <alex@karle.co>
Date: Tue, 30 Apr 2019 22:54:15 -0400
[bash] update aliases and add exit code to prompt
Specifically, it's nice to see the exit code if it's non-zero.
Props to Mike for the inspiration.
Diffstat:
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/bash/aliases b/bash/aliases
@@ -23,10 +23,12 @@ alias gl='git pull'
alias gco='git checkout'
alias gf='git fetch'
alias glg='git log --stat'
+alias glgr='git log --oneline | head -n 10'
alias g_='git stash'
alias g_p='git stash pop'
alias gb='git branch'
alias gr='git rebase'
+alias vlg='vim -c "GV"' # 'vim log' of a file
# Git completion for aliases
if [ -n "$(type -t __git_complete)" ] && [ "$(type -t __git_complete)" == "function" ]; then
diff --git a/bash/bash_prompt b/bash/bash_prompt
@@ -26,10 +26,18 @@ function parse_git_branch() {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/"
}
+function get_error_code() {
+ err="$?"
+ if [ $err -ne "0" ]; then
+ echo "[$err] "
+ fi
+}
+
# Preferred Prompt: Fancy with colors from tput
if tput setaf 1 &> /dev/null; then tput sgr0
if [[ $(tput colors) -ge 16 ]] 2>/dev/null; then
SET_PREFERRED_PROMPT=1
+ RED="\[$(tput setaf 1)\]"
MAGENTA="\[$(tput setaf 5)\]"
ORANGE="\[$(tput setaf 11)\]"
GRAY="\[$(tput setaf 8)\]"
@@ -37,7 +45,7 @@ if tput setaf 1 &> /dev/null; then tput sgr0
BOLD="\[$(tput bold)\]"
RESET="\[$(tput sgr0)\]"
- export PS1="$BOLD$BLUE\w $RESET$GRAY${ssh_text}\$(parse_git_branch)"$'\n'"$BOLD$MAGENTA\$ $RESET"
+ export PS1="$BOLD$RED\$(get_error_code)$BLUE\w $RESET$GRAY${ssh_text}\$(parse_git_branch)"$'\n'"$BOLD$MAGENTA\$ $RESET"
export PS2="$ORANGE> $RESET"
fi
fi