From 9b549a09a5e4e95be8c62154f25bd9d16498243d Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Sun, 3 Apr 2016 15:21:55 +0100 Subject: [PATCH] Switch from oh-my-zsh to zplug --- .gitmodules | 3 + shell/_main.sh | 2 +- .../peco-history/peco-history.plugin.zsh | 19 ----- shell/zsh/custom/powerline-arrow.zsh-theme | 50 ----------- shell/zsh/plugins/.gitkeep | 0 .../{custom => themes/plain}/plain.zsh-theme | 6 +- shell/zsh/zplug | 1 + shell/zsh/zplug-cache/.gitignore | 3 + shell/zsh/zplug-cache/.gitkeep | 0 shell/zshrc.sh | 82 ------------------- shell/zshrc.zsh | 65 +++++++++++++++ 11 files changed, 76 insertions(+), 155 deletions(-) delete mode 100644 shell/zsh/custom/plugins/peco-history/peco-history.plugin.zsh delete mode 100644 shell/zsh/custom/powerline-arrow.zsh-theme create mode 100644 shell/zsh/plugins/.gitkeep rename shell/zsh/{custom => themes/plain}/plain.zsh-theme (80%) create mode 160000 shell/zsh/zplug create mode 100644 shell/zsh/zplug-cache/.gitignore create mode 100644 shell/zsh/zplug-cache/.gitkeep delete mode 100644 shell/zshrc.sh create mode 100644 shell/zshrc.zsh diff --git a/.gitmodules b/.gitmodules index 5775b61..8855e9a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -25,3 +25,6 @@ [submodule "shell/enhancd"] path = shell/enhancd url = https://github.com/b4b4r07/enhancd +[submodule "shell/zsh/zplug"] + path = shell/zsh/zplug + url = https://github.com/b4b4r07/zplug diff --git a/shell/_main.sh b/shell/_main.sh index e4ba40a..c63f355 100644 --- a/shell/_main.sh +++ b/shell/_main.sh @@ -15,7 +15,7 @@ path_prepend "/usr/local/bin" if [ -n "$BASH_VERSION" ]; then source "$DOTSHELL/bashrc.sh" elif [ -n "$ZSH_VERSION" ]; then - source "$DOTSHELL/zshrc.sh" + source "$DOTSHELL/zshrc.zsh" fi # Package management diff --git a/shell/zsh/custom/plugins/peco-history/peco-history.plugin.zsh b/shell/zsh/custom/plugins/peco-history/peco-history.plugin.zsh deleted file mode 100644 index 8ed5470..0000000 --- a/shell/zsh/custom/plugins/peco-history/peco-history.plugin.zsh +++ /dev/null @@ -1,19 +0,0 @@ -# History search with peco -# -# Search shell history with peco: https://github.com/peco/peco -# Adapted from: https://github.com/mooz/percol#zsh-history-search -if which peco &> /dev/null; then - function peco_select_history() { - local tac - (which gtac &> /dev/null && tac="gtac") || \ - (which tac &> /dev/null && tac="tac") || \ - tac="tail -r" - BUFFER=$(fc -l -n 1 | eval $tac | \ - peco --layout=bottom-up --query "$LBUFFER") - CURSOR=$#BUFFER # move cursor - zle -R -c # refresh - } - - zle -N peco_select_history - bindkey '^R' peco_select_history -fi diff --git a/shell/zsh/custom/powerline-arrow.zsh-theme b/shell/zsh/custom/powerline-arrow.zsh-theme deleted file mode 100644 index cb0ecd1..0000000 --- a/shell/zsh/custom/powerline-arrow.zsh-theme +++ /dev/null @@ -1,50 +0,0 @@ -# A script to make using 256 colors in zsh less painful. -# P.C. Shyamshankar -# https://github.com/sykora/etc/blob/master/zsh/functions/spectrum/ - -typeset -Ag FX FG BG - -FX=( - reset "" - bold "" no-bold "" - italic "" no-italic "" - underline "" no-underline "" - blink "" no-blink "" - reverse "" no-reverse "" -) - -for color in {000..255}; do - FG[$color]="[38;5;${color}m" - BG[$color]="[48;5;${color}m" -done - - -# -# Powerline-Arrow theme -# - -PROMPT='%n@%m %{$FG[000]%}%{$BG[235]%}⮀%{$reset_color%}%{$BG[235]%} %~ $(check_git_prompt_info)%{$reset_color%} $ ' - -local return_code="%(?..%{$fg[cyan]%}%? ↵%{$reset_color%})" -RPROMPT="${return_code}" - -ZSH_THEME_GIT_PROMPT_PREFIX="%{$FG[236]%}%{$BG[237]%}⮀ %{$FG[014]%}" -ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}%{$FG[238]%}⮀%{$reset_color%}" -ZSH_THEME_GIT_PROMPT_DIRTY="%{$FG[001]%}*%{$reset_color%}" -ZSH_THEME_GIT_PROMPT_CLEAN=" " - - -# Git sometimes goes into a detached head state. git_prompt_info doesn't -# return anything in this case. So wrap it in another function and check -# for an empty string. -- Brorrowed from Soliah.zsh-theme :) -function check_git_prompt_info() { - if git rev-parse --git-dir > /dev/null 2>&1; then - if [[ -z $(git_prompt_info) ]]; then - echo "%{$fg[cyan]%}(detached%{$fg[magenta]%}*%{$fg[cyan]%})%{$reset_color%}" - else - echo "$(git_prompt_info)" - fi - else - echo "%{$reset_color%}%{$FG[236]%}⮀" - fi -} diff --git a/shell/zsh/plugins/.gitkeep b/shell/zsh/plugins/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/shell/zsh/custom/plain.zsh-theme b/shell/zsh/themes/plain/plain.zsh-theme similarity index 80% rename from shell/zsh/custom/plain.zsh-theme rename to shell/zsh/themes/plain/plain.zsh-theme index 52c4de3..6af001e 100644 --- a/shell/zsh/custom/plain.zsh-theme +++ b/shell/zsh/themes/plain/plain.zsh-theme @@ -3,7 +3,7 @@ PROMPT='%n@%m %~$(check_git_prompt_info)$ %{$reset_color%}' local return_code="%(?..%{$fg[cyan]%}%? ↵%{$reset_color%})" RPROMPT="${return_code}" -ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[cyan]%}(" +ZSH_THEME_GIT_PROMPT_PREFIX=" %{$fg[cyan]%}(" ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}*%{$fg[cyan]%})%{$reset_color%}" ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[cyan]%})%{$fg[blue]%}" @@ -15,9 +15,9 @@ ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[cyan]%})%{$fg[blue]%}" function check_git_prompt_info() { if git rev-parse --git-dir > /dev/null 2>&1; then if [[ -z $(git_prompt_info) ]]; then - echo " %{$fg[cyan]%}(detached%{$fg[magenta]%}*%{$fg[cyan]%})%{$reset_color%}" + echo "%{$fg[cyan]%}(detached%{$fg[magenta]%}*%{$fg[cyan]%})%{$reset_color%}" else - echo " $(git_prompt_info)" + echo "$(git_prompt_info)" fi fi } diff --git a/shell/zsh/zplug b/shell/zsh/zplug new file mode 160000 index 0000000..78cfe44 --- /dev/null +++ b/shell/zsh/zplug @@ -0,0 +1 @@ +Subproject commit 78cfe440ec6018e9d9d02cbfe6f14d6784c32c84 diff --git a/shell/zsh/zplug-cache/.gitignore b/shell/zsh/zplug-cache/.gitignore new file mode 100644 index 0000000..4fab89b --- /dev/null +++ b/shell/zsh/zplug-cache/.gitignore @@ -0,0 +1,3 @@ +.cache +repos/* +zcompdump diff --git a/shell/zsh/zplug-cache/.gitkeep b/shell/zsh/zplug-cache/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/shell/zshrc.sh b/shell/zshrc.sh deleted file mode 100644 index 3b55ffc..0000000 --- a/shell/zshrc.sh +++ /dev/null @@ -1,82 +0,0 @@ -# -# Z-Shell Init -# - -# Export path variables -DOTZSH="$DOTSHELL/zsh" - -# Path to your oh-my-zsh configuration. -ZSH="$DOTZSH/oh-my-zsh" - -# Customize oh-my-zsh's custom path. -ZSH_CUSTOM="$DOTZSH/custom" - -# Set name of the theme to load. -# Look in ~/.oh-my-zsh/themes/ -# Optionally, if you set this to "random", it'll load a random theme each -# time that oh-my-zsh is loaded. -ZSH_THEME="plain" - -# Set to this to use case-sensitive completion -# CASE_SENSITIVE="true" - -# Comment this out to disable weekly auto-update checks -DISABLE_AUTO_UPDATE="true" - -# Uncomment following line if you want to disable colors in ls -# DISABLE_LS_COLORS="true" - -# Uncomment following line if you want to disable autosetting terminal title. -DISABLE_AUTO_TITLE="true" - -# Uncomment following line if you want red dots to be displayed while waiting for completion -# COMPLETION_WAITING_DOTS="true" - -# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*) -# Example format: plugins=(rails git textmate ruby lighthouse) -plugins=( \ - brew \ - bundler \ - cake \ - cap \ - gem \ - heroku \ - node \ - nyan \ - osx \ - peco-history \ - powder \ - python \ - ruby \ - thor \ - vagrant \ - zsh-autosuggestions \ - zsh-syntax-highlighting \ -) - -source "$ZSH/oh-my-zsh.sh" - -# Customize to your needs... - -# Enable bash-style completion -autoload -U bashcompinit -bashcompinit - -# Disable shared history -unsetopt share_history - -# Disable attempted correction of commands (is wrong 98% of the time). -unsetopt correctall - -# Disable certain bundled ruby binaries, I install the gems globally. -unalias shotgun - -# Cause I hit emacs shorts too much -bindkey -s "\C-x\C-f" "cd " - -# Configure zsh-syntax-highlighting -ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets) - -# use ctrl+t to toggle autosuggestions(hopefully this wont be needed as -# zsh-autosuggestions is designed to be unobtrusive) -bindkey '^T' autosuggest-toggle diff --git a/shell/zshrc.zsh b/shell/zshrc.zsh new file mode 100644 index 0000000..fde285f --- /dev/null +++ b/shell/zshrc.zsh @@ -0,0 +1,65 @@ +# +# Z-Shell Init +# + +# Basic stuff. +DISABLE_AUTO_TITLE="true" + +# Export path variables. +DOTZSH="$DOTSHELL/zsh" +ZPLUG_HOME="$DOTZSH/zplug-cache" + +# Don't wrap these commands in a Bundler wrapper. +UNBUNDLED_COMMANDS=(shotgun) + +# Enable bash-style completion. +autoload -U bashcompinit +bashcompinit + +# Disable shared history. +unsetopt share_history + +# Disable attempted correction of commands (is wrong 98% of the time). +unsetopt correctall + +# Cause I hit emacs shorts too much. +bindkey -s "\C-x\C-f" "cd " + +# use ctrl+t to toggle autosuggestions(hopefully this wont be needed as +# zsh-autosuggestions is designed to be unobtrusive). +bindkey '^T' autosuggest-toggle + +# +# zplug +# + +source "$DOTZSH/zplug/zplug" +alias zp="zplug" + +zplug "plugins/brew", from:oh-my-zsh +zplug "plugins/bundler", from:oh-my-zsh +zplug "plugins/git", from:oh-my-zsh +zplug "plugins/powder", from:oh-my-zsh + +zplug "$DOTZSH/themes/plain", from:local + +zplug "jimeh/zsh-peco-history" +zplug "zsh-users/zsh-completions" +zplug "zsh-users/zsh-autosuggestions" +zplug "zsh-users/zsh-syntax-highlighting", nice:19 + +# Install plugins if there are plugins that have not been installed +if ! zplug check --verbose; then + printf "Install? [y/N]: " + if read -q; then + echo + zplug install + fi +fi + +zplug load + +# Configure zsh-syntax-highlighting +if zplug check zsh-users/zsh-syntax-highlighting; then + export ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets) +fi