Major rewrite
This commit is contained in:
30
modules/aliases.zsh
Normal file
30
modules/aliases.zsh
Normal 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
59
modules/compinit.zsh
Normal 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
8
modules/directories.zsh
Normal 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
12
modules/editor.zsh
Normal 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
14
modules/history.zsh
Normal 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
23
modules/keys.zsh
Normal 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
15
modules/new-scratch.zsh
Normal 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
|
||||
24
modules/pacman.zsh
Normal file
24
modules/pacman.zsh
Normal file
@@ -0,0 +1,24 @@
|
||||
#
|
||||
# Wrap pacman so you don't need to put sudo before
|
||||
# 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 "$@"
|
||||
return $?
|
||||
fi
|
||||
local ypath="$(command -v yaourt)"
|
||||
local ppath="$(command -v pacaur)"
|
||||
if [ ! -z "${ypath}" ]; then
|
||||
"${ypath}" "$@"
|
||||
elif [ ! -z "${ppath}" ]; then
|
||||
"${ppath}" "$@"
|
||||
else
|
||||
sudo /usr/bin/pacman "$@"
|
||||
fi
|
||||
return $?
|
||||
}
|
||||
|
||||
autoload -Uz pacman
|
||||
56
modules/pluginmanager.zsh
Normal file
56
modules/pluginmanager.zsh
Normal 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
|
||||
}
|
||||
60
modules/pluginmanager/antibody.zsh
Normal file
60
modules/pluginmanager/antibody.zsh
Normal 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
|
||||
44
modules/pluginmanager/zplug.zsh
Normal file
44
modules/pluginmanager/zplug.zsh
Normal 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
|
||||
18
modules/rationalize-dot.zsh
Normal file
18
modules/rationalize-dot.zsh
Normal file
@@ -0,0 +1,18 @@
|
||||
#
|
||||
# Alias '...' to do '../..'
|
||||
# Example: type 'cd ...' to get 'cd ../..'
|
||||
#
|
||||
|
||||
function rationalise-dot {
|
||||
local MATCH
|
||||
if [[ $LBUFFER =~ '(^|/| | |'$'\n''|\||;|&)\.\.$' ]]; then
|
||||
LBUFFER+=/
|
||||
zle self-insert
|
||||
zle self-insert
|
||||
else
|
||||
zle self-insert
|
||||
fi
|
||||
}
|
||||
|
||||
zle -N rationalise-dot
|
||||
bindkey . rationalise-dot
|
||||
17
modules/use-zaw-search.zsh
Normal file
17
modules/use-zaw-search.zsh
Normal 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
|
||||
Reference in New Issue
Block a user