1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-05-20 02:43:23 -07:00
rc/home/zshrc

172 lines
4.9 KiB
Bash
Raw Normal View History

2013-06-28 05:22:14 -07:00
setopt extended_glob
fpath=(~/sh $fpath)
function {
local f
for f in ~/sh/^([_.]*)(N^/:t); do
autoload -Uz $f
done
zsc() {
local s=$1; shift
zstyle ':completion:*'$s $@
}
zsc '*:default' list-colors ''
zsc '*' completer _complete _ignored _match _correct _approximate _prefix
zsc '*:approximate:*' max-errors 'reply=($((($#PREFIX+$#SUFFIX)/3)))'
#zsc '*:corrections' format '%B%d (errors %e)%b'
zsc '*:default' list-prompt '%S%M matches%s'
zsc '*:default' menu select=0
zsc '*' ignore-parents parent pwd
zsc '*' ignored-patterns '*?.sw[po]' '*?.pyc' '__pycache__'
zsc '*:*:rm:*:*' ignored-patterns
# matching: try exact, case insensitive, then partial word completion.
# ** for recursive, i think
zsc '*' matcher-list 'm:{[:lower:]}={[:upper:]}' 'r:|[._-]=** r:|=**'
# caching, for huge lists eg. package managers
zsc '*' use-cache on
zsc '*' cache-path ~/.zsh/cache
# when listing completions, show type names and group by them
zsc '*:descriptions' format "$fg_bold[black]» %d$reset_color"
zsc '*' group-name ''
}
autoload -Uz compinit
compinit
HISTFILE=~/.histfile
2014-09-07 20:55:42 -07:00
HISTSIZE=16384
SAVEHIST=16384
2013-06-28 05:22:14 -07:00
function {
local -a opts
opts=( no_beep
append_history share_history # across sessions
hist_expire_dups_first # sharing/appending will result in dups
hist_ignore_dups # don't push lines identical to the previous
2014-11-12 20:36:15 -08:00
hist_ignore_space # don't push lines beginning with spaces
2013-06-28 05:22:14 -07:00
auto_cd # exec a dir to cd
2013-07-09 20:27:19 -07:00
auto_pushd # cd acts as pushd
2013-06-28 05:22:14 -07:00
no_match # error on bad tab-complete
check_jobs notify # automatic job reporting
chase_links # cd into link resolves link
complete_aliases # allow original command completion within alias
complete_in_word # enable tab completion when cursor between words
rc_quotes # 'you''re dumb' like "you're dumb"
2013-07-01 02:22:36 -07:00
brace_ccl # for character ranges like {a-z}
2014-11-12 20:36:15 -08:00
ksh_typeset # treat `local x=$(cmd)` and `x=$(cmd)` the same
2013-06-28 05:22:14 -07:00
)
setopt "${opts[@]}"
unsetopt rm_star_silent rm_star_wait # yolo
}
2014-03-30 23:46:55 -07:00
autoload -U zmv
zmodload zsh/mathfunc
autoload -Uz zcalc
2013-07-09 20:27:19 -07:00
DIRSTACKSIZE=24
dirprev() {
pushd -q +1
zle reset-prompt
precmd
}
dirnext() {
pushd -q -0
zle reset-prompt
precmd
}
dirup() {
cd ..
zle reset-prompt
precmd
}
dirview() {
# TODO: print under prompt if possible,
# truncate and columnize
print
dirs -v
zle reset-prompt
}
for x (dirprev dirnext dirup dirview) zle -N $x
2013-06-28 05:22:14 -07:00
bindkey -e # emacs-style keybinds
2015-03-05 12:08:52 -08:00
# oh thank god: http://blog.samsonis.me/2013/12/bash-like-history-search-functionality-for-zsh/
autoload history-search-end
zle -N history-beginning-search-backward-end history-search-end
zle -N history-beginning-search-forward-end history-search-end
bindkey '^[[A' history-beginning-search-backward-end # up
bindkey '^[[B' history-beginning-search-forward-end # down
2015-03-30 21:42:01 -07:00
bindkey '^[OA' history-beginning-search-backward-end # up
bindkey '^[OB' history-beginning-search-forward-end # down
2015-03-05 12:08:52 -08:00
2015-05-30 14:06:31 -07:00
bindkey '^[[3~' delete-char
2013-06-28 05:22:14 -07:00
bindkey ';5D' emacs-backward-word # ctrl+left
bindkey ';5C' emacs-forward-word # ctrl+right
2013-07-09 20:27:19 -07:00
bindkey ';3D' dirprev # alt+left
bindkey ';3C' dirnext # alt+right
bindkey ';3A' dirup # alt+up
bindkey ';3B' dirview # alt+down
2013-06-28 05:22:14 -07:00
# we type a space (and delete it afterwards) to force ^Y to yank from ^U
2013-07-09 20:27:19 -07:00
#bindkey -s ';3A' ' ^Ucd ..^M^Y^H' # alt+up
2013-06-28 05:22:14 -07:00
bindkey -s '^[s' '^Asudo ^E' # alt+s
autoload edit-command-line
zle -N edit-command-line # new widget of the same function name
bindkey '^Xe' edit-command-line # ctrl+x -> e
2014-03-14 17:04:46 -07:00
. ~/.-shrc
2013-06-28 05:22:14 -07:00
2015-04-06 12:12:06 -07:00
alias -g OMFG="1>/dev/null"
2013-06-28 05:22:14 -07:00
alias -g STFU="2>/dev/null"
2016-08-27 23:45:42 -07:00
alias -g WHOA='${whoa[@]}'
2013-06-28 05:22:14 -07:00
2016-10-10 08:40:26 -07:00
wipe() {
clear
clear # twice because mintty is weird
echo "\e[30m\e[107m"
printf "*%.0s" {1..$COLUMNS}
echo "\e[0m\n"
}
2016-09-12 02:17:35 -07:00
2013-06-29 11:47:01 -07:00
for x in ack cd cp ebuild gcc gist grep ln man mkdir mv rm
2013-07-01 18:05:17 -07:00
alias $x="nocorrect $x"
2016-04-06 09:47:53 -07:00
for x in arith hex curl fc find ftp history let locate rsync scp sftp wget twitch hitbox yt
2013-07-01 18:05:17 -07:00
alias $x="noglob $x"
2016-12-09 17:19:28 -08:00
unset x
2013-06-28 05:22:14 -07:00
2017-01-30 15:36:23 -08:00
alias sc="~/sh/sc"
2013-06-28 05:22:14 -07:00
if [[ "$TERM" = xterm* ]]; then
2013-10-20 06:22:26 -07:00
precmd() { print -Pn "\e]2;%M: %~\a" }
2013-06-28 05:22:14 -07:00
fi
# note: zsh adds a % symbol to newline-less output, so bash prompt is overkill
2015-04-06 17:10:48 -07:00
function {
local good='green'
2016-01-01 20:23:33 -08:00
[[ "${(L)HOST}" == "banshee" ]] && good='cyan'
[[ "${(L)HOST}" == "spectre" ]] && good='white'
[[ "${(L)HOST}" == "wraith" ]] && good='yellow'
2015-04-06 17:10:48 -07:00
PROMPT='%{'$'\e''[10m%}%b%(?.%K{'"$good"'}.%K{red})%15F%#%f%k '
RPROMPT='%8F%h%b'
}
2013-06-28 05:22:14 -07:00
reload() {
2013-07-01 18:05:17 -07:00
# This doesn't seem to help with _vim_files errors, ehh
# you wanna rm .zcompdump then exit, that's why
cd ~
autoload -U zrecompile
[ -f .zshrc ] && zrecompile -p .zshrc
rm -f .zcompdump
[ -f .zshrc.zwc.old ] && rm -f .zshrc.zwc.old
[ -f .zcompdump.zwc.old ] && rm -f .zcompdump.zwc.old
exec zsh # reload shell, inheriting environment
2013-06-28 05:22:14 -07:00
}
2013-06-29 11:47:01 -07:00
2016-06-27 04:31:37 -07:00
[ -e "/home/$USER/opt/local/bin/torch-activate" ] && \
. "/home/$USER/opt/local/bin/torch-activate"