zshrc: configurability, ssh hostname display

This commit is contained in:
Cynthia Foxwell 2022-04-17 19:44:40 -06:00
parent 84f679db82
commit 372e05a172

View file

@ -4,10 +4,15 @@ fi
fpath=(~/.zsh $fpath)
if [[ ! -d "$HOME/.zsh/gitstatus" ]]; then
git clone --depth=1 https://github.com/romkatv/gitstatus.git ~/.zsh/gitstatus
CONF_BINARYCLOCK=1
CONF_ENABLEGIT=1
if [[ $CONF_ENABLEGIT -eq 1 ]]; then
if [[ ! -d "$HOME/.zsh/gitstatus" ]]; then
git clone --depth=1 https://github.com/romkatv/gitstatus.git ~/.zsh/gitstatus
fi
source ~/.zsh/gitstatus/gitstatus.plugin.zsh
fi
source ~/.zsh/gitstatus/gitstatus.plugin.zsh
# Lines configured by zsh-newuser-install
HISTFILE=~/.histfile
@ -17,46 +22,9 @@ SAVEHIST=1000
####
#autoload -Uz vcs_info
#precmd_vcs_info() {
# vcs_info
# local STATUS=$(git status --porcelain 2> /dev/null | tail -1)
# if [[ -n $STATUS ]]; then
# zstyle ':vcs_info:git:*' formats '%F{cyan}%b%f %F{yellow}▲%f '
# else
# zstyle ':vcs_info:git:*' formats '%F{cyan}%b%f %F{green}▲%f '
# fi
#}
#precmd_functions+=( precmd_vcs_info )
#
#zstyle ':vcs_info:*' enable git
# prompt
setopt prompt_subst
#get_git_branch() {
# git symbolic-ref --short HEAD 2> /dev/null
#}
#
#get_git_dirty() {
# git status --porcelain 2> /dev/null
#}
#
#git_status=""
#get_git_status() {
# git_status=""
# local BRANCH=$(get_git_branch)
# local STATUS=$(get_git_dirty)
# if [[ -n $BRANCH ]]; then
# if [[ -n $STATUS ]]; then
# git_status="%F{cyan}$BRANCH%f %F{yellow}▲%f "
# else
# git_status="%F{cyan}$BRANCH%f %F{green}▲%f "
# fi
# fi
#}
#
#precmd_functions+=(get_git_status)
git_status=""
git_status_v2() {
git_status=""
@ -67,14 +35,17 @@ git_status_v2() {
fi
if [[ $DIRTY -eq 1 ]]; then
git_status="%F{cyan}$VCS_STATUS_LOCAL_BRANCH%f %F{yellow}▲%f "
git_status="%F{cyan}$VCS_STATUS_LOCAL_BRANCH%f %F{yellow}▲%f "
else
git_status="%F{cyan}$VCS_STATUS_LOCAL_BRANCH%f %F{green}▲%f "
fi
fi
}
precmd_functions+=(git_status_v2)
gitstatus_stop 'PROMPT' && gitstatus_start -s -1 -u -1 -c -1 -d -1 'PROMPT'
if [[ $CONF_ENABLEGIT -eq 1 ]]; then
precmd_functions+=(git_status_v2)
gitstatus_stop 'PROMPT' && gitstatus_start -s -1 -u -1 -c -1 -d -1 'PROMPT'
fi
timer=0
timer_show=0
@ -113,6 +84,7 @@ prompt_time() {
}
precmd_functions+=(prompt_time)
prompt_clock=""
binary_clock() {
local row0=("" "⠈" "⠐" "⠘" "⠠" "⠨" "⠰" "⠸" "⢀" "⢈")
local row1=("⠁" "⠉" "⠑" "⠙" "⠡" "⠩" "⠱" "⠹" "⢁" "⢉")
@ -129,12 +101,29 @@ binary_clock() {
[[ $minute = 0* ]] && minute=${minute:1:1}
[[ $second = 0* ]] && second=${second:1:1}
bclock="${chars[$hour+1]} ${chars[$minute+1]} ${chars[$second+1]}"
prompt_clock="${chars[$hour+1]} ${chars[$minute+1]} ${chars[$second+1]}"
}
precmd_functions+=(binary_clock)
PROMPT=' %(?.%F{magenta}.%F{red})λ%f %1~ $git_status '
RPROMPT='%F{yellow}$timer_display%f %(?..%F{red}%?%f )%F{white}$bclock%f'
normal_clock() {
prompt_clock=$(date +"%H:%M:%S")
}
if [[ $CONF_BINARYCLOCK -eq 1 ]]; then
precmd_functions+=(binary_clock)
else
precmd_functions+=(normal_clock)
fi
ssh_hostname=""
get_is_in_ssh() {
if [[ ! -z $SSH_TTY ]]; then
ssh_hostname="%F{blue}[%m]%f"
fi
}
precmd_functions+=(get_is_in_ssh)
PROMPT='$ssh_hostname %(?.%F{magenta}.%F{red})λ%f %1~ $git_status '
RPROMPT='%F{yellow}$timer_display%f %(?..%F{red}%?%f )%F{white}$prompt_clock%f'
####
@ -175,8 +164,54 @@ alias del='rm'
####
# hast =)
hast() { a=$(cat); curl -X POST -s -d "$a" https://haste.soulja-boy-told.me/documents | awk -F '"' '{print "https://haste.soulja-boy-told.me/"$4}'; }
# functions
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;;
*.tbz2) tar xvjf $1 ;;
*.tgz) tar xvzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*.asar) asar e $1 ${1%.asar} ;;
*) echo "'$1' cannot be extracted via >extract<" ;;
esac
else
echo "'$1' is not a valid file!"
fi
}
remindperms () {
echo " 0 (No read, no write, no execute) ---"
echo " 1 (No read, no write, execute) --x"
echo " 2 (No read, write, no execute) -w-"
echo " 3 (No read, write, execute) -wx"
echo " 4 (Read, no write, no execute) r--"
echo " 5 (Read, no write, execute) r-x"
echo " 6 (Read, write, no execute) rw-"
echo " 7 (Read, write, execute) rwx"
echo ""
echo "(who) u User"
echo "(who) g Group owner"
echo "(who) o Other"
echo "(who) a All (“world”)"
echo ""
echo "(action) + Adding permissions"
echo "(action) - Removing permissions"
echo "(action) = Explicitly set permissions"
echo ""
echo "(permissions) r Read"
echo "(permissions) w Write"
echo "(permissions) x Execute"
echo "(permissions) t Sticky bit"
echo "(permissions) s Set UID or GID"
}
####