Initial commit

This commit is contained in:
2016-06-19 04:11:34 +03:00
commit 5ed23c482d
12 changed files with 217 additions and 0 deletions

5
functions/correct.zsh Normal file
View File

@@ -0,0 +1,5 @@
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

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

23
functions/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

View File

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

19
functions/pacman.zsh Normal file
View File

@@ -0,0 +1,19 @@
# Wrap pacman so you don't need to put sudo before
# Optionally use yaourt or pacaur
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
echo "No yaourt or pacaur found, defaulting to pacman"
sudo /usr/bin/pacman "$@"
fi
return $?
}

View File

@@ -0,0 +1,14 @@
# Alias '...' to do '../..'
# Example: type 'cd ...' to get 'cd ../..'
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

View File

@@ -0,0 +1,12 @@
# 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