diff --git a/bash_tools.sh b/bash_tools.sh index 923c577..0501ca6 100644 --- a/bash_tools.sh +++ b/bash_tools.sh @@ -5,17 +5,15 @@ # be used # doc for api: https://ip-api.com/docs/api -if [ ! -z "$ZSH_NAME" ]; then +if [ -n "$ZSH_NAME" ]; then SHELL_NAME=zsh DOTFILE_DIR=${0:a:h}/ -else + source $DOTFILE_DIR/bash_tools/theme_zsh.sh + +elif [ -n "$SHELL" ];then SHELL_NAME=bash - - # display git status - export GIT_PS1_SHOWDIRTYSTATE=1 - - export PS1='\[\e[01;32m\]\w\[\e[01;31m\]$(__git_ps1 " (%s)")\[\e[00m\] ' DOTFILE_DIR=$(dirname ${BASH_SOURCE[0]})/ + source $DOTFILE_DIR/bash_tools/theme_bash.sh fi function ipinfo(){ diff --git a/bash_tools/theme_bash.sh b/bash_tools/theme_bash.sh new file mode 100644 index 0000000..090c394 --- /dev/null +++ b/bash_tools/theme_bash.sh @@ -0,0 +1,4 @@ + +# display git status +export GIT_PS1_SHOWDIRTYSTATE=1 +export PS1='\[\e[0;32m\]\w\[\e[01;31m\]$(__git_ps1 " (%s)")\[\e[00m\] ' diff --git a/bash_tools/theme_zsh.sh b/bash_tools/theme_zsh.sh new file mode 100644 index 0000000..c64dd3e --- /dev/null +++ b/bash_tools/theme_zsh.sh @@ -0,0 +1,17 @@ + +# Autoload zsh add-zsh-hook and vcs_info functions (-U autoload w/o substition, -z use zsh style) +autoload -Uz add-zsh-hook vcs_info +# Enable substitution in the prompt. +setopt prompt_subst +# Run vcs_info just before a prompt is displayed (precmd) +add-zsh-hook precmd vcs_info +# Enable checking for (un)staged changes, enabling use of %u and %c +zstyle ':vcs_info:*' check-for-changes true +# Set custom strings for an unstaged vcs repo changes (*) and staged changes (+) +zstyle ':vcs_info:*' unstagedstr ' *' +zstyle ':vcs_info:*' stagedstr ' +' +# Set the format of the Git information for vcs_info +zstyle ':vcs_info:git:*' formats '(%b%u%c)' +zstyle ':vcs_info:git:*' actionformats '(%b|%a%u%c)' + +export PS1='%F{green}%1~ %F{cyan}${vcs_info_msg_0_}%f '