From fc327dacd538734da542d74c3fea584d205a1358 Mon Sep 17 00:00:00 2001 From: NeodarZ Date: Sat, 29 Jul 2017 20:28:50 +0200 Subject: Manual merge from t410 and update zsh conf file --- zsh/.zsh/aliases.zsh | 123 +++++++++++++------ zsh/.zsh/banner.zsh | 162 -------------------------- zsh/.zsh/banner.zsh_ | 162 ++++++++++++++++++++++++++ zsh/.zsh/keybindings.zsh | 4 + zsh/.zsh/keychain.zsh | 4 +- zsh/.zsh/nodejs.zsh | 2 +- zsh/.zsh/plugin.zsh | 3 + zsh/.zsh/plugins/zsh-autosuggestions | 1 + zsh/.zsh/plugins/zsh-history-substring-search | 1 + zsh/.zsh/plugins/zsh-syntax-highlighting | 1 + zsh/.zsh/prompt.zsh | 74 ++++++++++-- 11 files changed, 330 insertions(+), 207 deletions(-) delete mode 100755 zsh/.zsh/banner.zsh create mode 100755 zsh/.zsh/banner.zsh_ create mode 100644 zsh/.zsh/plugin.zsh create mode 160000 zsh/.zsh/plugins/zsh-autosuggestions create mode 160000 zsh/.zsh/plugins/zsh-history-substring-search create mode 160000 zsh/.zsh/plugins/zsh-syntax-highlighting diff --git a/zsh/.zsh/aliases.zsh b/zsh/.zsh/aliases.zsh index 8fe9d93..fb76cbe 100755 --- a/zsh/.zsh/aliases.zsh +++ b/zsh/.zsh/aliases.zsh @@ -15,48 +15,46 @@ # ░░░░░░░░░░ # #█▓▒░ aliases -alias xyzzy="echo nothing happens" -alias ls="ls -hF --color=auto" -alias ll="ls -lahF --color=auto" -alias lsl="ls -lhF --color=auto" -alias "cd.."="cd ../" -alias up="cd ../" +alias l='ls -F --color=auto --group-directories-first' +alias la='ls -lahF --color=auto --group-directories-first --time-style=+"%d.%m.%Y %H:%M"' +alias ll='ls -lhF --color=auto --group-directories-first --time-style=+"%d.%m.%Y %H:%M"' +alias ls='ls -F --color=auto --group-directories-first' +alias ".."="cd ../" +alias "..."="cd ../.." alias rmrf="rm -rf" alias psef="ps -ef" alias mkdir="mkdir -p" alias cp="cp -r" alias scp="scp -r" -alias mkdir="mkdir -p" alias xsel="xsel -b" alias fuck='sudo $(fc -ln -1)' alias v="vim" alias vi="vim" alias emacs="vim" -alias git="hub" -alias g="hub" +alias g="git" alias ga="git add" alias gc="git commit -m" alias gs="git status" alias gd="git diff" -alias gf="git fetch" +#alias gf="git fetch" To use with hub command alias gm="git merge" alias gr="git rebase" alias gp="git push" -alias gu="git unstage" -alias gg="git graph" +alias gu="git pull" +#alias gu="git unstage" # To use with hub command +#alias gg="git graph" # To use with hub command alias gco="git checkout" alias gcs="git commit -S -m" -alias gpr="hub pull-request" +#alias gpr="hub pull-request" To use with hub command alias ag="ag --color --color-line-number '0;35' --color-match '46;30' --color-path '4;36'" alias tree='tree -CAFa -I "CVS|*.*.package|.svn|.git|.hg|node_modules|bower_components" --dirsfirst' -alias rock="ncmpcpp" alias mixer="alsamixer" -alias genplaylist="cd ~/music;find . -name '*.mp3' -o -name '*.flac'|sed -e 's%^./%%g' > ~/.mpd/playlists/all.m3u" +#alias genplaylist="cd ~/music;find . -name '*.mp3' -o -name '*.flac'|sed -e 's%^./%%g' > ~/.mpd/playlists/all.m3u" alias matrix="cmatrix -b" alias tempwatch="while :; do sensors; sleep 1 && clear; done;" -alias term="urxvtc -hold -e " #used for run menu -alias sprunge="curl -F 'sprunge=<-' http://sprunge.us" -alias clbin="curl -F 'clbin=<-' https://clbin.com" +#alias term="urxvtc -hold -e " #used for run menu +#alias sprunge="curl -F 'sprunge=<-' http://sprunge.us" +#alias clbin="curl -F 'clbin=<-' https://clbin.com" alias toiletlist='for i in ${TOILET_FONT_PATH:=/usr/share/figlet}/*.{t,f}lf; do j=${i##*/}; echo ""; echo "╓───── "$j; echo "╙────────────────────────────────────── ─ ─ "; echo ""; toilet -d "${i%/*}" -f "$j" "${j%.*}"; done' alias ascii="toilet -t -f 3d" alias future="toilet -t -f future" @@ -64,14 +62,60 @@ alias rusto="toilet -t -f rusto" alias rustofat="toilet -t -f rustofat" alias lol="base64 ~/.config/mpd/playlists/all.m3u - mpc clear - mpc load all.m3u - mpc update -} +#function genplaylist() { +# cd ~/music +# find . -name '*.mp3' -o -name '*.flac'|sed -e 's%^./%%g' > ~/.config/mpd/playlists/all.m3u +# mpc clear +# mpc load all.m3u +# mpc update +#} function t() { X=$# @@ -104,14 +148,23 @@ function c() { done } # colorized less -function l() { +function le() { pygmentize -O style=sourcerer -f console256 -g $1 | less -r } # read markdown files like manpages -function md() { +function mdm() { pandoc -s -f markdown -t man "$*" | man -l - } # nullpointer url shortener -function short() { - curl -F"shorten=$*" https://0x0.st -} +#function short() { +# curl -F"shorten=$*" https://0x0.st +#} + +mkdir -p ~/.ssh-agent-thing +if ! pgrep -u "$USER" ssh-agent > /dev/null; then + ssh-agent > ~/.ssh-agent-thing +fi +if [[ "$SSH_AGENT_PID" == "" ]]; then + eval "$(<~/.ssh-agent-thing)" +fi + diff --git a/zsh/.zsh/banner.zsh b/zsh/.zsh/banner.zsh deleted file mode 100755 index 9c2903b..0000000 --- a/zsh/.zsh/banner.zsh +++ /dev/null @@ -1,162 +0,0 @@ -# ██ -# ░██ -# ██████ ██████░██ -# ░░░░██ ██░░░░ ░██████ -# ██ ░░█████ ░██░░░██ -# ██ ░░░░░██░██ ░██ -# ██████ ██████ ░██ ░██ -# ░░░░░░ ░░░░░░ ░░ ░░ -# -# ▓▓▓▓▓▓▓▓▓▓ -# ░▓ author ▓ xero -# ░▓ code ▓ http://code.xero.nu/dotfiles -# ░▓ mirror ▓ http://git.io/.files -# ░▓▓▓▓▓▓▓▓▓▓ -# ░░░░░░░░░░ -# -#█▓▒░ pick a random number -_RAND=`shuf -i1-10 -n1` - -#█▓▒░ display a random ascii banner -case $_RAND in -1) -cat << X0 - : - |\\____.____ .______._______. - ._____| / _/__ _|_ / \\ |__ - \\__ | _/_ _) Y _ _/__| __ / - / _ / \\ | | /| / | - / |___(__ |__| |_ | - \\_____l __ \\_____/__ l______/\\______/ - \\_____/ \\______/ \\______/\\______/ - x0^b7^imp! - -X0 -;; -2) -cat << X0 - : - |\\_____.____ /\\_____.________. - ._____| / _/___ _/_ / \\ _ |__ - \\__ | _/_ _) Y _ _/__| / / - / _ / \\ | | /| | - / :.. |____(__ ..:: |__| ..:: |_ ..:: | - \\_____l \\______/ l_______/\\_______/ - x0^b7^imp! - -X0 -;; -3) -cat << X0 - . - ____/|______.____ /\\_____.________. - \\ | / _/___ _/_ / \\ _ |__ - \\_ | __/ _) Y _ _/__| / / - / _ \\ \\ | | /| | - _/ .: | .: \\__ ..:: |__| ..:: |_ ..:: | - \\_____l____ /\\______/ l_______/\\_______/ - \\/ x0^b7^imp! - -X0 -;; -4) -cat << X0 - ____ _ . . _ ___ - \\ \\ - ___/\\ _____ /\\______ ____/\\ ___/\\ - \\ _ \\/ .://.:\\____//_\\_. \\ /./__ \\ - \\\\ / // ___// .\\/ _// \\ / \\ - /.: \\ \\_. // _. \\/ .:\\/ / - __/____/\\ __\\/__ //______| /\\_______/__ - \\ \\/ \\/ |/x0^b7^imp! / - _\\ | /_ - \\ / - -X0 -;; -5) -cat << X0 - - ___/\\ _____ /\\______ ____/\\ ___/\\ - \\ _ \\/ .://.:\\____//_\\_. \\ /./__ \\ - \\\\ / // ___// .\\/ _// \\ / \\ - /.: \\ \\_. // _. \\/ .:\\/ / - /____/\\ __\\/__ //______| /\\_______/ - \\/ \\/ |/x0^b7^imp! - -X0 -;; -6) -cat << X0 - - _________/\\________________________________/\\_______ - \\ / /\\_______ /______ /\\/ \\__ \\ - \\_ / _/ / _/ /\\_ _/ _/ / / / / - _/ _ \\_/ ______/_/ _ \\_/ / / / - \\ \\ / \\_ / \\ / \\/ / - \\______\\ /\\___________/______\\ /\\_________/ - \\ / \\ / x0^b7^imp! - \\/ \\/ - -X0 -;; -7) -cat << X0 - - ________ /\\________________________________/\\_______ - \\ / _________ _______ __/ \\__ \\ - \\_ / _/ / _/ /\\_ _/ _/ / / / / - _/ _ \\_/ ______/_/ _ \\_/ / / / - \\ \\ / \\_ / \\ / \\/ / - \\______\\ /\\___________/______\\ /\\_________/ - \\ / \\ / x0^b7^imp! - \\/ \\/ - -X0 -;; -8) -cat << X0 - - :_____ _________ __________ _______. - ______| \\__/ ___ \\ _/ ___ \\ / |__ - / | __/\\_ |/ \\\\_ |/ \\/ : \\_ - / : \\ | /_____/| / _/ __. __/\\ - \\___ \\/ \\/ \\ _ |/ \\ < - / . \\_ \\_ \\ \\ / / / - / | _ _ \\ / / / - \\ ______|______/\\_____________/\\_____ \\ __/\\________ / / - \\/ ____|_____/ \\____________/\\_______ \\/ /\\_______\\/ / - \\/ : x0^b7^imp! \\/ \\/ - -X0 -;; -9) -cat << X0 - - :_____ _________ __________ _______. - ______| \\__/ ___ \\ _/ ___ \\ / |__ - / | __/\\_ |/ \\\\_ |/ \\/ : \\_ - / : \\ | /_____/| / _/ __. __/\\ - \\___ \\/ \\/ \\ _ |/ \\_/ - / . /_ \\_ \\ \\ / /\\ - / | _ _ \\ / / / - \\ ______|______///\\_________///\\_____ \\ __///\\______ / / - \\/ ____|_____/ \\_______/ \\_____ \\/ / \\____\\/ / - \\/ : x0^b7^imp! \\/ \\/ - -X0 -;; -10) -cat << X0 - _____ _____ - \\ \\ / /_________ ___________ _____________ - \\ \\ / /\\\\ / _\\ __ /_\\\\ __ / - _ __\\ \\/ /_ __/ / _/ _/ / __ / __ _ - // /\\ \\\\ __\\__/ \\ \\/ / / / - / / \\ \\ //____/ \\ \\ / / - / / \\_____\\_______/ \\ \\__________// - \\_____\\\\ //_____/ x0^b7^imp! - -X0 -;; -esac diff --git a/zsh/.zsh/banner.zsh_ b/zsh/.zsh/banner.zsh_ new file mode 100755 index 0000000..9c2903b --- /dev/null +++ b/zsh/.zsh/banner.zsh_ @@ -0,0 +1,162 @@ +# ██ +# ░██ +# ██████ ██████░██ +# ░░░░██ ██░░░░ ░██████ +# ██ ░░█████ ░██░░░██ +# ██ ░░░░░██░██ ░██ +# ██████ ██████ ░██ ░██ +# ░░░░░░ ░░░░░░ ░░ ░░ +# +# ▓▓▓▓▓▓▓▓▓▓ +# ░▓ author ▓ xero +# ░▓ code ▓ http://code.xero.nu/dotfiles +# ░▓ mirror ▓ http://git.io/.files +# ░▓▓▓▓▓▓▓▓▓▓ +# ░░░░░░░░░░ +# +#█▓▒░ pick a random number +_RAND=`shuf -i1-10 -n1` + +#█▓▒░ display a random ascii banner +case $_RAND in +1) +cat << X0 + : + |\\____.____ .______._______. + ._____| / _/__ _|_ / \\ |__ + \\__ | _/_ _) Y _ _/__| __ / + / _ / \\ | | /| / | + / |___(__ |__| |_ | + \\_____l __ \\_____/__ l______/\\______/ + \\_____/ \\______/ \\______/\\______/ + x0^b7^imp! + +X0 +;; +2) +cat << X0 + : + |\\_____.____ /\\_____.________. + ._____| / _/___ _/_ / \\ _ |__ + \\__ | _/_ _) Y _ _/__| / / + / _ / \\ | | /| | + / :.. |____(__ ..:: |__| ..:: |_ ..:: | + \\_____l \\______/ l_______/\\_______/ + x0^b7^imp! + +X0 +;; +3) +cat << X0 + . + ____/|______.____ /\\_____.________. + \\ | / _/___ _/_ / \\ _ |__ + \\_ | __/ _) Y _ _/__| / / + / _ \\ \\ | | /| | + _/ .: | .: \\__ ..:: |__| ..:: |_ ..:: | + \\_____l____ /\\______/ l_______/\\_______/ + \\/ x0^b7^imp! + +X0 +;; +4) +cat << X0 + ____ _ . . _ ___ + \\ \\ + ___/\\ _____ /\\______ ____/\\ ___/\\ + \\ _ \\/ .://.:\\____//_\\_. \\ /./__ \\ + \\\\ / // ___// .\\/ _// \\ / \\ + /.: \\ \\_. // _. \\/ .:\\/ / + __/____/\\ __\\/__ //______| /\\_______/__ + \\ \\/ \\/ |/x0^b7^imp! / + _\\ | /_ + \\ / + +X0 +;; +5) +cat << X0 + + ___/\\ _____ /\\______ ____/\\ ___/\\ + \\ _ \\/ .://.:\\____//_\\_. \\ /./__ \\ + \\\\ / // ___// .\\/ _// \\ / \\ + /.: \\ \\_. // _. \\/ .:\\/ / + /____/\\ __\\/__ //______| /\\_______/ + \\/ \\/ |/x0^b7^imp! + +X0 +;; +6) +cat << X0 + + _________/\\________________________________/\\_______ + \\ / /\\_______ /______ /\\/ \\__ \\ + \\_ / _/ / _/ /\\_ _/ _/ / / / / + _/ _ \\_/ ______/_/ _ \\_/ / / / + \\ \\ / \\_ / \\ / \\/ / + \\______\\ /\\___________/______\\ /\\_________/ + \\ / \\ / x0^b7^imp! + \\/ \\/ + +X0 +;; +7) +cat << X0 + + ________ /\\________________________________/\\_______ + \\ / _________ _______ __/ \\__ \\ + \\_ / _/ / _/ /\\_ _/ _/ / / / / + _/ _ \\_/ ______/_/ _ \\_/ / / / + \\ \\ / \\_ / \\ / \\/ / + \\______\\ /\\___________/______\\ /\\_________/ + \\ / \\ / x0^b7^imp! + \\/ \\/ + +X0 +;; +8) +cat << X0 + + :_____ _________ __________ _______. + ______| \\__/ ___ \\ _/ ___ \\ / |__ + / | __/\\_ |/ \\\\_ |/ \\/ : \\_ + / : \\ | /_____/| / _/ __. __/\\ + \\___ \\/ \\/ \\ _ |/ \\ < + / . \\_ \\_ \\ \\ / / / + / | _ _ \\ / / / + \\ ______|______/\\_____________/\\_____ \\ __/\\________ / / + \\/ ____|_____/ \\____________/\\_______ \\/ /\\_______\\/ / + \\/ : x0^b7^imp! \\/ \\/ + +X0 +;; +9) +cat << X0 + + :_____ _________ __________ _______. + ______| \\__/ ___ \\ _/ ___ \\ / |__ + / | __/\\_ |/ \\\\_ |/ \\/ : \\_ + / : \\ | /_____/| / _/ __. __/\\ + \\___ \\/ \\/ \\ _ |/ \\_/ + / . /_ \\_ \\ \\ / /\\ + / | _ _ \\ / / / + \\ ______|______///\\_________///\\_____ \\ __///\\______ / / + \\/ ____|_____/ \\_______/ \\_____ \\/ / \\____\\/ / + \\/ : x0^b7^imp! \\/ \\/ + +X0 +;; +10) +cat << X0 + _____ _____ + \\ \\ / /_________ ___________ _____________ + \\ \\ / /\\\\ / _\\ __ /_\\\\ __ / + _ __\\ \\/ /_ __/ / _/ _/ / __ / __ _ + // /\\ \\\\ __\\__/ \\ \\/ / / / + / / \\ \\ //____/ \\ \\ / / + / / \\_____\\_______/ \\ \\__________// + \\_____\\\\ //_____/ x0^b7^imp! + +X0 +;; +esac diff --git a/zsh/.zsh/keybindings.zsh b/zsh/.zsh/keybindings.zsh index 2f80417..5959ab4 100755 --- a/zsh/.zsh/keybindings.zsh +++ b/zsh/.zsh/keybindings.zsh @@ -49,3 +49,7 @@ if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then zle -N zle-line-init zle -N zle-line-finish fi + +# Navigate words with ctrl+arrow keys +bindkey '^[[1;5D' backward-word +bindkey '^[[1;5C' forward-word diff --git a/zsh/.zsh/keychain.zsh b/zsh/.zsh/keychain.zsh index aee1aca..1585f26 100755 --- a/zsh/.zsh/keychain.zsh +++ b/zsh/.zsh/keychain.zsh @@ -15,7 +15,7 @@ # ░░░░░░░░░░ # #█▓▒░ ssh keys -export SSH_KEY_PATH="~/.ssh/id_rsa" +#export SSH_KEY_PATH="~/.ssh/id_rsa" #█▓▒░ funtoo keychain -eval `keychain -q --eval ~/.ssh/id_rsa` +#eval `keychain -q --eval ~/.ssh/id_rsa` diff --git a/zsh/.zsh/nodejs.zsh b/zsh/.zsh/nodejs.zsh index fb762b5..4f95e1e 100755 --- a/zsh/.zsh/nodejs.zsh +++ b/zsh/.zsh/nodejs.zsh @@ -15,7 +15,7 @@ # ░░░░░░░░░░ # #█▓▒░ node version manager -source ~/.nvm/nvm.sh +#source ~/.nvm/nvm.sh #█▓▒░ aliases alias node="sudo node" diff --git a/zsh/.zsh/plugin.zsh b/zsh/.zsh/plugin.zsh new file mode 100644 index 0000000..5519c2c --- /dev/null +++ b/zsh/.zsh/plugin.zsh @@ -0,0 +1,3 @@ +source ~/.zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh +source ~/.zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh +source ~/.zsh/plugins/zsh-history-substring-search/zsh-history-substring-search.zsh diff --git a/zsh/.zsh/plugins/zsh-autosuggestions b/zsh/.zsh/plugins/zsh-autosuggestions new file mode 160000 index 0000000..e304365 --- /dev/null +++ b/zsh/.zsh/plugins/zsh-autosuggestions @@ -0,0 +1 @@ +Subproject commit e30436574599df0f127153fea0c2ea86942ba11a diff --git a/zsh/.zsh/plugins/zsh-history-substring-search b/zsh/.zsh/plugins/zsh-history-substring-search new file mode 160000 index 0000000..933733e --- /dev/null +++ b/zsh/.zsh/plugins/zsh-history-substring-search @@ -0,0 +1 @@ +Subproject commit 933733e86724a018cb98cb8f514fc3d323461f74 diff --git a/zsh/.zsh/plugins/zsh-syntax-highlighting b/zsh/.zsh/plugins/zsh-syntax-highlighting new file mode 160000 index 0000000..5feed23 --- /dev/null +++ b/zsh/.zsh/plugins/zsh-syntax-highlighting @@ -0,0 +1 @@ +Subproject commit 5feed23962df4dd6b8ef7fb1946617140d4078aa diff --git a/zsh/.zsh/prompt.zsh b/zsh/.zsh/prompt.zsh index 4203929..cf1b525 100644 --- a/zsh/.zsh/prompt.zsh +++ b/zsh/.zsh/prompt.zsh @@ -13,21 +13,69 @@ # ░▓ mirror ▓ http://git.io/.files # ░▓▓▓▓▓▓▓▓▓▓ # ░░░░░░░░░░ +autoload -U compinit colors zcalc +compinit -d +colors -#ICO_DIRTY="⚡" +ICO_DIRTY="⚡" #ICO_DIRTY="↯" -ICO_DIRTY="*" -#ICO_AHEAD="↑" -ICO_AHEAD="🠙" +#ICO_DIRTY="*" +ICO_AHEAD="↑" +#ICO_AHEAD="🠙" #ICO_AHEAD="▲" -#ICO_BEHIND="↓" -ICO_BEHIND="🠛" +ICO_BEHIND="↓" +#ICO_BEHIND="🠛" #ICO_BEHIND="▼" ICO_DIVERGED="⥮" COLOR_ROOT="%F{red}" COLOR_USER="%F{cyan}" COLOR_NORMAL="%F{white}" PROMPT_STYLE="classic" +# Modify the colors and symbols in these variables as desired. +GIT_PROMPT_SYMBOL="%{$fg[blue]%}±" # plus/minus - clean repo +GIT_PROMPT_PREFIX="%{$fg[green]%} %{$reset_color%}" +GIT_PROMPT_SUFFIX="%{$fg[green]%}%{$reset_color%}" +GIT_PROMPT_AHEAD="%{$fg[red]%}ANUM%{$reset_color%}" # A"NUM" - ahead by "NUM" commits +GIT_PROMPT_BEHIND="%{$fg[cyan]%}BNUM%{$reset_color%}" # B"NUM" - behind by "NUM" commits +GIT_PROMPT_MERGING="%{$fg_bold[magenta]%}⚡%{$reset_color%}" # lightning bolt - merge conflict +GIT_PROMPT_UNTRACKED="%{$fg_bold[red]%}●%{$reset_color%}" # red circle - untracked files +GIT_PROMPT_MODIFIED="%{$fg_bold[yellow]%}●%{$reset_color%}" # yellow circle - tracked files modified +GIT_PROMPT_STAGED="%{$fg_bold[green]%}●%{$reset_color%}" # green circle - staged changes present = ready for "git push" + +parse_git_branch() { + # Show Git branch/tag, or name-rev if on detached head + ( git symbolic-ref -q HEAD || git name-rev --name-only --no-undefined --always HEAD ) 2> /dev/null +} + +parse_git_state() { + # Show different symbols as appropriate for various Git repository states + # Compose this value via multiple conditional appends. + local GIT_STATE="" + local NUM_AHEAD="$(git log --oneline @{u}.. 2> /dev/null | wc -l | tr -d ' ')" + if [ "$NUM_AHEAD" -gt 0 ]; then + GIT_STATE=$GIT_STATE${GIT_PROMPT_AHEAD//NUM/$NUM_AHEAD} + fi + local NUM_BEHIND="$(git log --oneline ..@{u} 2> /dev/null | wc -l | tr -d ' ')" + if [ "$NUM_BEHIND" -gt 0 ]; then + GIT_STATE=$GIT_STATE${GIT_PROMPT_BEHIND//NUM/$NUM_BEHIND} + fi + local GIT_DIR="$(git rev-parse --git-dir 2> /dev/null)" + if [ -n $GIT_DIR ] && test -r $GIT_DIR/MERGE_HEAD; then + GIT_STATE=$GIT_STATE$GIT_PROMPT_MERGING + fi + if [[ -n $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then + GIT_STATE=$GIT_STATE$GIT_PROMPT_UNTRACKED + fi + if ! git diff --quiet 2> /dev/null; then + GIT_STATE=$GIT_STATE$GIT_PROMPT_MODIFIED + fi + if ! git diff --cached --quiet 2> /dev/null; then + GIT_STATE=$GIT_STATE$GIT_PROMPT_STAGED + fi + if [[ -n $GIT_STATE ]]; then + echo "$GIT_PROMPT_PREFIX$GIT_STATE$GIT_PROMPT_SUFFIX" + fi +} #█▓▒░ allow functions in the prompt @@ -42,6 +90,17 @@ else # root! USER_LEVEL="${COLOR_ROOT}" fi +git_prompt_string() { + local git_where="$(parse_git_branch)" + + # If inside a Git repository, print its branch and state + [ -n "$git_where" ] && echo "$GIT_PROMPT_SYMBOL$(parse_git_state)$GIT_PROMPT_PREFIX%{$fg[yellow]%}${git_where#(refs/heads/|tags/)}$GIT_PROMPT_SUFFIX" + + # If not inside the Git repo, print exit codes of last command (only if it failed) + [ ! -n "$git_where" ] && echo "%{$fg[red]%}%(?..%?)" +} + + #█▓▒░ git prompt GIT_PROMPT() { test=$(git rev-parse --is-inside-work-tree 2> /dev/null) @@ -116,6 +175,7 @@ ${USER_LEVEL}└─ - %f' ;; #█▓▒░ classic *) -PROMPT='${USER_LEVEL}[${COLOR_NORMAL}%~${USER_LEVEL}]$(GIT_PROMPT)── - %f' +PROMPT='%F{cyan}┌─[$USER@$HOST]─[$(git_prompt_string)${USER_LEVEL}]─[${COLOR_NORMAL}%~${USER_LEVEL}] +└─ - %f' ;; esac -- cgit v1.2.1