doot doot

This commit is contained in:
LinlyBoi
2022-12-01 22:29:35 +02:00
parent 8035032c93
commit 9888691dd7
4 changed files with 398 additions and 0 deletions

141
dot_sh_aliases Normal file
View File

@@ -0,0 +1,141 @@
alias ebuild='nocorrect ebuild'
alias gist='nocorrect gist'
alias heroku='nocorrect heroku'
alias hpodder='nocorrect hpodder'
alias man='nocorrect man'
alias mkdir='nocorrect mkdir'
alias mv='nocorrect mv'
alias mysql='nocorrect mysql'
alias sudo='nocorrect sudo'
setopt correct_all
setopt auto_pushd
setopt pushd_ignore_dups
setopt pushdminus
setopt auto_cd
setopt multios
alias -g ...='../..'
alias -g ....='../../..'
alias -g .....='../../../..'
alias -g ......='../../../../..'
alias -- -='cd -'
alias l='ls -lah'
alias ls="ls -F --color=always"
alias ll="ls -lh"
alias la="ls -lAh"
alias lsr="ls -lSr"
alias grep="grep --color=always ${GREP_OPTIONS}"
alias mv="mv -i"
alias ncdu="ncdu --color=dark"
alias monitor="tmux new -A -s monitor"
alias ':q'='exit'
alias engage="play -n -c1 synth whitenoise band -n 100 20 band -n 50 20 gain +25 fade h 1 864000 1"
alias engage-high="play -c2 -n synth whitenoise band -n 100 24 band -n 300 100 gain +20"
alias astyle-c="astyle -t4 -L -m2 -f -p -U -k3 -W3 --brackets=stroustrup -j -O -xC80 -z2"
if [[ -x "$(which pacaur)" ]]; then
upgrade() {
pacaur -Syu "$@"
}
elif [[ -x "$(which trizen)" ]]; then
upgrade() {
trizen -Syu "$@"
}
elif [[ -x "$(which pacman)" ]]; then
upgrade() {
sudo pacman -Syu "$@"
}
fi
# Keybinds
# emacs mode
bindkey -e
bindkey '^r' history-incremental-search-backward
if [[ "${terminfo[kpp]}" != "" ]]; then
bindkey "${terminfo[kpp]}" up-line-or-history # [PageUp]
fi
if [[ "${terminfo[knp]}" != "" ]]; then
bindkey "${terminfo[knp]}" down-line-or-history # [PageDown]
fi
# [Up-Arrow]
if [[ "${terminfo[kcuu1]}" != "" ]]; then
if typeset -f history-substring-search-up > /dev/null; then
bindkey "${terminfo[kcuu1]}" history-substring-search-up
elif typeset -f directory-history-search-backward > /dev/null; then
zle -N directory-history-search-backward
bindkey "${terminfo[kcuu1]}" directory-history-search-backward
else
autoload -U up-line-or-beginning-search
zle -N up-line-or-beginning-search
bindkey "${terminfo[kcuu1]}" up-line-or-beginning-search
fi
fi
bindkey "^[[A" history-substring-search-up
# [Down-Arrow]
if [[ "${terminfo[kcud1]}" != "" ]]; then
if typeset -f history-substring-search-down > /dev/null; then
bindkey "${terminfo[kcud1]}" history-substring-search-down
elif typeset -f directory-history-search-forward > /dev/null; then
zle -N directory-history-search-forward
bindkey "${terminfo[kcud1]}" directory-history-search-forward
else
autoload -U down-line-or-beginning-search
zle -N down-line-or-beginning-search
bindkey "${terminfo[kcud1]}" down-line-or-beginning-search
fi
fi
bindkey "^[[B" history-substring-search-down
if [[ "${terminfo[khome]}" != "" ]]; then
bindkey "${terminfo[khome]}" beginning-of-line
fi
if [[ "${terminfo[kend]}" != "" ]]; then
bindkey "${terminfo[kend]}" end-of-line
fi
bindkey '^[[1;5C' forward-word # [Ctrl-RightArrow]
bindkey '^[[1;5D' backward-word # [Ctrl-LeftArrow]
if [[ "${terminfo[kcbt]}" != "" ]]; then
bindkey "${terminfo[kcbt]}" reverse-menu-complete # [Shift-Tab]
fi
bindkey '^?' backward-delete-char # [Backspace]
if [[ "${terminfo[kdch1]}" != "" ]]; then
bindkey "${terminfo[kdch1]}" delete-char # [Delete]
else
bindkey "^[[3~" delete-char
bindkey "^[3;5~" delete-char
bindkey "\e[3~" delete-char
fi
autoload -U edit-command-line
zle -N edit-command-line
bindkey '\C-x\C-e' edit-command-line
# file rename magick
bindkey "^[m" copy-prev-shell-word
# Fix weird sequence that rxvt produces
bindkey -s '^[[Z' '\t'
# vim:ft=zsh
alias rsync-mv='rsync -aiv --no-g --remove-source-files'
alias spotify-light=~/scripts/spot-light.sh
alias spotify-dark=~/scripts/spot-dark.sh
alias yt-mp3='yt-dlp -x -f bestaudio'
alias work='tmux attach-session -t work'
alias tmux-monitor='tmux attach-session -t monitor'

34
dot_sh_colorize Normal file
View File

@@ -0,0 +1,34 @@
autoload -U colors && colors
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:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=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:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=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:*.webp=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:'
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
# {{{ Manual pages
# - colorize, since man-db fails to do so
export LESS_TERMCAP_mb=$'\E[01;31m' # begin blinking
export LESS_TERMCAP_md=$'\E[01;31m' # begin bold
export LESS_TERMCAP_me=$'\E[0m' # end mode
export LESS_TERMCAP_se=$'\E[0m' # end standout-mode
export LESS_TERMCAP_so=$'\E[1;33;40m' # begin standout-mode - info box
export LESS_TERMCAP_ue=$'\E[0m' # end underline
export LESS_TERMCAP_us=$'\E[1;32m' # begin underline
# }}}
# Less needs this switch to pass color sequences and so forth
export LESS='-R'
# GREP has deprecated it and complains constantly if it's set, interfering with aliases
unset GREP_OPTIONS
setopt prompt_subst
PROMPT=$'%{\e[0;34m%}%B[%b%{\e[0m%}%{\e[1;32m%}%n%{\e[1;30m%}@%{\e[0m%}%{\e[0;36m%}%m%{\e[0;34m%}%B]―[%(?|%{\e[1;32m%}$|%{\e[1;35m%}$)%{\e[0;34m%}%B]%}%b%{\e[0m%} '
RPROMPT=$'%{\e[0;34m%}%B[%b%{\e[1;37m%}%(5~|%-2~/…/%2~|%~)%{\e[0;34m%}%B]%b%{\e[0m%}─%{\e[0;34m%}<$(git_prompt_info)>%{\e[0m%}'
PS2=$' %{\e[0;34m%}%B>%{\e[0m%}%b%} '
RPS2=$'%{\e[0;34m%}%B%_%{\e[0m%}%b%} '
# vim:ft=zsh

196
dot_sh_functions Normal file
View File

@@ -0,0 +1,196 @@
autoload -U terminfo
autoload -U add-zsh-hook
function swap_hogs() {
grep --color=never -n VmSwap /proc/*/status | sort -n -k2 | awk '/proc\/([0-9]+)\/status/ { split($1, p, "/"); fn="/proc/"p[3]"/status"; getline s < fn; split(s, n, ":"); sub(/^[ \t\r\n]+/, "", n[2]); print n[2] " (" p[3] ") " $2 "kB" }'
}
# ssh-agent {{{
# typeset _ssh_env_cache
# _ssh_env_cache="$HOME/.ssh/environment-${HOST/.*/}"
# function _start_ssh_agent() {
# ssh-agent -s -t 4h | sed 's/^echo/#echo/' >! "$_ssh_env_cache"
#
# for ident in $HOME/.ssh/*.pub; do
# ssh-add ${ident/.pub/}
# done
# }
#
# if [[ -n "$SSH_AUTH_SOCK" ]]; then
# [[ -L "$SSH_AUTH_SOCK" ]] || ln -snf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USER-screen
# elif [[ -f "$_ssh_env_cache" ]]; then
# . "$_ssh_env_cache" > /dev/null
# pgrep ssh-agent | grep -q $SSH_AGENT_PID || {
# _start_ssh_agent
# }
# else
# _start_ssh_agent
# fi
#
# unset _ssh_env_cache
# }}}
# battery/UPS {{{
if [[ -x "$(whence apcaccess)" ]]; then
function battery_pct_remaining() {
echo $(apcaccess | fgrep BCHARGE | cut -d: -f2 | cut -d\ -f2)
}
function battery_time_remaining() {
echo $(apcaccess | fgrep TIMELEFT | cut -d: -f2)
}
function battery_pct_prompt() {
b=$(battery_pct_remaining)
if [[ $b -gt 60 ]]; then
color=green
elif [[ $b -gt 25 ]]; then
color=yellow
else
color=red
fi
echo "%{$fg[$color]%}$(battery_pct_remaining)%%%{$reset_color%}"
}
else
function battery_pct_remaining() {
}
function battery_time_remaining() {
}
function battery_pct_prompt() {
}
fi
# }}}
# git prompt {{{
function git_prompt_info() {
local ref
ref=$(command git symbolic-ref HEAD 2>/dev/null) || \
ref=$(command git rev-parse --short HEAD 2>/dev/null) || return 0
echo "git:(${ref#refs/heads/}$(parse_git_dirty))"
}
function parse_git_dirty() {
local STATUS=''
local -a FLAGS
FLAGS=('--porcelain' '--untracked-files=no')
STATUS=$(command git status ${FLAGS} 2>/dev/null | tail -n1)
if [[ -n "$STATUS" ]]; then
# dirty
echo -e " %{\e[1;35m%}%{⧱%G%}%{\e[0;34m%}"
else
# clean
echo ""
fi
}
# }}}
function title {
emulate -L zsh
[[ "$EMACS" == *term* ]] && return
: ${2=$1}
case "$TERM" in
cygwin|xterm*|putty*|rxvt*|ansi)
print -Pn "\e]2;$2:q\a" # window
print -Pn "\e]1;$1:q\a" # tab
;;
screen*)
print -Pn "\ek$1:q\e\\"
;;
*)
if [[ -n "$terminfo[fsl]" ]] && [[ -n "$terminfo[tsl]" ]]; then
echoti tsl
print -Pn "$1"
echoti fsl
fi
;;
esac
}
function title_precmd {
title "%15<…<%~%<<" "%n@%m: %~"
}
add-zsh-hook precmd title_precmd
function title_preexec {
setopt extended_glob
local CMD=${1[(wr)^(*=*|sudo|ssh|mosh|rake|-*)]:gs/%/%%}
local LINE="${2:gs/%/%%}"
title "$CMD" "%100>…>$LINE%<<"
}
add-zsh-hook preexec title_preexec
function md() {
mkdir -p $1
cd $1
}
function cdl() {
pushd "$1" && ls -CF --color=always "${@:2}"
}
function dur() {
ls -lSr -hd "${1:-.}"/*; du -chd2 -- "${1:-.}"/ | sort -h; df -h "$@"
}
alias rcp="rsync -aiPvh"
alias rup="rsync -aiPvhu"
function rmv() {
local -a flags=(${(M)@:#-*})
local -a parms=(${@:#-*})
shift $parms
local src="${parms[1]}"
local dest="${parms[2]}"
rsync -aiPvhu --remove-source-files --prune-empty-dirs "${(@)flags}" "$parms"
if [[ -d "$src" ]] ; then
find "$src" -type d -empty -delete
fi
}
function unpack() {
filename="$1"
echo "$filename"
shift
basefilename="$(basename "${filename}")"
dirname="${basefilename%.*}"
echo "$dirname"
mkdir -p "$dirname"
7z x -o"$dirname" "$filename"
}
function unpack-mv() {
unpack "$1"
mv "$@"
}
cp-lower() {
local -a from=()
local to
local CMD=""
local verbose
while [[ $# -gt 1 ]]; do
case "$1" in
-n)
CMD=echo
echo '.-n' "$@"
;;
-v)
verbose=-v
echo '.-v' "$@"
;;
*)
if [[ -e "$1" ]]; then
from+=("$to")
to="$1"
fi
echo "$@"
;;
esac
shift
done
echo ${(@)from}
echo $to
}
# vim:ft=zsh

27
dot_sh_paths Normal file
View File

@@ -0,0 +1,27 @@
HISTFILE=~/.histfile
export PAGER="/usr/bin/less"
export MANPAGER="/usr/bin/less"
export SQUEAK_IMAGE=$HOME/.squeak/squeak.image
export GOPATH=$HOME/.local/gocode
export INCLUDEOS_PREFIX=~/.local/includeos
export PATH="$PATH:$HOME/.local/bin:$HOME/.cabal/bin:$HOME/.local/gocode/bin"
if [ -e ~/.local/includeos/bin ]; then
export PATH="$PATH:${HOME}/.local/includeos/bin"
fi
if [ -e ~/.roswell/bin ]; then
export PATH="$PATH:${HOME}/.roswell/bin"
fi
if [ -e ~/.local/share/x-tools ]; then
for xtool in $HOME/.local/share/x-tools/*-*/bin
do
export PATH="$PATH:${xtool}"
done
fi
#export PATH="/usr/lib/colorgcc/bin:${PATH}"
# vim ft=zsh