feat(revamp): add zsh and neovim configs, add an install script and a dependencies list
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
#compdef cdls popdls pushdls
|
||||
#autoload
|
||||
|
||||
#
|
||||
# Completes cdls, popdls, and pushdls.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
_cd
|
||||
@@ -0,0 +1,11 @@
|
||||
#compdef dut
|
||||
#autoload
|
||||
|
||||
#
|
||||
# Completes dut.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
_du
|
||||
@@ -0,0 +1,13 @@
|
||||
#compdef mkdcd
|
||||
#autoload
|
||||
|
||||
#
|
||||
# Completes mkdcd.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
local expl
|
||||
|
||||
_wanted directories expl 'directory' _path_files -/ || _message 'directory'
|
||||
@@ -0,0 +1,11 @@
|
||||
#compdef noremoteglob
|
||||
#autoload
|
||||
|
||||
#
|
||||
# Completes noremoteglob.
|
||||
#
|
||||
# Authors:
|
||||
# Indrajit Raychaudhuri <irc+code@indrajit.com>
|
||||
#
|
||||
|
||||
_precommand
|
||||
@@ -0,0 +1,18 @@
|
||||
#compdef prep
|
||||
#autoload
|
||||
|
||||
#
|
||||
# Completes prep.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
_arguments \
|
||||
'-i[ignore case]' \
|
||||
'-m[^ and $ match the start and the end of a line]' \
|
||||
'-s[. matches newline]' \
|
||||
'-v[invert match]' \
|
||||
'-x[ignore whitespace and comments]' \
|
||||
'1::pattern:' \
|
||||
'2::files:_files' && return 0
|
||||
@@ -0,0 +1,19 @@
|
||||
#compdef psub
|
||||
#autoload
|
||||
|
||||
#
|
||||
# Completes psub.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
_arguments \
|
||||
'-g[match globally]' \
|
||||
'-i[ignore case]' \
|
||||
'-m[^ and $ match the start and the end of a line]' \
|
||||
'-s[. matches newline]' \
|
||||
'-x[ignore whitespace and comments]' \
|
||||
'1::pattern:' \
|
||||
'2::replacement:' \
|
||||
'3::files:_files' && return 0
|
||||
@@ -0,0 +1,19 @@
|
||||
#
|
||||
# Highlights diff output.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
# function diff {
|
||||
|
||||
if zstyle -t ':prezto:module:utility:diff' color \
|
||||
&& [[ -t 1 ]] \
|
||||
&& (( $+commands[colordiff] )); then
|
||||
command diff "$@" | colordiff
|
||||
return "${pipestatus[1]}"
|
||||
else
|
||||
command diff "$@"
|
||||
fi
|
||||
|
||||
# }
|
||||
@@ -0,0 +1,27 @@
|
||||
#
|
||||
# Displays the grand total disk usage using human readable units.
|
||||
#
|
||||
# Authors:
|
||||
# Suraj N. Kurapati <sunaku@gmail.com>
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
# function dut {
|
||||
|
||||
(( $# == 0 )) && set -- *
|
||||
|
||||
if [[ ${(@M)${(f)"$(du --version 2>&1)"}:#*GNU *} ]]; then
|
||||
du -khsc "$@" | sort -h -r
|
||||
else
|
||||
local line size name
|
||||
local -a record
|
||||
|
||||
while IFS=$'\n' read line; do
|
||||
record=(${(z)line})
|
||||
size="$(($record[1] / 1024.0))"
|
||||
name="$record[2,-1]"
|
||||
printf "%9.1LfM %s\n" "$size" "$name"
|
||||
done < <(du -kcs "$@") | sort -n -r
|
||||
fi
|
||||
|
||||
# }
|
||||
@@ -0,0 +1,17 @@
|
||||
#
|
||||
# Highlights make output.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
# function make {
|
||||
|
||||
if zstyle -t ':prezto:module:utility:make' color \
|
||||
&& (( $+commands[colormake] )); then
|
||||
command colormake "$@"
|
||||
else
|
||||
command make "$@"
|
||||
fi
|
||||
|
||||
# }
|
||||
@@ -0,0 +1,56 @@
|
||||
#
|
||||
# Provides a grep-like pattern search.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
# function prep {
|
||||
|
||||
local usage pattern modifiers invert
|
||||
|
||||
usage="$(
|
||||
cat <<EOF
|
||||
usage: $0 [-option ...] [--] pattern [file ...]
|
||||
|
||||
options:
|
||||
-i ignore case
|
||||
-m ^ and $ match the start and the end of a line
|
||||
-s . matches newline
|
||||
-v invert match
|
||||
-x ignore whitespace and comments
|
||||
EOF
|
||||
)"
|
||||
|
||||
while getopts ':imsxv' opt; do
|
||||
case "$opt" in
|
||||
(i) modifiers="${modifiers}i" ;;
|
||||
(m) modifiers="${modifiers}m" ;;
|
||||
(s) modifiers="${modifiers}s" ;;
|
||||
(x) modifiers="${modifiers}x" ;;
|
||||
(v) invert="yes" ;;
|
||||
(:)
|
||||
print "$0: option requires an argument: $OPTARG" >&2
|
||||
print "$usage" >&2
|
||||
return 1
|
||||
;;
|
||||
([?])
|
||||
print "$0: unknown option: $OPTARG" >&2
|
||||
print "$usage" >&2
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $(( $OPTIND - 1 ))
|
||||
|
||||
if (( $# < 1 )); then
|
||||
print "$usage" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
pattern="$1"
|
||||
shift
|
||||
|
||||
perl -n -l -e "print if ${invert:+not} m/${pattern//\//\\/}/${modifiers}" "$@"
|
||||
|
||||
# }
|
||||
@@ -0,0 +1,57 @@
|
||||
#
|
||||
# Provides a sed-like pattern substitution.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
# function psub {
|
||||
|
||||
local usage pattern replacement modifiers
|
||||
|
||||
usage="$(
|
||||
cat <<EOF
|
||||
usage: $0 [-option ...] [--] pattern replacement [file ...]
|
||||
|
||||
options:
|
||||
-g match globally
|
||||
-i ignore case
|
||||
-m ^ and $ match the start and the end of a line
|
||||
-s . matches newline
|
||||
-x ignore whitespace and comments
|
||||
EOF
|
||||
)"
|
||||
|
||||
while getopts ':gimsx' opt; do
|
||||
case "$opt" in
|
||||
(g) modifiers="${modifiers}g" ;;
|
||||
(i) modifiers="${modifiers}i" ;;
|
||||
(m) modifiers="${modifiers}m" ;;
|
||||
(s) modifiers="${sodifiers}s" ;;
|
||||
(x) modifiers="${modifiers}x" ;;
|
||||
(:)
|
||||
print "$0: option requires an argument: $OPTARG" >&2
|
||||
print "$usage" >&2
|
||||
return 1
|
||||
;;
|
||||
([?])
|
||||
print "$0: unknown option: $OPTARG" >&2
|
||||
print "$usage" >&2
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $(( $OPTIND - 1 ))
|
||||
|
||||
if (( $# < 2 )); then
|
||||
print "$usage" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
pattern="$1"
|
||||
replacement="$2"
|
||||
repeat 2 shift
|
||||
|
||||
perl -i'.orig' -n -l -e "s/${pattern//\//\\/}/${replacement//\//\\/}/${modifiers}; print" "$@"
|
||||
|
||||
# }
|
||||
@@ -0,0 +1,32 @@
|
||||
#
|
||||
# Highlights wdiff output.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
# Indrajit Raychaudhuri <irc@indrajit.com>
|
||||
#
|
||||
|
||||
# function wdiff {
|
||||
|
||||
if zstyle -t ':prezto:module:utility:wdiff' color; then
|
||||
if (( $+commands[wdiff] )); then
|
||||
command wdiff \
|
||||
--avoid-wraps \
|
||||
--start-delete="$(print -n $FG[red])" \
|
||||
--end-delete="$(print -n $FG[none])" \
|
||||
--start-insert="$(print -n $FG[green])" \
|
||||
--end-insert="$(print -n $FG[none])" \
|
||||
"$@" \
|
||||
| sed 's/^\(@@\( [+-][[:digit:]]*,[[:digit:]]*\)\{2\} @@\)$/;5;6m\10m/g'
|
||||
elif (( $+commands[git] )); then
|
||||
command git --no-pager diff --no-ext-diff --no-index --color=auto --color-words "$@"
|
||||
else
|
||||
command wdiff "$@"
|
||||
fi
|
||||
elif (( ! $+commands[wdiff] && $+commands[git] )); then
|
||||
command git --no-pager diff --no-ext-diff --no-index --color=never "$@"
|
||||
else
|
||||
command wdiff "$@"
|
||||
fi
|
||||
|
||||
# }
|
||||
@@ -0,0 +1,102 @@
|
||||
#
|
||||
# Provides a much easier way to search and access ZSH's manual. First checks for
|
||||
# terms at the start of the manual, then checks if it's at start of a line allowing
|
||||
# whitespace.
|
||||
#
|
||||
# Authors:
|
||||
# Samantha McVey <samantham@posteo.net>
|
||||
#
|
||||
|
||||
# function zsh-help {
|
||||
|
||||
local usage="$(
|
||||
cat <<EOF
|
||||
usage: $0 [--help] [--zsh-help-debug] [--all] search term(s)
|
||||
Options:
|
||||
--all - search for the term anywhere, not just at the start of a line.
|
||||
--help - show this help message
|
||||
--zsh-help-debug - print out the regex search choosenq instead of searching
|
||||
Looks up things in the zsh documentation. --all must come after --zsh-help-debug
|
||||
if used together.
|
||||
Uses less as the pager. Press 'n' to search forward 'N' to search backwards.
|
||||
Case is ignored unless capital letters appear in the search term.
|
||||
EOF
|
||||
)"
|
||||
#function zsh-help {
|
||||
function _zsh-help-join { # Joins the arguments into a string delimited by $separator
|
||||
local separator=$1;
|
||||
local arr=$*;
|
||||
arr=${arr:${#separator}+1}; # < Line needed so result doesn't start with
|
||||
arr=${arr// /$separator}; # a separator.
|
||||
<<<$arr
|
||||
}
|
||||
local case='-i'; local section='ZSHALL'; local debug=''; local pattern=''
|
||||
function _zsh-help-try-query {
|
||||
local case="$1"; local pattern="$2"; local i=''
|
||||
local array=( ZSHBUILTINS ZSHALL ZSHMODULES )
|
||||
for i in ${array}; do
|
||||
if [[ ${debug} ]]; then printf "Looking in %s for: %s %s\n" "${i}" "${case}" "${pattern}" 1>&2; fi
|
||||
if man --pager='' ${i} | grep -E ${case} "${pattern}" > /dev/null; then
|
||||
printf "%s" "${i}"; return 0;
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
# By default search only things at start of line
|
||||
local first_prefix='^'
|
||||
local prefix='^\s*'
|
||||
if [[ ${1} == '--zsh-help-debug' ]]; then
|
||||
shift; debug=1
|
||||
fi
|
||||
if [[ ${1} == "--all" ]]; then
|
||||
shift; first_prefix='' # We're searching everything, so remove the prefix
|
||||
fi
|
||||
if [[ $# < 1 || $1 == "--help" ]]; then
|
||||
printf "%s\n" "${usage}"
|
||||
unfunction _zsh-help-join; unfunction _zsh-help-try-query; # unfunction so it's not in the global scope
|
||||
return 1
|
||||
fi
|
||||
if [[ ${1} == "test" && $# == 1 ]]; then
|
||||
case=''
|
||||
pattern='^CONDITIONAL EXPRESSIONS$'
|
||||
elif [[ ($1 == "-eq" || $1 == "-ne" || $1 == "-lt" || $1 == "-gt" || $1 == "-le" || $1 == "-ge") && $# == 1 ]]; then
|
||||
case=''
|
||||
pattern="${prefix}exp1\s+${1}\s+exp2"
|
||||
elif [[ $1 == 'zstyle' ]]; then
|
||||
pattern=$(_zsh-help-join '\s+' "$@")
|
||||
section=ZSHMODULES
|
||||
fi
|
||||
# If it wasn't one of the special-cased things, check ZSHBUILTINS first. If
|
||||
# not found there, we will search ZSHALL
|
||||
if [[ ${pattern} == "" ]]; then
|
||||
pattern="$(_zsh-help-join '\s+' "$@")"
|
||||
# search for sections at the start of the man page first
|
||||
section=$(_zsh-help-try-query "${case}" "${first_prefix}${pattern}")
|
||||
# If it exists there, keep ZSHBUILTINS as the section
|
||||
if (( $? == 0 )); then
|
||||
pattern="${first_prefix}${pattern}"
|
||||
elif [[ "${prefix}" ]]; then
|
||||
# if not found, search for the term preceeded by whitetext
|
||||
section=$(_zsh-help-try-query "${case}" "${prefix}${pattern}")
|
||||
if (( $? == 0 )); then
|
||||
pattern="${prefix}${pattern}"
|
||||
else
|
||||
pattern=""
|
||||
fi
|
||||
fi
|
||||
if [[ ! ${pattern} ]]; then # Otherwise we use zshall
|
||||
printf "Can't find term\n" 2>&1
|
||||
unfunction _zsh-help-join; unfunction _zsh-help-try-query; # unfunction so it's not in the global scope
|
||||
return 1;
|
||||
fi
|
||||
fi
|
||||
local command="man --pager=\"less ${case} -p '${pattern}'\" \"${section}\""
|
||||
if [[ ${debug} ]]; then
|
||||
printf "\nFinal search term is:\n"; printf "%s\n" "${command}";
|
||||
else
|
||||
eval $command
|
||||
fi
|
||||
local rtrn=$?
|
||||
unfunction _zsh-help-join; unfunction _zsh-help-try-query; # unfunction so it's not in the global scope
|
||||
return $?
|
||||
#}
|
||||
Reference in New Issue
Block a user