diff --git a/zsh/.bash-powerline.sh b/zsh/.bash-powerline.sh deleted file mode 100644 index 81593f7..0000000 --- a/zsh/.bash-powerline.sh +++ /dev/null @@ -1,110 +0,0 @@ -#!/usr/bin/env bash - -__powerline() { - - # Unicode symbols - PS_SYMBOL_DARWIN='>' - PS_SYMBOL_LINUX='$' - PS_SYMBOL_OTHER='%' - GIT_BRANCH_SYMBOL=' ' - GIT_BRANCH_CHANGED_SYMBOL='+' - GIT_NEED_PUSH_SYMBOL='⇡' - GIT_NEED_PULL_SYMBOL='⇣' - - # Solarized colorscheme - FG_BASE03="\[$(tput setaf 8)\]" - FG_BASE02="\[$(tput setaf 0)\]" - FG_BASE01="\[$(tput setaf 10)\]" - FG_BASE00="\[$(tput setaf 11)\]" - FG_BASE0="\[$(tput setaf 12)\]" - FG_BASE1="\[$(tput setaf 14)\]" - FG_BASE2="\[$(tput setaf 7)\]" - FG_BASE3="\[$(tput setaf 15)\]" - - BG_BASE03="\[$(tput setab 8)\]" - BG_BASE02="\[$(tput setab 0)\]" - BG_BASE01="\[$(tput setab 10)\]" - BG_BASE00="\[$(tput setab 11)\]" - BG_BASE0="\[$(tput setab 12)\]" - BG_BASE1="\[$(tput setab 14)\]" - BG_BASE2="\[$(tput setab 8)\]" - BG_BASE3="\[$(tput setab 15)\]" - - FG_YELLOW="\[$(tput setaf 3)\]" - FG_ORANGE="\[$(tput setaf 9)\]" - FG_RED="\[$(tput setaf 1)\]" - FG_MAGENTA="\[$(tput setaf 5)\]" - FG_VIOLET="\[$(tput setaf 13)\]" - FG_BLUE="\[$(tput setaf 4)\]" - FG_CYAN="\[$(tput setaf 6)\]" - FG_GREEN="\[$(tput setaf 2)\]" - - BG_YELLOW="\[$(tput setab 3)\]" - BG_ORANGE="\[$(tput setab 9)\]" - BG_RED="\[$(tput setab 1)\]" - BG_MAGENTA="\[$(tput setab 5)\]" - BG_VIOLET="\[$(tput setab 13)\]" - BG_BLUE="\[$(tput setab 4)\]" - BG_CYAN="\[$(tput setab 6)\]" - BG_GREEN="\[$(tput setab 2)\]" - - DIM="\[$(tput dim)\]" - REVERSE="\[$(tput rev)\]" - RESET="\[$(tput sgr0)\]" - BOLD="\[$(tput bold)\]" - - # what OS? - case "$(uname)" in - Darwin) - PS_SYMBOL=$PS_SYMBOL_DARWIN - ;; - Linux) - PS_SYMBOL=$PS_SYMBOL_LINUX - ;; - *) - PS_SYMBOL=$PS_SYMBOL_OTHER - esac - - __git_info() { - [ -x "$(which git)" ] || return # git not found - - local git_eng="env LANG=C git" # force git output in English to make our work easier - # get current branch name or short SHA1 hash for detached head - local branch="$($git_eng symbolic-ref --short HEAD 2>/dev/null || $git_eng describe --tags --always 2>/dev/null)" - [ -n "$branch" ] || return # git branch not found - - local marks - - # branch is modified? - [ -n "$($git_eng status --porcelain)" ] && marks+=" $GIT_BRANCH_CHANGED_SYMBOL" - - # how many commits local branch is ahead/behind of remote? - local stat="$($git_eng status --porcelain --branch | grep '^##' | grep -o '\[.\+\]$')" - local aheadN="$(echo $stat | grep -o 'ahead [[:digit:]]\+' | grep -o '[[:digit:]]\+')" - local behindN="$(echo $stat | grep -o 'behind [[:digit:]]\+' | grep -o '[[:digit:]]\+')" - [ -n "$aheadN" ] && marks+=" $GIT_NEED_PUSH_SYMBOL$aheadN" - [ -n "$behindN" ] && marks+=" $GIT_NEED_PULL_SYMBOL$behindN" - - # print the git branch segment without a trailing newline - printf " $GIT_BRANCH_SYMBOL$branch$marks " - } - - ps1() { - # Check the exit code of the previous command and display different - # colors in the prompt accordingly. - if [ $? -eq 0 ]; then - local BG_EXIT="$BG_VIOLET" - else - local BG_EXIT="$BG_RED" - fi - - PS1="$BG_BASE2$FG_BASE3 \w $RESET" - PS1+="$BG_BLUE$FG_BASE3$(__git_info)$RESET" - PS1+="$BG_EXIT$FG_BASE3 $PS_SYMBOL $RESET " - } - - PROMPT_COMMAND=ps1 -} - -__powerline -unset __powerline diff --git a/zsh/.oh-my-zsh b/zsh/.oh-my-zsh deleted file mode 160000 index 835a0a5..0000000 --- a/zsh/.oh-my-zsh +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 835a0a5d17765243cabee782acb5905a9aab33c3 diff --git a/zsh/.zshrc b/zsh/.zshrc index 63b5b13..de481dd 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -5,6 +5,9 @@ else curl -sL --proto-redir -all,https https://raw.githubusercontent.com/zplug/installer/master/installer.zsh | zsh fi +zplug "lib/completion", from:oh-my-zsh +zplug "plugins/git", from:oh-my-zsh + zplug "zsh-users/zsh-syntax-highlighting", defer:2 zplug "mafredri/zsh-async", from:"github", use:"async.zsh" zplug "zsh-users/zsh-autosuggestions" @@ -17,11 +20,8 @@ zplug load # Initialization code that may require console input (password prompts, [y/n] # confirmations, etc.) must go above this block; everything else may go below. if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then - source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" + source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" fi -# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh. -# [[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh -# plugins=(zsh-autosuggestions zsh-syntax-highlighting) ZSH_THEME=powerlevel10k/powerlevel10k DISABLE_AUTO_TITLE=true @@ -38,7 +38,7 @@ fi export EDITOR='nvim' zle -N fancy-ctrl-z bindkey '^Z' fancy-ctrl-z -bindkey '^R' fzf-histor-widget +bindkey '^R' fzf-history-widget bindkey "^A" beginning-of-line bindkey "^E" end-of-line bindkey "^K" kill-line @@ -58,151 +58,23 @@ emulate -L zsh typeset -Ag color colour -color=( -# Codes listed in this array are from ECMA-48, Section 8.3.117, p. 61. -# Those that are commented out are not widely supported or aren't closely -# enough related to color manipulation, but are included for completeness. - -# Attribute codes: - 00 none # 20 gothic - 01 bold # 21 double-underline - 02 faint 22 normal - 03 italic 23 no-italic # no-gothic - 04 underline 24 no-underline - 05 blink 25 no-blink -# 06 fast-blink # 26 proportional - 07 reverse 27 no-reverse -# 07 standout 27 no-standout - 08 conceal 28 no-conceal -# 09 strikethrough # 29 no-strikethrough - -# Font selection: -# 10 font-default -# 11 font-first -# 12 font-second -# 13 font-third -# 14 font-fourth -# 15 font-fifth -# 16 font-sixth -# 17 font-seventh -# 18 font-eighth -# 19 font-ninth - -# Text color codes: - 30 black 40 bg-black - 31 red 41 bg-red - 32 green 42 bg-green - 33 yellow 43 bg-yellow - 34 blue 44 bg-blue - 35 magenta 45 bg-magenta - 36 cyan 46 bg-cyan - 37 white 47 bg-white -# 38 iso-8316-6 # 48 bg-iso-8316-6 - 39 default 49 bg-default - -# Other codes: -# 50 no-proportional -# 51 border-rectangle -# 52 border-circle -# 53 overline -# 54 no-border -# 55 no-overline -# 56 through 59 reserved - -# Ideogram markings: -# 60 underline-or-right -# 61 double-underline-or-right -# 62 overline-or-left -# 63 double-overline-or-left -# 64 stress -# 65 no-ideogram-marking - -# Bright color codes (xterm extension) - 90 bright-gray 100 bg-bright-gray - 91 bright-red 101 bg-bright-red - 92 bright-green 102 bg-bright-green - 93 bright-yellow 103 bg-bright-yellow - 94 bright-blue 104 bg-bright-blue - 95 bright-magenta 105 bg-bright-magenta - 96 bright-cyan 106 bg-bright-cyan - 97 bright-white 107 bg-bright-white -) - -# A word about black and white: The "normal" shade of white is really a -# very pale grey on many terminals; to get truly white text, you have to -# use bold white, and to get a truly white background you have to use -# bold reverse white bg-xxx where xxx is your desired foreground color -# (and which means the foreground is also bold). - -# Map in both directions; could do this with e.g. ${(k)colors[(i)normal]}, -# but it's clearer to include them all both ways. - -local k -for k in ${(k)color}; do color[${color[$k]}]=$k; done - -# Add "fg-" keys for all the text colors, for clarity. - -for k in ${color[(I)[39]?]}; do color[fg-${color[$k]}]=$k; done - -# This is inaccurate, but the prompt theme system needs it. - -for k in grey gray; do - color[$k]=${color[black]} - color[fg-$k]=${color[$k]} - color[bg-$k]=${color[bg-black]} -done - -# Assistance for the colo(u)r-blind. - -for k in '' fg- bg-; do - color[${k}bright-grey]=${color[${k}bright-gray]} -done - -colour=(${(kv)color}) # A case where ksh namerefs would be useful ... - -# The following are terminal escape sequences used by colored prompt themes. - -local lc=$'\e[' rc=m # Standard ANSI terminal escape values - -typeset -Hg reset_color bold_color -reset_color="$lc${color[none]}$rc" -bold_color="$lc${color[bold]}$rc" - -# Foreground - -typeset -AHg fg fg_bold fg_no_bold -for k in ${(k)color[(I)fg-*]}; do - fg[${k#fg-}]="$lc${color[$k]}$rc" - fg_bold[${k#fg-}]="$lc${color[bold]};${color[$k]}$rc" - fg_no_bold[${k#fg-}]="$lc${color[normal]};${color[$k]}$rc" -done - -# Background - -typeset -AHg bg bg_bold bg_no_bold -for k in ${(k)color[(I)bg-*]}; do - bg[${k#bg-}]="$lc${color[$k]}$rc" - bg_bold[${k#bg-}]="$lc${color[bold]};${color[$k]}$rc" - bg_no_bold[${k#bg-}]="$lc${color[normal]};${color[$k]}$rc" -done - prompt_google3() { - if [[ $PWD =~ '/google/src/cloud/[^/]+/(.+)/google3(.*)' ]]; then - GPROMPT=$(print -r -- "//${match[2]#/}") - else - GPROMPT=$(print -r -- "$PWD") - fi - p10k segment -b '#afafff' -f '#fff' -t $GPROMPT + if [[ $PWD =~ '/google/src/cloud/[^/]+/(.+)/google3(.*)' ]]; then + GPROMPT=$(print -r -- "//${match[2]#/}") + else + GPROMPT=$(print -r -- "$PWD") + fi + p10k segment -b '#afafff' -f '#fff' -t $GPROMPT } prompt_workspace() { - if [[ $PWD =~ '/google/src/cloud/[^/]+/(.+)/google3(.*)' ]]; then - # Use CitC client names as window titles in screen/tmux - print -n "\e]2;${match[1]}\a" >/dev/tty + if [[ $PWD =~ '/google/src/cloud/[^/]+/(.+)/google3(.*)' ]]; then + # Use CitC client names as window titles in screen/tmux + print -n "\e]2;${match[1]}\a" >/dev/tty - GPROMPT=$(print -r -- "$match[1]") - p10k segment -b 104 -f white -t $GPROMPT - fi + GPROMPT=$(print -r -- "$match[1]") + p10k segment -b 44 -f white -t $GPROMPT + fi } POWERLEVEL9K_CUSTOM_FIG='get_fig_prompt' @@ -211,47 +83,16 @@ POWERLEVEL9K_CUSTOM_FIG_BACKGROUND="237" POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(status workspace google3 dir_writable vcs custom_fig) POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(host command_execution_time) -POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=1 - -# typeset POWERLEVEL9K_{LEFT,RIGHT}_SUBSEGMENT_SEPARATOR='%F{232}\uE0BD' -typeset POWERLEVEL9K_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL='▓▒░' -typeset POWERLEVEL9K_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL='░▒▓' - -# color customization - -POWERLEVEL9K_COMMAND_EXECUTION_TIME_BACKGROUND='216' -POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND='black' - -POWERLEVEL9K_DIR_DEFAULT_BACKGROUND='grey' -POWERLEVEL9K_DIR_DEFAULT_FOREGROUND='skyblue' -POWERLEVEL9K_DIR_ETC_BACKGROUND='grey' -POWERLEVEL9K_DIR_ETC_FOREGROUND='skyblue' -POWERLEVEL9K_DIR_HOME_SUBFOLDER_BACKGROUND='grey' -POWERLEVEL9K_DIR_HOME_SUBFOLDER_FOREGROUND='grey89' - -POWERLEVEL9K_VCS_CLEAN_BACKGROUND='blue' -POWERLEVEL9K_VCS_CLEAN_FOREGROUND='white' -POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND='yellow' -POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND='black' -POWERLEVEL9K_VCS_MODIFIED_BACKGROUND='yellow' -POWERLEVEL9K_VCS_MODIFIED_FOREGROUND='black' - -POWERLEVEL9K_STATUS_ERROR_BACKGROUND='red' -POWERLEVEL9K_STATUS_ERROR_FOREGROUND='white' - -POWERLEVEL9K_SHORTEN_DIR_LENGTH=1 -POWERLEVEL9K_SHORTEN_DELIMITER="" -POWERLEVEL9K_SHORTEN_STRATEGY="truncate_to_unique" -# ### Fix slowness of pastes with zsh-syntax-highlighting.zsh pasteinit() { - OLD_SELF_INSERT=${${(s.:.)widgets[self-insert]}[2,3]} - zle -N self-insert url-quote-magic # I wonder if you'd need `.url-quote-magic`? + OLD_SELF_INSERT=${${(s.:.)widgets[self-insert]}[2,3]} + zle -N self-insert url-quote-magic # I wonder if you'd need `.url-quote-magic`? } pastefinish() { - zle -N self-insert $OLD_SELF_INSERT + zle -N self-insert $OLD_SELF_INSERT } + zstyle :bracketed-paste-magic paste-init pasteinit zstyle :bracketed-paste-magic paste-finish pastefinish ### Fix slowness of pastes @@ -260,18 +101,9 @@ zstyle :bracketed-paste-magic paste-finish pastefinish autoload -Uz add-zsh-hook [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh -export ZSH="$HOME/.oh-my-zsh" -source $ZSH/oh-my-zsh.sh source ~/.bash_profile -alias luamake=/luamake -export PATH="/opt/homebrew/opt/openjdk/bin:$PATH" export PATH="$HOME/.local/bin:$PATH" - -export NVM_DIR="$HOME/.nvm" -[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm -[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion - # Setup go/hi #!>>HI<>HI<