diff options
Diffstat (limited to 'zsh')
-rw-r--r-- | zsh/completion/_tmux_pane_words | 10 | ||||
-rwxr-xr-x | zsh/environment.zsh | 53 | ||||
-rw-r--r-- | zsh/fasd.zsh | 85 | ||||
-rw-r--r-- | zsh/fasdrc | 8 | ||||
-rwxr-xr-x | zsh/freebsd.zsh | 8 | ||||
-rwxr-xr-x | zsh/functions/fasd/fasd | 624 | ||||
-rw-r--r-- | zsh/functions/pure/prompt_pure_setup | 118 | ||||
-rw-r--r-- | zsh/functions/runit/_sv | 7 | ||||
-rw-r--r-- | zsh/functions/runit/getservicedir | 2 | ||||
-rw-r--r-- | zsh/functions/runit/linksv | 16 | ||||
-rw-r--r-- | zsh/functions/runit/renamesv | 36 | ||||
-rwxr-xr-x | zsh/interactive.zsh | 362 | ||||
-rwxr-xr-x | zsh/login.zsh | 0 | ||||
-rwxr-xr-x | zsh/logout.zsh | 0 | ||||
-rw-r--r-- | zsh/prefect.zsh | 10 | ||||
-rw-r--r-- | zsh/server.zsh | 20 |
16 files changed, 0 insertions, 1359 deletions
diff --git a/zsh/completion/_tmux_pane_words b/zsh/completion/_tmux_pane_words deleted file mode 100644 index 6ff9ce1..0000000 --- a/zsh/completion/_tmux_pane_words +++ /dev/null @@ -1,10 +0,0 @@ -local expl -local -a w - -if [[ -z "$TMUX_PANE" ]]; then - _message "not running inside tmux!" - return 1 -fi - -w=( ${(u)=$(tmux capture-pane \; show-buffer \; delete-buffer)} ) -_wanted values expl 'words from current tmux pane' compadd -a w diff --git a/zsh/environment.zsh b/zsh/environment.zsh deleted file mode 100755 index 11932e6..0000000 --- a/zsh/environment.zsh +++ /dev/null @@ -1,53 +0,0 @@ -if [[ $defpath == "" && -d ~/bin ]] -then - defpath=($path) - path=( - $defpath - ~/bin - ) - if [[ -d ~/.gem/ruby/*/bin ]] - then - path=( - $path - ~/.gem/ruby/*/bin - ) - fi -fi - -export PATH - -myfuncs=( ~/projects/dotfiles/zsh/functions/*(/) ) -fpath=( - $myfuncs - ~/projects/dotfiles/zsh/completion/ - $fpath -) -if [[ -d /usr/local/share/zsh-completions ]] -then - fpath=(/usr/local/share/zsh-completions $fpath) -fi - -if [[ -d /usr/local/share/zsh/site-functions ]] -then - fpath=(/usr/local/share/zsh/site-functions $fpath) -fi - -export FPATH - -case $OSTYPE in - *gnu*) - os=gnu - ;; - freebsd*) - os=freebsd - ;; - darwin*) - os=osx -esac - -export os - -if [[ -s $commands[direnv] ]] -then - eval "$(direnv hook zsh)" -fi diff --git a/zsh/fasd.zsh b/zsh/fasd.zsh deleted file mode 100644 index 64dbf7b..0000000 --- a/zsh/fasd.zsh +++ /dev/null @@ -1,85 +0,0 @@ -alias a='fasd -a' -alias s='fasd -si' -alias sd='fasd -sid' -alias sf='fasd -sif' -alias d='fasd -d' -alias f='fasd -f' -# function to execute built-in cd -fasd_cd() { - if [ $# -le 1 ]; then - fasd "$@" - else - local _fasd_ret="$(fasd -e 'printf %s' "$@")" - [ -z "$_fasd_ret" ] && return - [ -d "$_fasd_ret" ] && cd "$_fasd_ret" || printf %s\n "$_fasd_ret" - fi -} -alias z='fasd_cd -d' -alias zz='fasd_cd -d -i' - -# add zsh hook -_fasd_preexec() { - { eval "fasd --proc $(fasd --sanitize $1)"; } >> "/dev/null" 2>&1 -} -autoload -Uz add-zsh-hook -add-zsh-hook preexec _fasd_preexec - -# zsh command mode completion -_fasd_zsh_cmd_complete() { - local compl - read -c compl - (( $+compstate )) && compstate[insert]=menu # no expand if compsys loaded - reply=(${(f)"$(fasd --complete "$compl")"}) -} - -# enbale command mode completion -compctl -U -K _fasd_zsh_cmd_complete -V fasd -x 'C[-1,-*e],s[-]n[1,e]' -c - \ - 'c[-1,-A][-1,-D]' -f -- fasd fasd_cd - -(( $+functions[compdef] )) && { - # zsh word mode completion - _fasd_zsh_word_complete() { - [ "$2" ] && local _fasd_cur="$2" - [ -z "$_fasd_cur" ] && local _fasd_cur="${words[CURRENT]}" - local fnd="${_fasd_cur//,/ }" - local typ=${1:-e} - fasd --query $typ "$fnd" 2>> "/dev/null" | \ - sort -nr | sed 's/^[^ ]*[ ]*//' | while read -r line; do - compadd -U -V fasd "$line" - done - compstate[insert]=menu # no expand - } - _fasd_zsh_word_complete_f() { _fasd_zsh_word_complete f ; } - _fasd_zsh_word_complete_d() { _fasd_zsh_word_complete d ; } - _fasd_zsh_word_complete_trigger() { - local _fasd_cur="${words[CURRENT]}" - eval $(fasd --word-complete-trigger _fasd_zsh_word_complete $_fasd_cur) - } - # define zle widgets - zle -C fasd-complete complete-word _generic - zstyle ':completion:fasd-complete:*' completer _fasd_zsh_word_complete - zstyle ':completion:fasd-complete:*' menu-select - - zle -C fasd-complete-f complete-word _generic - zstyle ':completion:fasd-complete-f:*' completer _fasd_zsh_word_complete_f - zstyle ':completion:fasd-complete-f:*' menu-select - - zle -C fasd-complete-d complete-word _generic - zstyle ':completion:fasd-complete-d:*' completer _fasd_zsh_word_complete_d - zstyle ':completion:fasd-complete-d:*' menu-select -} - -(( $+functions[compdef] )) && { - # enable word mode completion - orig_comp="$(zstyle -L ':completion:\*' completer 2>> "/dev/null")" - if [ "$orig_comp" ]; then - case $orig_comp in - *_fasd_zsh_word_complete_trigger*);; - *) eval "$orig_comp _fasd_zsh_word_complete_trigger";; - esac - else - zstyle ':completion:*' completer _complete _fasd_zsh_word_complete_trigger - fi - unset orig_comp -} - diff --git a/zsh/fasdrc b/zsh/fasdrc deleted file mode 100644 index 22259d7..0000000 --- a/zsh/fasdrc +++ /dev/null @@ -1,8 +0,0 @@ -# -*- mode: sh; -*- -current () { - for path in *; do - printf "./%s|1\\n" "$path" - done -} - -alias e="f -t -e $EDITOR -B current" diff --git a/zsh/freebsd.zsh b/zsh/freebsd.zsh deleted file mode 100755 index 6ca0f8d..0000000 --- a/zsh/freebsd.zsh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env zsh -function update-check () { - sudo portsnap update - sudo portmaster -L --index-only | awk '/ [Nn]ew / { print substr($0,9,9999) }' - sudo pkg audit - pkg updating -d $( ls -ltr -D '%Y%m%d' /var/db/pkg | awk 'END{print $6}' ) -} -alias iotop="top -m io -o total" diff --git a/zsh/functions/fasd/fasd b/zsh/functions/fasd/fasd deleted file mode 100755 index b1e64f4..0000000 --- a/zsh/functions/fasd/fasd +++ /dev/null @@ -1,624 +0,0 @@ -#!/usr/bin/env sh - -# Fasd (this file) can be sourced or executed by any POSIX compatible shell. - -# Fasd is originally written based on code from z (https://github.com/rupa/z) -# by rupa deadwyler under the WTFPL license. Most if not all of the code has -# been rewritten. - -# Copyright (C) 2011, 2012 by Wei Dai. All rights reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -fasd() { - - # make zsh do word splitting inside this function - [ "$ZSH_VERSION" ] && emulate sh && setopt localoptions - - case $1 in - --init) shift - while [ "$1" ]; do - case $1 in - env) - { # source rc files if present - [ -s "/etc/fasdrc" ] && . "/etc/fasdrc" - [ -s "$HOME/.fasdrc" ] && . "$HOME/.fasdrc" - - # set default options - [ -z "$_FASD_DATA" ] && _FASD_DATA="$HOME/.fasd" - [ -z "$_FASD_BLACKLIST" ] && _FASD_BLACKLIST="--help" - [ -z "$_FASD_SHIFT" ] && _FASD_SHIFT="sudo busybox" - [ -z "$_FASD_IGNORE" ] && _FASD_IGNORE="fasd ls echo" - [ -z "$_FASD_SINK" ] && _FASD_SINK=/dev/null - [ -z "$_FASD_TRACK_PWD" ] && _FASD_TRACK_PWD=1 - [ -z "$_FASD_MAX" ] && _FASD_MAX=2000 - [ -z "$_FASD_BACKENDS" ] && _FASD_BACKENDS=native - [ -z "$_FASD_FUZZY" ] && _FASD_FUZZY=2 - [ -z "$_FASD_VIMINFO" ] && _FASD_VIMINFO="$HOME/.viminfo" - [ -z "$_FASD_RECENTLY_USED_XBEL" ] && \ - _FASD_RECENTLY_USED_XBEL="$HOME/.local/share/recently-used.xbel" - - if [ -z "$_FASD_AWK" ]; then - # awk preferences - local awk; for awk in mawk gawk original-awk nawk awk; do - $awk "" && _FASD_AWK=$awk && break - done - fi - } >> "${_FASD_SINK:-/dev/null}" 2>&1 - ;; - - auto) cat <<EOS -{ if [ "\$ZSH_VERSION" ] && compctl; then # zsh - eval "\$(fasd --init posix-alias zsh-hook zsh-ccomp zsh-ccomp-install \\ - zsh-wcomp zsh-wcomp-install)" - elif [ "\$BASH_VERSION" ] && complete; then # bash - eval "\$(fasd --init posix-alias bash-hook bash-ccomp bash-ccomp-install)" - else # posix shell - eval "\$(fasd --init posix-alias posix-hook)" - fi -} >> "$_FASD_SINK" 2>&1 - -EOS - ;; - - posix-alias) cat <<EOS -alias a='fasd -a' -alias s='fasd -si' -alias sd='fasd -sid' -alias sf='fasd -sif' -alias d='fasd -d' -alias f='fasd -f' -# function to execute built-in cd -fasd_cd() { - if [ \$# -le 1 ]; then - fasd "\$@" - else - local _fasd_ret="\$(fasd -e 'printf %s' "\$@")" - [ -z "\$_fasd_ret" ] && return - [ -d "\$_fasd_ret" ] && cd "\$_fasd_ret" || printf %s\\n "\$_fasd_ret" - fi -} -alias z='fasd_cd -d' -alias zz='fasd_cd -d -i' - -EOS - ;; - - tcsh-alias) cat <<EOS -;alias a 'fasd -a'; -alias s 'fasd -si'; -alias sd 'fasd -sid'; -alias sf 'fasd -sif'; -alias d 'fasd -d'; -alias f 'fasd -f'; -alias z 'cd "\`fasd -d -e printf\\ %s \\!*\`" >& /dev/null || fasd -d'; -EOS - ;; - - zsh-hook) cat <<EOS -# add zsh hook -_fasd_preexec() { - { eval "fasd --proc \$(fasd --sanitize \$1)"; } >> "$_FASD_SINK" 2>&1 -} -autoload -Uz add-zsh-hook -add-zsh-hook preexec _fasd_preexec - -EOS - ;; - - bash-hook) cat <<EOS -_fasd_prompt_func() { - eval "fasd --proc \$(fasd --sanitize \$(history 1 | \\ - sed "s/^[ ]*[0-9]*[ ]*//"))" >> "$_FASD_SINK" 2>&1 -} - -# add bash hook -case \$PROMPT_COMMAND in - *_fasd_prompt_func*) ;; - *) PROMPT_COMMAND="_fasd_prompt_func;\$PROMPT_COMMAND";; -esac - -EOS - ;; - - posix-hook) cat <<EOS -_fasd_ps1_func() { - { eval "fasd --proc \$(fasd --sanitize \$(fc -nl -1))"; } \\ - >> "$_FASD_SINK" 2>&1 -} -case \$PS1 in - *_fasd_ps1_func*) ;; - *) export PS1="\\\$(_fasd_ps1_func)\$PS1";; -esac - -EOS - ;; - - tcsh-hook) cat <<EOS -;alias fasd-prev-cmd 'fasd --sanitize \`history -h 1\`'; -set pprecmd="\`alias precmd\`"; -alias precmd '\$pprecmd; eval "fasd --proc \`fasd-prev-cmd\`" >& /dev/null'; -EOS - - ;; - - zsh-ccomp) cat <<EOS -# zsh command mode completion -_fasd_zsh_cmd_complete() { - local compl - read -c compl - (( \$+compstate )) && compstate[insert]=menu # no expand if compsys loaded - reply=(\${(f)"\$(fasd --complete "\$compl")"}) -} - -EOS - ;; - - zsh-wcomp) cat <<EOS -(( \$+functions[compdef] )) && { - # zsh word mode completion - _fasd_zsh_word_complete() { - [ "\$2" ] && local _fasd_cur="\$2" - [ -z "\$_fasd_cur" ] && local _fasd_cur="\${words[CURRENT]}" - local fnd="\${_fasd_cur//,/ }" - local typ=\${1:-e} - fasd --query \$typ "\$fnd" 2>> "$_FASD_SINK" | \\ - sort -nr | sed 's/^[^ ]*[ ]*//' | while read -r line; do - compadd -U -V fasd "\$line" - done - compstate[insert]=menu # no expand - } - _fasd_zsh_word_complete_f() { _fasd_zsh_word_complete f ; } - _fasd_zsh_word_complete_d() { _fasd_zsh_word_complete d ; } - _fasd_zsh_word_complete_trigger() { - local _fasd_cur="\${words[CURRENT]}" - eval \$(fasd --word-complete-trigger _fasd_zsh_word_complete \$_fasd_cur) - } - # define zle widgets - zle -C fasd-complete complete-word _generic - zstyle ':completion:fasd-complete:*' completer _fasd_zsh_word_complete - zstyle ':completion:fasd-complete:*' menu-select - - zle -C fasd-complete-f complete-word _generic - zstyle ':completion:fasd-complete-f:*' completer _fasd_zsh_word_complete_f - zstyle ':completion:fasd-complete-f:*' menu-select - - zle -C fasd-complete-d complete-word _generic - zstyle ':completion:fasd-complete-d:*' completer _fasd_zsh_word_complete_d - zstyle ':completion:fasd-complete-d:*' menu-select -} - -EOS - ;; - - zsh-ccomp-install) cat <<EOS -# enbale command mode completion -compctl -U -K _fasd_zsh_cmd_complete -V fasd -x 'C[-1,-*e],s[-]n[1,e]' -c - \\ - 'c[-1,-A][-1,-D]' -f -- fasd fasd_cd - -EOS - ;; - - zsh-wcomp-install) cat <<EOS -(( \$+functions[compdef] )) && { - # enable word mode completion - orig_comp="\$(zstyle -L ':completion:\\*' completer 2>> "$_FASD_SINK")" - if [ "\$orig_comp" ]; then - case \$orig_comp in - *_fasd_zsh_word_complete_trigger*);; - *) eval "\$orig_comp _fasd_zsh_word_complete_trigger";; - esac - else - zstyle ':completion:*' completer _complete _fasd_zsh_word_complete_trigger - fi - unset orig_comp -} - -EOS - ;; - - bash-ccomp) cat <<EOS -# bash command mode completion -_fasd_bash_cmd_complete() { - # complete command after "-e" - local cur=\${COMP_WORDS[COMP_CWORD]} - [[ \${COMP_WORDS[COMP_CWORD-1]} == -*e ]] && \\ - COMPREPLY=( \$(compgen -A command \$cur) ) && return - # complete using default readline complete after "-A" or "-D" - case \${COMP_WORDS[COMP_CWORD-1]} in - -A|-D) COMPREPLY=( \$(compgen -o default \$cur) ) && return;; - esac - # get completion results using expanded aliases - local RESULT=\$( fasd --complete "\$(alias -p \$COMP_WORDS \\ - 2>> "$_FASD_SINK" | sed -n "\\\$s/^.*'\\\\(.*\\\\)'/\\\\1/p") - \${COMP_LINE#* }" | while read -r line; do - quote_readline "\$line" 2>/dev/null || \\ - printf %q "\$line" 2>/dev/null && \\ - printf \\\\n - done) - local IFS=\$'\\n'; COMPREPLY=( \$RESULT ) -} -_fasd_bash_hook_cmd_complete() { - for cmd in \$*; do - complete -F _fasd_bash_cmd_complete \$cmd - done -} - -EOS - ;; - - bash-ccomp-install) cat <<EOS -# enable bash command mode completion -_fasd_bash_hook_cmd_complete fasd a s d f sd sf z zz - -EOS - ;; - esac; shift - done - ;; - - # if "$_fasd_cur" or "$2" is a query, then output shell code to be eval'd - --word-complete-trigger) - shift; [ "$2" ] && local _fasd_cur="$2" || return - case $_fasd_cur in - ,*) printf %s\\n "$1 e $_fasd_cur";; - f,*) printf %s\\n "$1 f ${_fasd_cur#?}";; - d,*) printf %s\\n "$1 d ${_fasd_cur#?}";; - *,,) printf %s\\n "$1 e $_fasd_cur";; - *,,f) printf %s\\n "$1 f ${_fasd_cur%?}";; - *,,d) printf %s\\n "$1 d ${_fasd_cur%?}";; - esac - ;; - - --sanitize) shift; printf %s\\n "$*" | \ - sed 's/\([^\]\)$( *[^ ]* *\([^)]*\)))*/\1\2/g - s/\([^\]\)[|&;<>$`{}]\{1,\}/\1 /g' - ;; - - --proc) shift # process commands - # stop if we don't own $_FASD_DATA or $_FASD_RO is set - [ -f "$_FASD_DATA" -a ! -O "$_FASD_DATA" ] || [ "$_FASD_RO" ] && return - - # blacklists - local each; for each in $_FASD_BLACKLIST; do - case " $* " in *\ $each\ *) return;; esac - done - - # shifts - while true; do - case " $_FASD_SHIFT " in - *\ $1\ *) shift;; - *) break;; - esac - done - - # ignores - case " $_FASD_IGNORE " in - *\ $1\ *) return;; - esac - - shift; fasd --add "$@" # add all arguments except command - ;; - - --add|-A) shift # add entries - # stop if we don't own $_FASD_DATA or $_FASD_RO is set - [ -f "$_FASD_DATA" -a ! -O "$_FASD_DATA" ] || [ "$_FASD_RO" ] && return - - # find all valid path arguments, convert them to simplest absolute form - local paths="$(while [ "$1" ]; do - [ -e "$1" ] && printf %s\\n "$1"; shift - done | sed '/^[^/]/s@^@'"$PWD"'/@ - s@/\.\.$@/../@;s@/\(\./\)\{1,\}@/@g;:0 - s@[^/][^/]*//*\.\./@/@;t 0 - s@^/*\.\./@/@;s@//*@/@g;s@/\.\{0,1\}$@@;s@^$@/@' 2>> "$_FASD_SINK" \ - | tr '\n' '|')" - - # add current pwd if the option is set - [ "$_FASD_TRACK_PWD" = "1" -a "$PWD" != "$HOME" ] && paths="$paths|$PWD" - - [ -z "${paths##\|}" ] && return # stop if we have nothing to add - - # maintain the file - local tempfile - tempfile="$(mktemp "$_FASD_DATA".XXXXXX)" || return - $_FASD_AWK -v list="$paths" -v now="$(date +%s)" -v max="$_FASD_MAX" -F"|" ' - BEGIN { - split(list, files, "|") - for(i in files) { - path = files[i] - if(path == "") continue - paths[path] = path # array for checking - rank[path] = 1 - time[path] = now - } - } - $2 >= 1 { - if($1 in paths) { - rank[$1] = $2 + 1 / $2 - time[$1] = now - } else { - rank[$1] = $2 - time[$1] = $3 - } - count += $2 - } - END { - if(count > max) - for(i in rank) print i "|" 0.9*rank[i] "|" time[i] # aging - else - for(i in rank) print i "|" rank[i] "|" time[i] - }' "$_FASD_DATA" 2>> "$_FASD_SINK" >| "$tempfile" - if [ $? -ne 0 -a -f "$_FASD_DATA" ]; then - env rm -f "$tempfile" - else - env mv -f "$tempfile" "$_FASD_DATA" - fi - ;; - - --delete|-D) shift # delete entries - # stop if we don't own $_FASD_DATA or $_FASD_RO is set - [ -f "$_FASD_DATA" -a ! -O "$_FASD_DATA" ] || [ "$_FASD_RO" ] && return - - # turn valid arguments into entry-deleting sed commands - local sed_cmd="$(while [ "$1" ]; do printf %s\\n "$1"; shift; done | \ - sed '/^[^/]/s@^@'"$PWD"'/@;s@/\.\.$@/../@;s@/\(\./\)\{1,\}@/@g;:0 - s@[^/][^/]*//*\.\./@/@;t 0 - s@^/*\.\./@/@;s@//*@/@g;s@/\.\{0,1\}$@@ - s@^$@/@;s@\([.[\/*^$]\)@\\\1@g;s@^\(.*\)$@/^\1|/d@' 2>> "$_FASD_SINK")" - - # maintain the file - local tempfile - tempfile="$(mktemp "$_FASD_DATA".XXXXXX)" || return - - sed "$sed_cmd" "$_FASD_DATA" 2>> "$_FASD_SINK" >| "$tempfile" - - if [ $? -ne 0 -a -f "$_FASD_DATA" ]; then - env rm -f "$tempfile" - else - env mv -f "$tempfile" "$_FASD_DATA" - fi - ;; - - --query) shift # query the db, --query [$typ ["$fnd" [$mode]]] - [ -f "$_FASD_DATA" ] || return # no db yet - [ "$1" ] && local typ="$1" - [ "$2" ] && local fnd="$2" - [ "$3" ] && local mode="$3" - - # cat all backends - local each _fasd_data; for each in $_FASD_BACKENDS; do - _fasd_data="$_fasd_data -$(fasd --backend $each)" - done - [ "$_fasd_data" ] || _fasd_data="$(cat "$_FASD_DATA")" - - # set mode specific code for calculating the prior - case $mode in - rank) local prior='times[i]';; - recent) local prior='sqrt(100000/(1+t-la[i]))';; - *) local prior='times[i] * frecent(la[i])';; - esac - - if [ "$fnd" ]; then # dafault matching - local bre="$(printf %s\\n "$fnd" | sed 's/\([*\.\\\[]\)/\\\1/g - s@ @[^|]*@g;s/\$$/|/')" - bre='^[^|]*'"$bre"'[^|/]*|' - local _ret="$(printf %s\\n "$_fasd_data" | grep "$bre")" - [ "$_ret" ] && _ret="$(printf %s\\n "$_ret" | while read -r line; do - [ -${typ:-e} "${line%%\|*}" ] && printf %s\\n "$line" - done)" - if [ "$_ret" ]; then - _fasd_data="$_ret" - else # no case mathcing - _ret="$(printf %s\\n "$_fasd_data" | grep -i "$bre")" - [ "$_ret" ] && _ret="$(printf %s\\n "$_ret" | while read -r line; do - [ -${typ:-e} "${line%%\|*}" ] && printf %s\\n "$line" - done)" - if [ "$_ret" ]; then - _fasd_data="$_ret" - elif [ "${_FASD_FUZZY:-0}" -gt 0 ]; then # fuzzy matching - local fuzzy_bre="$(printf %s\\n "$fnd" | \ - sed 's/\([*\.\\\[]\)/\\\1/g;s/\$$/|/ - s@\(\\\{0,1\}[^ ]\)@\1[^|/]\\{0,'"$_FASD_FUZZY"'\\}@g - s@ @[^|]*@g')" - fuzzy_bre='^[^|]*'"$fuzzy_bre"'[^|/]*|' - _ret="$(printf %s\\n "$_fasd_data" | grep -i "$fuzzy_bre")" - [ "$_ret" ] && _ret="$(printf %s\\n "$_ret" | while read -r line; do - [ -${typ:-e} "${line%%\|*}" ] && printf %s\\n "$line" - done)" - [ "$_ret" ] && _fasd_data="$_ret" || _fasd_data= - fi - fi - else # no query arugments - _fasd_data="$(printf %s\\n "$_fasd_data" | while read -r line; do - [ -${typ:-e} "${line%%\|*}" ] && printf %s\\n "$line" - done)" - fi - - # query the database - [ "$_fasd_data" ] && printf %s\\n "$_fasd_data" | \ - $_FASD_AWK -v t="$(date +%s)" -F"|" ' - function frecent(time) { - dx = t-time - if( dx < 3600 ) return 6 - if( dx < 86400 ) return 4 - if( dx < 604800 ) return 2 - return 1 - } - { - if(!paths[$1]) { - times[$1] = $2 - la[$1] = $3 - paths[$1] = 1 - } else { - times[$1] += $2 - if($3 > la[$1]) la[$1] = $3 - } - } - END { - for(i in paths) printf "%-10s %s\n", '"$prior"', i - }' - 2>> "$_FASD_SINK" - ;; - - --backend) - case $2 in - native) cat "$_FASD_DATA";; - viminfo) - < "$_FASD_VIMINFO" sed -n '/^>/{s@~@'"$HOME"'@ - s/^..// - p - }' | $_FASD_AWK -v t="$(date +%s)" '{ - t -= 60 - print $0 "|1|" t - }' - ;; - recently-used) - local nl="$(printf '\\\nX')"; nl="${nl%X}" # slash newline for sed - tr -d '\n' < "$_FASD_RECENTLY_USED_XBEL" | \ - sed 's@file:/@'"$nl"'@g;s@count="@'"$nl"'@g' | sed '1d;s/".*$//' | \ - tr '\n' '|' | sed 's@|/@'"$nl"'@g' | $_FASD_AWK -F'|' '{ - sum = 0 - for( i=2; i<=NF; i++ ) sum += $i - print $1 "|" sum - }' - ;; - *) eval "$2";; - esac - ;; - - *) # parsing logic and processing - local fnd= last= _FASD_BACKENDS="$_FASD_BACKENDS" _fasd_data= comp= exec= - while [ "$1" ]; do case $1 in - --complete) [ "$2" = "--" ] && shift; set -- $2; local lst=1 r=r comp=1;; - --query|--add|--delete|-A|-D) fasd "$@"; return $?;; - --version) [ -z "$comp" ] && echo "1.0.1" && return;; - --) while [ "$2" ]; do shift; fnd="$fnd $1"; last="$1"; done;; - -*) local o="${1#-}"; while [ "$o" ]; do case $o in - s*) local show=1;; - l*) local lst=1;; - i*) [ -z "$comp" ] && local interactive=1 show=1;; - r*) local mode=rank;; - t*) local mode=recent;; - e*) o="${o#?}"; if [ "$o" ]; then # there are characters after "-e" - local exec="$o" # anything after "-e" - else # use the next argument - local exec="${2:?"-e: Argument needed "}" - shift - fi; break;; - b*) o="${o#?}"; if [ "$o" ]; then - _FASD_BACKENDS="$o" - else - _FASD_BACKENDS="${2:?"-b: Argument needed"}" - shift - fi; break;; - B*) o="${o#?}"; if [ "$o" ]; then - _FASD_BACKENDS="$_FASD_BACKENDS $o" - else - _FASD_BACKENDS="$_FASD_BACKENDS ${2:?"-B: Argument needed"}" - shift - fi; break;; - a*) local typ=e;; - d*) local typ=d;; - f*) local typ=f;; - R*) local r=r;; - [0-9]*) local _fasd_i="$o"; break;; - h*) [ -z "$comp" ] && echo "fasd [options] [query ...] -[f|a|s|d|z] [options] [query ...] - options: - -s list paths with scores - -l list paths without scores - -i interactive mode - -e <cmd> set command to execute on the result file - -b <name> only use <name> backend - -B <name> add additional backend <name> - -a match files and directories - -d match directories only - -f match files only - -r match by rank only - -t match by recent access only - -R reverse listing order - -h show a brief help message - -[0-9] select the nth entry - -fasd [-A|-D] [paths ...] - -A add paths - -D delete paths" >&2 && return;; - esac; o="${o#?}"; done;; - *) fnd="$fnd $1"; last="$1";; - esac; shift; done - - # guess whether the last query is selected from tab completion - case $last in - /?*) if [ -z "$show$lst" -a -${typ:-e} "$last" -a "$exec" ]; then - $exec "$last" - return - fi;; - esac - - local R; [ -z "$r" ] && R=r || R= # let $R be the opposite of $r - fnd="${fnd# }" - - local res - res="$(fasd --query 2>> "$_FASD_SINK")" # query the database - [ $? -gt 0 ] && return - if [ 0 -lt ${_fasd_i:-0} ] 2>> "$_FASD_SINK"; then - res="$(printf %s\\n "$res" | sort -n${R} | \ - sed -n "$_fasd_i"'s/^[^ ]*[ ]*//p')" - elif [ "$interactive" ] || [ "$exec" -a -z "$fnd$lst$show" -a -t 1 ]; then - if [ "$(printf %s "$res" | sed -n '$=')" -gt 1 ]; then - res="$(printf %s\\n "$res" | sort -n${R})" - printf %s\\n "$res" | sed = | sed 'N;s/\n/ /' | sort -nr >&2 - printf "> " >&2 - local i; read i; [ 0 -lt "${i:-0}" ] 2>> "$_FASD_SINK" || return 1 - fi - res="$(printf %s\\n "$res" | sed -n "${i:-1}"'s/^[^ ]*[ ]*//p')" - elif [ "$lst" ]; then - [ "$res" ] && printf %s\\n "$res" | sort -n${r} | sed 's/^[^ ]*[ ]*//' - return - elif [ "$show" ]; then - [ "$res" ] && printf %s\\n "$res" | sort -n${r} - return - elif [ "$fnd" ] && [ "$exec" -o ! -t 1 ]; then # exec or subshell - res="$(printf %s\\n "$res" | sort -n | sed -n '$s/^[^ ]*[ ]*//p')" - else # no args, show - [ "$res" ] && printf %s\\n "$res" | sort -n${r} - return - fi - if [ "$res" ]; then - fasd --add "$res" - [ -z "$exec" ] && exec='printf %s\n' - $exec "$res" - fi - ;; - esac -} - -fasd --init env - -case $- in - *i*) ;; # assume being sourced, do nothing - *) # assume being executed as an executable - if [ -x "$_FASD_SHELL" -a -z "$_FASD_SET" ]; then - _FASD_SET=1 exec $_FASD_SHELL "$0" "$@" - else - fasd "$@" - fi;; -esac - diff --git a/zsh/functions/pure/prompt_pure_setup b/zsh/functions/pure/prompt_pure_setup deleted file mode 100644 index 5c63503..0000000 --- a/zsh/functions/pure/prompt_pure_setup +++ /dev/null @@ -1,118 +0,0 @@ -# Pure -# by Sindre Sorhus -# https://github.com/sindresorhus/pure -# MIT License - -# For my own and others sanity -# git: -# %b => current branch -# %a => current action (rebase/merge) -# prompt: -# %F => color dict -# %f => reset color -# %~ => current path -# %* => time -# %n => username -# %m => shortname host -# %(?..) => prompt conditional - %(condition.true.false) - - -# turns seconds into human readable time -# 165392 => 1d 21h 56m 32s -prompt_pure_human_time() { - local tmp=$1 - local days=$(( tmp / 60 / 60 / 24 )) - local hours=$(( tmp / 60 / 60 % 24 )) - local minutes=$(( tmp / 60 % 60 )) - local seconds=$(( tmp % 60 )) - (( $days > 0 )) && echo -n "${days}d " - (( $hours > 0 )) && echo -n "${hours}h " - (( $minutes > 0 )) && echo -n "${minutes}m " - echo "${seconds}s" -} - -# fastest possible way to check if repo is dirty -prompt_pure_git_dirty() { - # check if we're in a git repo - command git rev-parse --is-inside-work-tree &>/dev/null || return - # check if it's dirty - command git diff --quiet --ignore-submodules HEAD &>/dev/null - - (($? == 1)) && echo '*' -} - -# displays the exec time of the last command if set threshold was exceeded -prompt_pure_cmd_exec_time() { - local stop=$(date +%s) - local start=${cmd_timestamp:-$stop} - integer elapsed=$stop-$start - (($elapsed > ${PURE_CMD_MAX_EXEC_TIME:=5})) && prompt_pure_human_time $elapsed -} - -prompt_pure_preexec() { - cmd_timestamp=$(date +%s) - - # shows the current dir and executed command in the title when a process is active - print -Pn "\e]0;" - echo -nE "$PWD:t: $2" - print -Pn "\a" -} - -# string length ignoring ansi escapes -prompt_pure_string_length() { - echo ${#${(S%%)1//(\%([KF1]|)\{*\}|\%[Bbkf])}} -} - -prompt_pure_precmd() { - # shows the full path in the title - print -Pn '\e]0;%~\a' - - # git info - vcs_info - - local prompt_pure_preprompt='\n%F{blue}%~%F{242}$vcs_info_msg_0_`prompt_pure_git_dirty` $prompt_pure_username%f %F{yellow}`prompt_pure_cmd_exec_time`%f' - print -P $prompt_pure_preprompt - - # check async if there is anything to pull - (( ${PURE_GIT_PULL:-1} )) && { - # check if we're in a git repo - command git rev-parse --is-inside-work-tree &>/dev/null && - # check check if there is anything to pull - command git fetch &>/dev/null && - # check if there is an upstream configured for this branch - command git rev-parse --abbrev-ref @'{u}' &>/dev/null && - (( $(command git rev-list --right-only --count HEAD...@'{u}' 2>/dev/null) > 0 )) && - # some crazy ansi magic to inject the symbol into the previous line - print -Pn "\e7\e[A\e[1G\e[`prompt_pure_string_length $prompt_pure_preprompt`C%F{cyan}⇣%f\e8" - } &! - - # reset value since `preexec` isn't always triggered - unset cmd_timestamp -} - - -prompt_pure_setup() { - # prevent percentage showing up - # if output doesn't end with a newline - export PROMPT_EOL_MARK='' - - prompt_opts=(cr subst percent) - - autoload -Uz add-zsh-hook - autoload -Uz vcs_info - - add-zsh-hook precmd prompt_pure_precmd - add-zsh-hook preexec prompt_pure_preexec - - zstyle ':vcs_info:*' enable git - zstyle ':vcs_info:git*' formats ' %b' - zstyle ':vcs_info:git*' actionformats ' %b|%a' - - # show username@host if logged in through SSH - [[ "$SSH_CONNECTION" != '' ]] && prompt_pure_username='%n@%m ' - - # prompt turns red if the previous command didn't exit with 0 - PROMPT='%(?.%F{magenta}.%F{red})❯%f ' -} - -prompt_pure_setup "$@" diff --git a/zsh/functions/runit/_sv b/zsh/functions/runit/_sv deleted file mode 100644 index bf98b3e..0000000 --- a/zsh/functions/runit/_sv +++ /dev/null @@ -1,7 +0,0 @@ -#compdef sv - -_arguments -A -S -s \ - '-v[wait up to 7 seconds for the command to take effect. (up|down|term|once|cont|exit)]' \ - '-w+[wait for %n seconds]: :_guard "[0-9]#" "numeric value"' \ - '1:command:(status up down once pause cont hup alarm interrupt quit 1 2 term kill exit start stop restart shutdown force-stop force-reload force-restart force-shutdown check)' \ - '*:installed service:_files -W ${SVDIR:-/service}' diff --git a/zsh/functions/runit/getservicedir b/zsh/functions/runit/getservicedir deleted file mode 100644 index 2e5d961..0000000 --- a/zsh/functions/runit/getservicedir +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env zsh -print ${$(readlink ${SVDIR:-/service}/$1):h} \ No newline at end of file diff --git a/zsh/functions/runit/linksv b/zsh/functions/runit/linksv deleted file mode 100644 index 7ee7109..0000000 --- a/zsh/functions/runit/linksv +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env zsh - -if [[ -z $1 ]]; then - echo "No service specified" - return 64 -fi - - -if [[ ! -x $1 ]]; then - echo "Service does not exist in current directory" - return 1 -fi - -mv $1{,.old} -ln -s =sv $1 -chmod -h a-w $1 diff --git a/zsh/functions/runit/renamesv b/zsh/functions/runit/renamesv deleted file mode 100644 index dba1098..0000000 --- a/zsh/functions/runit/renamesv +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env zsh -local svdir=${SVDIR:-/service} -if [[ -z $1 || -z $2 ]]; then - echo "Usage: $0 source target" - return 64 -fi - -if [[ ! -h $svdir/$1 ]]; then - echo $svdir/$1 does not exist - return 2 -fi - -if [[ -e $svdir/$2 ]]; then - echo $svdir/$2 already exists - return 3 -fi - -local servicedir=`getservicedir` - -if [[ ! ( -w $svdir && -w $servicedir ) ]]; then - echo $svdir or $servicedir is not writeable -fi - -# The service doesn't have to be stopped as removing the link will do that -# However, running the same service twice isn't a great idea, so wait here -sv stop $1 - -rm -f $svdir/$1 || return - -mv $servicedir/{$1,$2} || return - -ln -s {$servicedir,$svdir}/$2 || return - -sv start $2 - -return diff --git a/zsh/interactive.zsh b/zsh/interactive.zsh deleted file mode 100755 index 365214c..0000000 --- a/zsh/interactive.zsh +++ /dev/null @@ -1,362 +0,0 @@ -export PAGER="less" -export EDITOR="emacsclient" -export CLICOLOR=true - -# -# zsh variables -# -HISTFILE=~/.zsh/history -HISTSIZE=4000 -SAVEHIST=3000 - -WORDCHARS='*?_-[]~=.&;!#$%^(){}<>' - -#If a command takes more than 5 seconds, give statistics -REPORTTIME=5 -TIMEFMT="%U user %S system %P cpu %*Es total" - -#Check for user logins -watch=notme -WATCHFMT="%n has %a %l from %M at %t" - -hosts=( - server - prefect - alanpearce.co.uk - home.alanpearce.co.uk -) - -users=(alan root toor) - -function linkAuthSock () { - local linkSock=~/.ssh/ssh_auth_sock - ln -sf $1 ~/.ssh/ssh_auth_sock - export SSH_AUTH_SOCK=$linkSock -} - -if [[ "$SSH_AUTH_SOCK" != "" ]] -then - if [[ -e ~/.ssh/ssh_auth_sock && ! -L ~/.ssh/ssh_auth_sock ]] - then - linkAuthSock $SSH_AUTH_SOCK - fi -fi - -LS_COLORS='no=00:fi=00:di=36:ln=35:pi=30;44:so=35;44:do=35;44:bd=33;44:cd=37;44:or=05;37;41:mi=05;37;41:ex=01;31:*.cmd=01;31:*.exe=01;31:*.com=01;31:*.bat=01;31:*.reg=01;31:*.app=01;31:*.txt=32:*.org=32:*.md=32:*.mkd=32:*.h=32:*.c=32:*.C=32:*.cc=32:*.cpp=32:*.cxx=32:*.objc=32:*.sh=32:*.csh=32:*.zsh=32:*.el=32:*.vim=32:*.java=32:*.pl=32:*.pm=32:*.py=32:*.rb=32:*.hs=32:*.php=32:*.htm=32:*.html=32:*.shtml=32:*.erb=32:*.haml=32:*.xml=32:*.rdf=32:*.css=32:*.sass=32:*.scss=32:*.less=32:*.js=32:*.coffee=32:*.man=32:*.0=32:*.1=32:*.2=32:*.3=32:*.4=32:*.5=32:*.6=32:*.7=32:*.8=32:*.9=32:*.l=32:*.n=32:*.p=32:*.pod=32:*.tex=32:*.bmp=33:*.cgm=33:*.dl=33:*.dvi=33:*.emf=33:*.eps=33:*.gif=33:*.jpeg=33:*.jpg=33:*.JPG=33:*.mng=33:*.pbm=33:*.pcx=33:*.pdf=33:*.pgm=33:*.png=33:*.ppm=33:*.pps=33:*.ppsx=33:*.ps=33:*.svg=33:*.svgz=33:*.tga=33:*.tif=33:*.tiff=33:*.xbm=33:*.xcf=33:*.xpm=33:*.xwd=33:*.xwd=33:*.yuv=33:*.aac=33:*.au=33:*.flac=33:*.mid=33:*.midi=33:*.mka=33:*.mp3=33:*.mpa=33:*.mpeg=33:*.mpg=33:*.ogg=33:*.ra=33:*.wav=33:*.anx=33:*.asf=33:*.avi=33:*.axv=33:*.flc=33:*.fli=33:*.flv=33:*.gl=33:*.m2v=33:*.m4v=33:*.mkv=33:*.mov=33:*.mp4=33:*.mp4v=33:*.mpeg=33:*.mpg=33:*.nuv=33:*.ogm=33:*.ogv=33:*.ogx=33:*.qt=33:*.rm=33:*.rmvb=33:*.swf=33:*.vob=33:*.wmv=33:*.doc=31:*.docx=31:*.rtf=31:*.dot=31:*.dotx=31:*.xls=31:*.xlsx=31:*.ppt=31:*.pptx=31:*.fla=31:*.psd=31:*.7z=1;35:*.apk=1;35:*.arj=1;35:*.bin=1;35:*.bz=1;35:*.bz2=1;35:*.cab=1;35:*.deb=1;35:*.dmg=1;35:*.gem=1;35:*.gz=1;35:*.iso=1;35:*.jar=1;35:*.msi=1;35:*.rar=1;35:*.rpm=1;35:*.tar=1;35:*.tbz=1;35:*.tbz2=1;35:*.tgz=1;35:*.tx=1;35:*.war=1;35:*.xpi=1;35:*.xz=1;35:*.z=1;35:*.Z=1;35:*.zip=1;35:*.ANSI-30-black=30:*.ANSI-01;30-brblack=01;30:*.ANSI-31-red=31:*.ANSI-01;31-brred=01;31:*.ANSI-32-green=32:*.ANSI-01;32-brgreen=01;32:*.ANSI-33-yellow=33:*.ANSI-01;33-bryellow=01;33:*.ANSI-34-blue=34:*.ANSI-01;34-brblue=01;34:*.ANSI-35-magenta=35:*.ANSI-01;35-brmagenta=01;35:*.ANSI-36-cyan=36:*.ANSI-01;36-brcyan=01;36:*.ANSI-37-white=37:*.ANSI-01;37-brwhite=01;37:*.log=01;34:*~=01;34:*#=01;34:*.bak=01;36:*.BAK=01;36:*.old=01;36:*.OLD=01;36:*.org_archive=01;36:*.off=01;36:*.OFF=01;36:*.dist=01;36:*.DIST=01;36:*.orig=01;36:*.ORIG=01;36:*.swp=01;36:*.swo=01;36:*,v=01;36:*.gpg=34:*.gpg=34:*.pgp=34:*.asc=34:*.3des=34:*.aes=34:*.enc=34:' - -#Ignore suffixes in completion -fignore=( - svbin -) - -# -# Modules -# -autoload -Uz compinit bashcompinit -autoload -U colors complist zrecompile zmv zargs zed -autoload -Uz vcs_info -autoload insert-files -zle -N insert-files -zmodload -i zsh/complist -colors -compinit -u -d .zsh/cache/compdump -bashcompinit - -zstyle :compinstall filename '~/.zshrc' - -autoload -Uz _tmux_pane_words -zle -C tmux-pane-words-prefix complete-word _generic -zle -C tmux-pane-words-anywhere complete-word _generic -zstyle ':completion:tmux-pane-words-(prefix|anywhere):*' completer _tmux_pane_words -zstyle ':completion:tmux-pane-words-(prefix|anywhere):*' ignore-line current -zstyle ':completion:tmux-pane-words-anywhere:*' matcher-list 'b:=* m:{A-Za-z}={a-zA-Z}' - -# Speed up completion by not going further than a full match -zstyle ':completion:*' accept-exact '*(N)' - -zstyle ':completion:*:default' use-cache on -zstyle ':completion:*:default' cache-path ~/.zsh/cache/compcache - -zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' '+m:{A-Z}={a-z}' -zstyle ':completion:*' completer _oldlist _expand _force_rehash _complete _match - -zstyle ':completion:*' verbose yes -zstyle ':completion:*:messages' format '%d' -zstyle ':completion:*:warnings' format 'No matches for: %d' -zstyle ':completion:*:descriptions' format '%U%B%d%b%u' -zstyle ':completion:*:corrections' format '%B%d (errors: %e)%b' -zstyle ':completion:*' group-name '' - -# Complete all user processes -zstyle ':completion:*:processes' command 'ps -au$USER' -# Add colour to process lists -zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31' -zstyle ':completion:*:*:kill:*' menu yes select -zstyle ':completion:*:kill:*' force-list always -zstyle ':completion:*:*:killall:*' menu yes select -zstyle ':completion:*:killall:*' force-list always - -# Complete unreadable log filenames -#zstyle ':completion::complete:(most|tail)::' fake-files '/var/log/*:current' - -# Group manpages by section -zstyle ':completion:*' separate-sections true - -# Users -#zstyle '*' users $users - -zstyle '*' hosts $hosts - -zstyle ':completion:*:functions' ignored-patterns '_*' -zstyle ':completion:*:cd:*' ignore-parents parent pwd - -#This works, but isn't the same as ls -#zstyle ':completion:*:default' list-colors '' -zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} - -zstyle ':vcs_info:*' enable git hg - -# Filename suffixes to ignore during completion (except after rm command) -zstyle ':completion:*:*:(^rm):*:*files' ignored-patterns '*?.o' '*?.c~' '*?.old' '*?.pro' - -## Prompt -if [[ $TERM != 'dumb' ]] -then - autoload -U promptinit - promptinit - prompt pure -fi - -# Options - -# Changing directories -setopt auto_cd - -# Completion -setopt auto_list # List multiple choices on first tab -unsetopt list_ambiguous # List ambiguous choices rather than completing common prefixes -unsetopt list_beep # Don't try to beep here -setopt list_types # Indicate file types - -# Expansion and globbing -setopt extended_glob # Use #~^ as part of filename patterns -unsetopt nomatch - -# History -unsetopt hist_beep -setopt hist_expire_dups_first -setopt hist_fcntl_lock # Use standard locking on histfile -setopt hist_find_no_dups -setopt hist_ignore_space -setopt hist_reduce_blanks -setopt hist_verify -setopt share_history -setopt inc_append_history - -# Input/Output -unsetopt clobber -unsetopt flow_control -setopt path_dirs # Search PATH even with slashes -setopt print_exit_value - -# Job Control -setopt auto_continue -unsetopt nohup -setopt long_list_jobs -unsetopt notify - -# Scripts and functions -unsetopt multi_func_def -setopt multios - -# Zle -unsetopt beep - -############ -# Keybinds # -############ -#KiTTY -bindkey "OD" backward-word -bindkey "OC" forward-word - -#General -bindkey "[1~" beginning-of-line -bindkey "[4~" end-of-line -bindkey "[5~" beginning-of-history -bindkey "[6~" end-of-history -bindkey "[2~" quoted-insert -bindkey "[3~" delete-char - -bindkey '' backward-delete-char - -bindkey '^I' expand-or-complete-prefix -bindkey '[Z' reverse-menu-complete -bindkey '[A' up-line-or-search -bindkey '[B' down-line-or-search - -#urxvt -bindkey '[3;5~' delete-word -bindkey '[1;5D' backward-word -bindkey '[1;5C' forward-word - -bindkey 'f' insert-files -bindkey 'd' describe-key-briefly - -bindkey '\' tmux-pane-words-prefix -bindkey '|' tmux-pane-words-anywhere - -# Aliases before functions -alias getcflags='gcc -\#\#\# -march=native -E /usr/include/stdlib.h 2>&1 | grep "/usr/libexec/gcc/.*cc1"' -alias grep='grep --color=auto' -alias df='df -h' -alias du='du -h' -alias md='mkdir -p' -alias rd='rmdir' -alias .='source' - -ls='\ls' -gnu_ls_options="-v --group-directories-first --color=auto" -gnu_ls_isodate="--time-style=long-iso" -bsd_ls_options="-p" -bsd_ls_isodate="-D '%F %k:%M'" - -case $os in - osx) - if [[ -n $commands[gls] ]] - then - ls='\gls' - ls_options=$gnu_ls_options - ls_isodate=$gnu_ls_isodate - else - ls_options=$bsd_ls_options - ls_isodate=$bsd_ls_isodate - fi - ;; - freebsd) - ls_options=$bsd_ls_options - ls_isodate=$bsd_ls_isodate - ;; - gnu) - ls_options=$gnu_ls_options - ls_isodate=$gnu_ls_isodate - ;; -esac -alias l="${ls} ${ls_options} -Bp" -alias l1="${ls} ${ls_options} -1" -alias ls="${ls} ${ls_options} -hF" -alias la="${ls} ${ls_options} -hA" -alias ll="${ls} ${ls_options} ${ls_isodate} -hl" -alias lal="ll -A" -alias lla="lal" -alias llr="ll -t" -alias gpp='g++' -alias lsr="${ls} -tld *(m-2)" # mtime < -2days - -alias salt="noglob salt" -alias pping="prettyping.sh" -alias trans="transmission-remote transmission.home" -alias bitcoin="bitcoind" -alias su="smart_sudo " -alias E="SUDO_EDITOR=\emacsclient -c -a emacs\" sudoedit" -alias wprop='xprop |awk '\'' - /^WM_CLASS/{sub(/.* =/, "instance:"); sub(/,/, "\nclass:"); print} - /^WM_NAME/{sub(/.* =/, "title:"); print} - /^WM_WINDOW_ROLE/{sub(/.* =/, "role:"); print}'\''' - -alias et="emacsclient -t" - -alias -g ...='../..' - -#Suffix aliases -alias -s log=less - -if [[ -e =hub ]]; then - alias git="hub" - autoload -U _hub - compdef _hub hub -fi - -# Functions - -magit () { - emacsclient -e "(magit-status \"$PWD\")" -} - -dired () { - emacsclient -e "(dired \"$PWD\")" -} - -pid () { - local i - for i in /proc/<->/stat - [[ "$(< $i)" = *\((${(j:|:)~@})\)* ]] && echo $i:h:t - return 0 -} - -_force_rehash() { - (( CURRENT == 1 )) && rehash - return 1 # Because we didn't really complete anything -} - -portgrep() { - sudo lsof -i :$1 -nP | egrep '(LISTEN|UDP|COMMAND)' -} - -ipgrep() { - sudo lsof -i @$1 -nP -} - -smart_sudo () { - if [[ -n $1 ]]; then - \sudo $argv - else - #if no parameters were given, then assume we want a root shell - \sudo -i -u toor - fi -} - -compdef _sudo smart_sudo - -smart_compile () { - local zcompargs - if [[ $1 = *zshrc* ]]; then - zcompargs="-R" - fi - - if [[ $EUID -ne 0 || $1 != *alan* ]]; then - zrecompile -q -p $zcompargs $1 - fi - if [[ -n $2 ]]; then - . $1 - fi -} - -emacs_change_focus () { - emacsclient -n -e "(select-frame-set-input-focus (selected-frame))" > /dev/null -} - -ec () { - local visibleFrames - visibleFrames=`emacsclient -e '(length (visible-frame-list))'` - if [[ $? -ne 0 ]]; then - print "Daemon not running" - return 1 - fi - - if [[ $visibleFrames -eq 1 ]]; then - emacsclient -n -c "$@" && emacs_change_focus - else - emacs_change_focus - if [[ $# -gt 0 ]]; then - emacsclient -n "$@" - fi - fi -} - -_FASD_DATA="$HOME/.zsh/fasd-data" -autoload -U fasd -source ~/.zsh/cache/fasd-init-zsh - -if [[ $OSTYPE == freebsd* ]]; then - source ~/projects/dotfiles/zsh/freebsd.zsh -fi diff --git a/zsh/login.zsh b/zsh/login.zsh deleted file mode 100755 index e69de29..0000000 --- a/zsh/login.zsh +++ /dev/null diff --git a/zsh/logout.zsh b/zsh/logout.zsh deleted file mode 100755 index e69de29..0000000 --- a/zsh/logout.zsh +++ /dev/null diff --git a/zsh/prefect.zsh b/zsh/prefect.zsh deleted file mode 100644 index 997ba39..0000000 --- a/zsh/prefect.zsh +++ /dev/null @@ -1,10 +0,0 @@ -EDITOR="emacs" -VISUAL="emacs" - -if [[ ! -S $SSH_AUTH_SOCK ]] -then - eval `ssh-agent | sed -e '/^echo/d'` - linkAuthSock $SSH_AUTH_SOCK -fi - -export WINEARCH="win32" \ No newline at end of file diff --git a/zsh/server.zsh b/zsh/server.zsh deleted file mode 100644 index d9d7421..0000000 --- a/zsh/server.zsh +++ /dev/null @@ -1,20 +0,0 @@ -# -*- shell-script -*- - -export SVDIR=/service -if [[ "$EUID" == "0" ]] || [[ "$USER" == "root" ]] -then - export EDITOR="emacs -nw" -else - export ALTERNATE_EDITOR="emacs" - export EDITOR="emacsclient" -fi - -mailpath= - -# Folder aliases -hash -d music=/tank/media/Music - -zstyle ':completion:*' local server /tank/www/internal '' -zstyle ':completion:*' local external /tank/www/external -zstyle ':completion:*' local alphapulsar.uk.to /tank/www/gaming -zstyle ':completion:*' local home.alanpearce.co.uk /tank/www/external |