Major rewrite

This commit is contained in:
Mark Vainomaa 2018-02-03 02:29:33 +02:00
parent e18877b394
commit c5820947f5
Signed by: mikroskeem
GPG Key ID: 1B3F9523B542D315
26 changed files with 456 additions and 193 deletions

2
.gitignore vendored
View File

@ -1 +1,3 @@
*~
.*
zplug/

View File

@ -4,5 +4,5 @@ Pronounced as '/ʃ/uper'
This is my simple zsh config
## Installation
`git clone --depth=1 https://git.wut.ee/mikroskeem/zshuper ~/.config/zshuper && echo "source ~/.config/zshuper/main.zsh" > ~/.zshrc`
`git clone --depth=1 https://git.wut.ee/mikroskeem/zshuper ~/.config/zshuper && echo "source ~/.config/zshuper/init.zsh" > ~/.zshrc`

View File

@ -1,8 +1,6 @@
# zshuper default configuration
# Runtime-critical configurations
#
# zshuper runtime-critical configurations
#
# zplug home
ZPLUG_HOME=~/.config/zshuper/zplug
# Shall we use grml PS1? Useful only when there are no prompt plugins
USE_GRML_PS1=no
# Which plugin manager to use? Choices: antibody, zplug
ZSHUPER_PLUGIN_MANAGER=zplug

View File

@ -1,18 +0,0 @@
# ls colors and aliases
[ ! "$(uname -s)" = "Linux" ] && return;
export LS_COLORS="rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:"
alias ls="ls --color"
alias l="ls -l"
alias lah="ls -lah"
alias ldot="ls -d .*"
# Make rm, mv and cp recursive and verbose
alias rm="rm -rfv"
alias mv="mv -v"
alias cp="cp -rv"
# Other aliases
alias grep="grep --color"
alias mkdir="mkdir -p"
alias dmesg="dmesg -L"
alias ip="ip -c"

View File

@ -1,5 +0,0 @@
setopt correct
zstyle ':completion:*:correct:*' insert-unambiguous true
zstyle ':completion:*:corrections' format $'%{\e[0;31m%}%d (errors: %e)%{\e[0m%}'
zstyle ':completion:*:correct:*' original true
zstyle ':completion:correct:' prompt 'correct to: %e'

View File

@ -1,7 +0,0 @@
hosts=(
$(
([ -r .ssh/known_hosts ] && awk '{print $1}' .ssh/known_hosts | tr , '\n') | sort -u
)
)
zstyle ':completion:*' hosts $hosts

View File

@ -1,23 +0,0 @@
# Part of this is from http://unix.stackexchange.com/q/62919
# Fixes my navigation keys
typeset -A key
key[Home]=${terminfo[khome]}
key[End]=${terminfo[kend]}
key[Insert]=${terminfo[kich1]}
key[Delete]=${terminfo[kdch1]}
key[Up]=${terminfo[kcuu1]}
key[Down]=${terminfo[kcud1]}
key[Left]=${terminfo[kcub1]}
key[Right]=${terminfo[kcuf1]}
key[PageUp]=${terminfo[kpp]}
key[PageDown]=${terminfo[knp]}
[[ -n "${key[Home]}" ]] && bindkey "${key[Home]}" beginning-of-line
[[ -n "${key[End]}" ]] && bindkey "${key[End]}" end-of-line
[[ -n "${key[Insert]}" ]] && bindkey "${key[Insert]}" overwrite-mode
[[ -n "${key[Delete]}" ]] && bindkey "${key[Delete]}" delete-char
[[ -n "${key[Up]}" ]] && bindkey "${key[Up]}" up-line-or-history
[[ -n "${key[Down]}" ]] && bindkey "${key[Down]}" down-line-or-history
[[ -n "${key[Left]}" ]] && bindkey "${key[Left]}" backward-char
[[ -n "${key[Right]}" ]] && bindkey "${key[Right]}" forward-char
[[ -n "${key[PageUp]}" ]] && bindkey "${key[PageUp]}" beginning-of-buffer-or-history
[[ -n "${key[PageDown]}" ]] && bindkey "${key[PageDown]}" end-of-buffer-or-history

View File

@ -1,9 +0,0 @@
# Create quick scratch directory for testing and other stuff
function new-scratch {
local cur_dir="$HOME/scratch"
local new_dir="$HOME/tmp/scratch_$(date --iso-8601=seconds)"
mkdir -p $new_dir
ln -nfs $new_dir $cur_dir
cd $cur_dir
printf "New scratch dir ready for grinding ;>\n\n"
}

View File

@ -1,12 +0,0 @@
# Use ZAW search
# First check if ZAW is installed and sourced
zplug info zsh-users/zaw >|/dev/null || return
bindkey '^R' zaw-history
bindkey -M filterselect '^R' down-line-or-history
bindkey -M filterselect '^S' up-line-or-history
bindkey -M filterselect '^E' accept-search
zstyle ':filter-select:highlight' matched fg=red
zstyle ':filter-select' max-lines 5
zstyle ':filter-select' extended-search yes

15
functions/utils.zsh Normal file
View File

@ -0,0 +1,15 @@
#
# Utilities
#
# Returns whether command exists or not
function __zspr_has_command {
command -v "${1}" >/dev/null
return $?
}
# Creates directory relative to home directory
function __zspr_mkdir {
local HOMEDIR="${HOME}"
mkdir -p "${HOMEDIR}/${1}"
}

63
init.zsh Normal file
View File

@ -0,0 +1,63 @@
#
# zshuper - pronounced as '/ʃ/uper'
#
# Edit config.zsh to configure zshuper
# Source this script like:
# % source "${ZSHUPER_DIR}/"init.zsh
#
ZSHUPER_DIR="$(dirname "${_}")"
# PATH
export PATH="${PATH}:${HOME}/.local/share/bin:${HOME}/bin"
# Functions
source "${ZSHUPER_DIR}/functions/utils.zsh"
# Load config
source "${ZSHUPER_DIR}/config.zsh"
# Set up directories
source "${ZSHUPER_DIR}/modules/directories.zsh"
# Setup plugin manager
source "${ZSHUPER_DIR}/modules/pluginmanager.zsh"
case "${ZSHUPER_PLUGIN_MANAGER}" in;
"antibody")
source "${ZSHUPER_DIR}/modules/pluginmanager/antibody.zsh"
;;
"zplug")
source "${ZSHUPER_DIR}/modules/pluginmanager/zplug.zsh"
;;
*)
echo "Unknown plugin manager: '${ZSHUPER_PLUGIN_MANAGER}', plugins will not enable!"
esac
__zspr_plm_init
# Include own plugins
source "${ZSHUPER_DIR}/plugins.zsh"
# Load plugins
__zspr_plm_load_plugins
# Enable comments in interactive shell
setopt interactivecomments
# Show program exit code and don't check for jobs on exit
setopt printexitvalue
setopt nocheckjobs
# zshuper modules
source "${ZSHUPER_DIR}/modules/aliases.zsh"
source "${ZSHUPER_DIR}/modules/compinit.zsh"
source "${ZSHUPER_DIR}/modules/directories.zsh"
source "${ZSHUPER_DIR}/modules/editor.zsh"
source "${ZSHUPER_DIR}/modules/history.zsh"
source "${ZSHUPER_DIR}/modules/keys.zsh"
source "${ZSHUPER_DIR}/modules/new-scratch.zsh"
source "${ZSHUPER_DIR}/modules/pacman.zsh"
source "${ZSHUPER_DIR}/modules/rationalize-dot.zsh"
source "${ZSHUPER_DIR}/modules/new-scratch.zsh"
source "${ZSHUPER_DIR}/modules/use-zaw-search.zsh"

100
main.zsh
View File

@ -1,100 +0,0 @@
# zshuper - pronounced as '/ʃ/uper'
#
# Edit config.zsh to configure zshuper
# Source this script like:
# % source ~/.config/zshuper/main.zsh
#
# Load config
source ~/.config/zshuper/config.zsh
# ---------------------------------
# 3rd party plugins
# Check if zplug is installed
if [ ! -d "${ZPLUG_HOME}" ]; then
echo ">>> Installing zplug"
git clone --depth=1 https://github.com/zplug/zplug ${ZPLUG_HOME}
fi
# Include zplug
source ${ZPLUG_HOME}/init.zsh
# Let zplug manage itself
zplug "zplug/zplug"
# Include own plugins
source ~/.config/zshuper/plugins.zsh
# And include highlighting at the end
# https://github.com/zsh-users/zsh-syntax-highlighting#faq
zplug "zsh-users/zsh-syntax-highlighting", defer:2
# Install and load plugins
if ! zplug check; then
zplug install
fi
zplug load
# ---------------------------------
# zshuper specific configuration
# Set up sane defaults and useful functions
# Use grml PS1 (if enabled)
# https://grml.org/zsh/
if [ "${USE_GRML_PS1}" = "yes" ]; then
PS1="%B%F{red}%(?..%? )%f%b%B%F{blue}%n%f%b@%m %B%40<..<%~%<< %b%# "
fi
# Default editor and pager
# cool people use neovim :>
export EDITOR=$(if [ ! -z "$(command -v nvim)" ]; then echo "nvim"; else echo "vim"; fi)
export VISUAL=${EDITOR}
export PAGER=less
export MANPAGER=less
# less options
export LESS="-r"
# History control
setopt histignorealldups
setopt extended_history
setopt append_history
setopt histignorespace
unsetopt share_history
setopt histallowclobber
setopt INC_APPEND_HISTORY_TIME
HISTSIZE=100000
SAVEHIST=100000
HISTFILE=~/.zsh_history
# PATH
export PATH=${PATH}:~/bin
# Enable comments in interactive shell
setopt interactivecomments
# Show program exit code and don't check for jobs on exit
setopt printexitvalue
setopt nocheckjobs
# Set up autocompletion and correction
autoload -U compinit && compinit
setopt menu_complete
zstyle ':completion:*' menu select
zstyle ':completion:*:warnings' format 'Nuffin there :('
zstyle ':completion:*' expand prefix suffix
zstyle ':completion:*' completer _expand_alias _complete _approximate
zstyle ':completion:*:approximate:*' max-errors 4
zstyle ':completion:*' special-dirs true
# zshuper functions
source ~/.config/zshuper/functions/aliases.zsh
source ~/.config/zshuper/functions/keys.zsh
source ~/.config/zshuper/functions/new-scratch.zsh
source ~/.config/zshuper/functions/rationalise-dot.zsh
source ~/.config/zshuper/functions/use-zaw-search.zsh
source ~/.config/zshuper/functions/correct.zsh
source ~/.config/zshuper/functions/pacman.zsh
source ~/.config/zshuper/functions/hosts-completion.zsh

30
modules/aliases.zsh Normal file
View File

@ -0,0 +1,30 @@
# ls colors and aliases
if ! __zspr_has_command "exa"; then
alias ls="ls --color"
export LS_COLORS="rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:"
else
alias ls="exa"
fi
alias l="ls -l"
alias lah="ls -lah"
alias ldot="ls -d .*"
# Make rm, mv and cp recursive and verbose
alias rm="rm -rfv"
alias mv="mv -v"
alias cp="cp -rv"
# git
alias gd='git diff'
alias gco='git checkout'
alias gs='git status'
alias gl='git pull'
alias gp='git push'
alias gwc='git whatchanged -p --abbrev-commit --pretty=medium'
# Other aliases
alias grep="grep --color"
alias mkdir="mkdir -p"
alias dmesg="dmesg -L"
alias ip="ip -c"
alias diff="diff --color"

59
modules/compinit.zsh Normal file
View File

@ -0,0 +1,59 @@
#
# Autocompletions
#
# Also see https://gist.github.com/ctechols/ca1035271ad134841284
autoload -Uz compinit
if [[ -n ${HOME}/.zcompdump(#qN.mh+24) ]]; then
compinit;
else
compinit -C;
fi;
# Make it case insensitive
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
# Completion menu
setopt menu_complete
zstyle ':completion:*' menu select
zstyle ':completion:*:warnings' format 'Nuffin there :('
zstyle ':completion:*' expand prefix suffix
zstyle ':completion:*' completer _expand_alias _complete _approximate
zstyle ':completion:*:approximate:*' max-errors 4
zstyle ':completion:*' special-dirs true
# Completion correction
setopt correct
zstyle ':completion:*:correct:*' insert-unambiguous true
zstyle ':completion:*:corrections' format $'%{\e[0;31m%}%d (errors: %e)%{\e[0m%}'
zstyle ':completion:*:correct:*' original true
zstyle ':completion:correct:' prompt 'correct to: %e'
# Completion cache
zstyle ':completion::complete:*' use-cache 1
zstyle ':completion::complete:*' cache-path "${ZSHUPER_DIR}/.cache/completion"
# Username completion
ignored_users=(
$(cat /etc/passwd | cut -d':' -f1,6 | sed 's/:/ /g' | awk '$2 !~ /^ *\/home/ {print $1}')
)
zstyle ':completion:*:*:*:users' ignored-patterns $ignored_users
# Process killing
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
zstyle ':completion:*:*:*:*:processes' command "ps -u $(whoami) -o pid,user,comm -w -w"
# Hostname completions
[ -r ~/.ssh/known_hosts ] && _ssh_known_hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _ssh_known_hosts=()
[ -r ~/.ssh/config ] && _ssh_hosts=($(cat ~/.ssh/config | sed -ne 's/Host[=\t ]//p')) || _ssh_hosts=()
[ -r /etc/hosts ] && : ${(A)_etc_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}} || _etc_hosts=()
hosts=(
"${_ssh_known_hosts[@]}"
"${_ssh_hosts[@]}"
"$_etc_hosts[@]"
localhost
)
zstyle ':completion:*' hosts $hosts

8
modules/directories.zsh Normal file
View File

@ -0,0 +1,8 @@
#
# Directories setup
#
# Directories to create
__zspr_mkdir bin/
__zspr_mkdir .local/share/bin/
__zspr_mkdir tmp/

12
modules/editor.zsh Normal file
View File

@ -0,0 +1,12 @@
#
# Default editor and pager
#
# cool people use neovim :>
export EDITOR=$(if __zspr_has_command nvim; then echo -n "nvim"; else echo -n "vim"; fi)
export VISUAL="${EDITOR}"
export PAGER=less
export MANPAGER=less
# less options
export LESS="-r"

14
modules/history.zsh Normal file
View File

@ -0,0 +1,14 @@
#
# History control
#
setopt histignorealldups
setopt extended_history
setopt append_history
setopt histignorespace
unsetopt share_history
setopt histallowclobber
setopt INC_APPEND_HISTORY_TIME
HISTSIZE=100000
SAVEHIST=100000
HISTFILE=~/.zsh_history

23
modules/keys.zsh Normal file
View File

@ -0,0 +1,23 @@
# Part of this is from http://unix.stackexchange.com/q/62919
# Fixes my navigation keys
#typeset -A key
#key[Home]=${terminfo[khome]}
#key[End]=${terminfo[kend]}
#key[Insert]=${terminfo[kich1]}
#key[Delete]=${terminfo[kdch1]}
#key[Up]=${terminfo[kcuu1]}
#key[Down]=${terminfo[kcud1]}
#key[Left]=${terminfo[kcub1]}
#key[Right]=${terminfo[kcuf1]}
#key[PageUp]=${terminfo[kpp]}
#key[PageDown]=${terminfo[knp]}
#[[ -n "${key[Home]}" ]] && bindkey "${key[Home]}" beginning-of-line
#[[ -n "${key[End]}" ]] && bindkey "${key[End]}" end-of-line
#[[ -n "${key[Insert]}" ]] && bindkey "${key[Insert]}" overwrite-mode
#[[ -n "${key[Delete]}" ]] && bindkey "${key[Delete]}" delete-char
#[[ -n "${key[Up]}" ]] && bindkey "${key[Up]}" up-line-or-history
#[[ -n "${key[Down]}" ]] && bindkey "${key[Down]}" down-line-or-history
#[[ -n "${key[Left]}" ]] && bindkey "${key[Left]}" backward-char
#[[ -n "${key[Right]}" ]] && bindkey "${key[Right]}" forward-char
#[[ -n "${key[PageUp]}" ]] && bindkey "${key[PageUp]}" beginning-of-buffer-or-history
#[[ -n "${key[PageDown]}" ]] && bindkey "${key[PageDown]}" end-of-buffer-or-history

15
modules/new-scratch.zsh Normal file
View File

@ -0,0 +1,15 @@
#
# Quick scratch directory creator
#
# Create quick scratch directory for testing and other stuff
function new-scratch {
local SCRATCH="${HOME}/scratch"
local NEW_SCRATCH="${HOME}/tmp/scratch_$(date "+%s")"
__zspr_mkdir "${NEW_SCRATCH}"
ln -nfs "${NEW_SCRATCH}" "${SCRATCH}"
pushd "${SCRATCH}" > /dev/null
printf "New scratch dir ready for grinding ;>\n\n"
}
autoload -Uz new-scratch

View File

@ -1,5 +1,9 @@
#
# Wrap pacman so you don't need to put sudo before
# Optionally use yaourt or pacaur
# Optionally uses yaourt or pacaur
# Wrapper can be disabled using NO_PACMAN_WRAP=1 pacman -Syu
#
function pacman {
if [ ! -z "${NO_PACMAN_WRAP}" ]; then
sudo /usr/bin/pacman "$@"
@ -8,11 +12,13 @@ function pacman {
local ypath="$(command -v yaourt)"
local ppath="$(command -v pacaur)"
if [ ! -z "${ypath}" ]; then
${ypath} "$@"
"${ypath}" "$@"
elif [ ! -z "${ppath}" ]; then
${ppath} "$@"
"${ppath}" "$@"
else
sudo /usr/bin/pacman "$@"
fi
return $?
}
autoload -Uz pacman

56
modules/pluginmanager.zsh Normal file
View File

@ -0,0 +1,56 @@
#
# Plugin manager "interface"
#
ZSPR_PLM_FUNCTIONS=(
__zspr_plm_init
__zspr_plm_load_plugins
__zspr_plm_install_plugin
__zspr_plm_update_plugins
__zspr_plm_has_plugin
)
# Initializes plugin manager
function __zspr_plm_init {
if [[ "${ZSPR_PLM_FUNCTIONS[1]}" = "__zspr_plm_init" ]]; then
echo "Plugin manager does not implement __zspr_plm_init"
else
"${ZSPR_PLM_FUNCTIONS[1]}" "${@}"
fi
}
# Loads plugins
function __zspr_plm_load_plugins {
if [[ "${ZSPR_PLM_FUNCTIONS[2]}" = "__zspr_plm_load_plugins" ]]; then
echo "Plugin manager does not implement __zspr_plm_load_plugins"
else
"${ZSPR_PLM_FUNCTIONS[2]}" "${@}"
fi
}
# Installs new plugin
function __zspr_plm_install_plugin {
if [[ "${ZSPR_PLM_FUNCTIONS[3]}" = "__zspr_plm_install_plugin" ]]; then
echo "Plugin manager does not implement __zspr_plm_install_plugin"
else
"${ZSPR_PLM_FUNCTIONS[3]}" "${@}"
fi
}
# Updates plugins
function __zspr_plm_update_plugins {
if [[ "${ZSPR_PLM_FUNCTIONS[4]}" = "__zspr_plm_update_plugins" ]]; then
echo "Plugin manager does not implement __zspr_plm_update_plugins"
else
"${ZSPR_PLM_FUNCTIONS[4]}" "${@}"
fi
}
# Returns wheter plugin is present or not
function __zspr_plm_has_plugin {
if [[ "${ZSPR_PLM_FUNCTIONS[5]}" = "__zspr_plm_has_plugin" ]]; then
echo "Plugin manager does not implement __zspr_plm_has_plugin"
else
"${ZSPR_PLM_FUNCTIONS[5]}" "${@}"
fi
}

View File

@ -0,0 +1,60 @@
#
# Antibody plugin manager
#
function __zspr_antibody_download {
local DOWNLOAD_URL="https://github.com/getantibody/antibody/releases/download"
local LATEST="$(curl -s https://raw.githubusercontent.com/getantibody/homebrew-tap/master/Formula/antibody.rb | grep url | cut -f8 -d'/')"
local ANTIBODY_TMP="$(mktemp -d)"
local ANTIBODY_TGZ="${ANTIBODY_TMP}/antibody.tar.gz"
local ANTIBODY="${ANTIBODY_TMP}/antibody"
echo "Downloading Antibody $LATEST for $(uname -s)_$(uname -m), please wait..."
curl -s -L -o "${ANTIBODY_TGZ}" "${DOWNLOAD_URL}/${LATEST}/antibody_$(uname -s)_$(uname -m).tar.gz"
tar -xf "${ANTIBODY_TGZ}" -C "${ANTIBODY_TMP}"
# Move antibody to ~/.local/share/bin
test -x "${ANTIBODY}" || {
echo "Failed to find unpacked Antibody binary!"
}
mv "${ANTIBODY}" "${HOME}/.local/share/bin/antibody"
# Test if antibody works
__zspr_has_command "antibody" || echo "Could not get Antibody working!"
# Clean up
rm -rf "${ANTIBODY_TMP}"
}
function __zspr_antibody_init {
__zspr_has_command "antibody" || __zspr_antibody_download
source <(antibody init)
}
function __zspr_antibody_load_plugins {
# Iterate over array and let antibody create plugins script
for plugin in ${ZSHUPER_PLUGINS}; do echo "${plugin}"; done | antibody bundle
}
function __zspr_antibody_install_plugin {
antibody bundle "${1}"
}
function __zspr_antibody_update_plugins {
antibody update
}
function __zspr_antibody_has_plugin {
local PLUGIN="$(echo -n "${1}" | sed 's#/#-SLASH-##g')"
antibody list | grep -q "${PLUGIN}"
return $?
}
# Set up antibody as a plugin manager
ZSPR_PLM_FUNCTIONS[1]=__zspr_antibody_init
ZSPR_PLM_FUNCTIONS[2]=__zspr_antibody_load_plugins
ZSPR_PLM_FUNCTIONS[3]=__zspr_antibody_install_plugin
ZSPR_PLM_FUNCTIONS[4]=__zspr_antibody_update_plugins
ZSPR_PLM_FUNCTIONS[5]=__zspr_antibody_has_plugin

View File

@ -0,0 +1,44 @@
#
# zplug plugin manager
#
ZSPR_ZPLUG_HOME="${ZSHUPER_DIR}/zplug"
function __zspr_zplug_init {
if [ ! -d "${ZSPR_ZPLUG_HOME}" ]; then
git clone --depth=1 https://github.com/zplug/zplug "${ZSPR_ZPLUG_HOME}"
fi
source "${ZSPR_ZPLUG_HOME}/init.zsh"
zplug "zplug/zplug"
}
function __zspr_zplug_load_plugins {
for plugin in ${ZSHUPER_PLUGINS}; do
__zspr_zplug_install_plugin "${plugin}"
done
if ! zplug check; then
zplug install
fi
zplug load
}
function __zspr_zplug_install_plugin {
zplug ${1}
}
function __zspr_zplug_update_plugins {
zplug update
}
function __zspr_zplug_has_plugin {
zplug check ${1}
return $?
}
# Set up zplug as a plugin manager
ZSPR_PLM_FUNCTIONS[1]=__zspr_zplug_init
ZSPR_PLM_FUNCTIONS[2]=__zspr_zplug_load_plugins
ZSPR_PLM_FUNCTIONS[3]=__zspr_zplug_install_plugin
ZSPR_PLM_FUNCTIONS[4]=__zspr_zplug_update_plugins
ZSPR_PLM_FUNCTIONS[5]=__zspr_zplug_has_plugin

View File

@ -1,6 +1,9 @@
#
# Alias '...' to do '../..'
# Example: type 'cd ...' to get 'cd ../..'
rationalise-dot() {
#
function rationalise-dot {
local MATCH
if [[ $LBUFFER =~ '(^|/| | |'$'\n''|\||;|&)\.\.$' ]]; then
LBUFFER+=/
@ -10,5 +13,6 @@ rationalise-dot() {
zle self-insert
fi
}
zle -N rationalise-dot
bindkey . rationalise-dot

View File

@ -0,0 +1,17 @@
#
# Use ZAW search
# First check if ZAW is installed and sourced
#
__zspr_plm_has_plugin "zsh-users/zaw" || return
bindkey '^R' zaw-history
bindkey -M filterselect '^R' up-line-or-history
bindkey -M filterselect '^D' down-line-or-history
bindkey -M filterselect '^E' accept-search
zstyle ':filter-select:highlight' matched fg=red,standout
zstyle ':filter-select' hist-find-no-dups
zstyle ':filter-select' max-lines 7
zstyle ':filter-select' rotate-list yes
zstyle ':filter-select' extended-search yes

View File

@ -1,7 +1,18 @@
# See https://github.com/zplug/zplug
zplug "mafredri/zsh-async"
zplug "sindresorhus/pure"
zplug "zsh-users/zsh-history-substring-search"
zplug "willghatch/zsh-cdr"
zplug "zsh-users/zsh-completions"
zplug "zsh-users/zaw"
#
# zshuper plugins
# See https://getantibody.github.io/
# See https://github.com/zplug/zplug/
# (depends which plugin manager you are currently using)
#
ZSHUPER_PLUGINS=(
mafredri/zsh-async
sindresorhus/pure
zsh-users/zsh-history-substring-search
willghatch/zsh-cdr
zsh-users/zsh-completions
zsh-users/zaw
#zsh-users/zsh-syntax-highlighting
zdharma/fast-syntax-highlighting
)