dgy
/
hexagons
Archived
1
0
Fork 0
This repository has been archived on 2021-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
hexagons/.zshrc

864 lines
31 KiB
Bash

# -*- mode: shell-script -*-
# vim:ft=zsh
export PATH="/usr/lib/ccache/bin/:$PATH"
# Completion styles {{{
zstyle ':completion:*' auto-description '%d'
zstyle ':completion:*' completer _oldlist _expand _complete _match _approximate _prefix
zstyle ':completion:*' completions 1
zstyle ':completion:*' expand prefix suffix
zstyle ':completion:*' file-sort modification
zstyle ':completion:*' format $'\n%BCompleting %F{magenta}%d%f%b'
zstyle ':completion:*' glob 1
zstyle ':completion:*' group-name ''
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
zstyle ':completion:*' list-suffixes true
zstyle ':completion:*' list-rows-first true
zstyle ':completion:*' matcher-list 'm:{[:lower:]}={[:upper:]} m:{[:lower:][:upper:]}={[:upper:][:lower:]}' 'm:{[:lower:]}={[:upper:]} m:{[:lower:][:upper:]}={[:upper:][:lower:]} l:|=* r:|=*' 'm:{[:lower:]}={[:upper:]} m:{[:lower:][:upper:]}={[:upper:][:lower:]} l:|=* r:|=*' 'm:{[:lower:]}={[:upper:]} m:{[:lower:][:upper:]}={[:upper:][:lower:]} l:|=* r:|=*'
zstyle ':completion:*' match-original both
zstyle ':completion:*' max-errors 1 numeric
zstyle ':completion:*' menu select=1 eval "$(dircolors -b $HOME/.config/zstuff/LS_COLORS)"
zstyle ':completion:*' original true
zstyle ':completion:*' old-list _complete _approximate _expand _correct
zstyle ':completion:*' old-menu false
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
zstyle ':completion:*' substitute 1
zstyle ':completion:*' verbose true
zstyle ':completion:*' word true
zstyle :compinstall filename '/home/deadguy/.zshrc'
zstyle ':completion:*' accept-exact '*(N)'
zstyle ':completion::complete:*' use-cache 1
zstyle ':completion::complete:*' cache-path "$HOME/.config/zstuff/cache"
zstyle ':completion:*:complete:-command-::commands' ignored-patterns '*\~'
zstyle ':completion:*:builtins' list-colors '=*=1;38;5;142'
zstyle ':completion:*:aliases' list-colors '=*=2;38;5;128'
zstyle ':completion:*:options' list-colors '=^(-- *)=34'
zstyle ':completion:*' list-dirs-first true
zstyle ':completion:*' special-dirs true
zstyle -e ':completion:*' special-dirs '[[ $PREFIX = (../)#(|.|..) ]] && reply=(..)'
zstyle ':completion:*' rehash true
zstyle ':completion:*:descriptions' format '%F{yellow}%B--- %d%b --- %f'
zstyle ':completion:*:warnings' format 'No matches for: %B%F{cyan}%d%f%b'
zstyle ':completion:*:corrections' format '%d %B(%F{red}errors: %e%f)%b'
zstyle ':completion:*:messages' format ' %F{purple} -- %d --%f'
zstyle ':completion:*:options' description 'yes'
zstyle ':completion:*:processes' command 'ps -au $USER -o pid,stat,%cpu,%mem,cputime,command'
zstyle ':completion:*:processes-names' command 'ps c -u ${USER} -o command | uniq'
zstyle ':completion:*:killall:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'
zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters
zstyle ':completion:*:sudo:*' command-path /usr/local/sbin \
/usr/local/bin \
/usr/sbin \
/usr/bin \
/sbin \
/bin
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;36=0=01'
zstyle ':completion:*:*:kill:*' menu yes select
zstyle ':completion:*:*:kill:*' force-list always
zstyle ':completion:*:*:kill:*' insert-ids single
zstyle ':completion:*:manuals' separate-sections true
zstyle ':completion:*:manuals.(^1*)' insert-sections true
zstyle ':completion:*:*:cd:*:directory-stack' force-list always
zstyle ':completion:*:*:cd:*:directory-stack' menu yes select
zstyle ':completion:*:*:*:*:users' list-colors '=*=$color[green]=$color[red]'
zstyle ':completion:*:*:*:users' ignored-patterns \
adm amanda apache avahi beaglidx bin cacti canna clamav daemon \
dbus distcache dovecot fax ftp games gdm gkrellmd gopher \
hacluster haldaemon halt hsqldb ident junkbust ldap lp mail \
mailman mailnull mldonkey mysql nagios \
named netdump news nfsnobody nobody nscd ntp nut nx openvpn \
operator pcap postfix postgres privoxy pulse pvm quagga radvd \
rpc rpcuser rpm shutdown squid sshd sync uucp vcsa xfs '_*'
# prompt formats
LISTPROMPT='View all items? '
# prompt for correct
SPROMPT="Correct to %r? "
# }}}
# Zsh addons {{{
autoload -Uz compinit
autoload -Uz colors
zmodload zsh/complist
compinit
colors
autoload -Uz zmv
autoload -Uz zcalc
autoload -Uz run-help
autoload -Uz run-help-git
autoload -Uz surround
zle -N delete-surround surround
zle -N add-surround surround
zle -N change-surround surround
bindkey -a cs change-surround
bindkey -a ds delete-surround
bindkey -a ys add-surround
bindkey -M visual S add-surround
autoload -U select-bracketed
autoload -U select-quoted
zle -N select-quoted
zle -N select-bracketed
for km in visual viopp; do
bindkey -M $km -- '-' vi-up-line-or-history
for c in {a,i}${(s..)^:-\'\"\`\|,./:;-=+@}; do
bindkey -M $km $c select-quoted
done
for c in {a,i}${(s..)^:-'()[]{}<>bB'}; do
bindkey -M $km $c select-bracketed
done
done
# Zcalc stuff
function __calc_plugin {
zcalc -e "$*"
}
aliases[calc]='noglob __calc_plugin'
aliases[=]='noglob __calc_plugin'
#}}}za
# Options {{{
export HISTIGNORE="ls:cd:cd -:pwd:exit:date:* --help"
HISTFILE=~/.config/zstuff/histfile
HISTSIZE=10000
SAVEHIST=50000
unsetopt beep
unsetopt nomatch
unsetopt menucomplete # show a menu instead
unsetopt flowcontrol
unsetopt correctall # turn off the infernal correctall for filenames
setopt completealiases # autocompletion CLI switches for aliases
setopt autocd
setopt autoresume
setopt equals # Enable "=command" feature
setopt magic_equal_subst # Enable completion in "--option=arg"
setopt prompt_subst # allow expansion in prompts
setopt brace_ccl # Enable brace expansion function
setopt appendhistory # dont create the hist file over and over
setopt hist_ignore_all_dups # If a new command is a duplicate, remove the older one
setopt hist_reduce_blanks # remove blank spaces from history file
setopt hist_ignore_space # Ignore add history if space
setopt extended_history # Save time stamp
setopt hist_expand # Expand history
setopt inc_append_history # Share zsh histories
setopt share_history
setopt mark_dirs # Add "/" if completes directory
setopt RM_STAR_WAIT # if you do a 'rm *', Zsh will give you a sanity check!
setopt interactivecomments # bash style comments
setopt correct # Auto correct mistakes
setopt long_list_jobs # Better jobs
setopt glob_complete # Expand globs when completion
setopt extendedglob # Extended globbing
setopt nocaseglob # Case insensitive globbing
setopt nocheckjobs # Dont warn about running processes when exiting
setopt numericglobsort # Sort filenames numerically when it makes sense
setopt nohup # Dont kill processes when exiting
setopt printeightbit # For multi byte
setopt auto_list # List completion
setopt auto_param_slash
setopt auto_param_keys
setopt auto_name_dirs
setopt always_to_end
setopt complete_in_word
setopt list_types # List like "ls -F"
bindkey -v
eval $( dircolors -b $HOME/.config/zstuff/LS_COLORS )
export EDITOR="nvim"
export VISUAL="mousepad"
export BROWSER="firefox"
HELPDIR=/usr/share/zsh/$ZSH_VERSION/help
COMPLETION_WAITING_DOTS="true" # if you want red dots to be displayed while waiting for completion
if [[ $COMPLETION_WAITING_DOTS = true ]]; then
expand-or-complete-with-dots() {
# toggle line-wrapping off and back on again
[[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti rmam
print -Pn "%{%F{red}......%f%}"
[[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti smam
zle expand-or-complete
zle redisplay
}
zle -N expand-or-complete-with-dots
bindkey "^I" expand-or-complete-with-dots
fi
# }}}
# Zplugin {{{
local -A ZPLGM
ZPLGM[BIN_DIR]="$HOME/.config/zstuff/zplugin/bin"
ZPLGM[HOME_DIR]="$HOME/.config/zstuff/zplugin"
ZPLGM[PLUGINS_DIR]="$HOME/.config/zstuff/zplugin/plugins"
ZPLGM[COMPLETIONS_DIR]="$HOME/.config/zstuff/zplugin/root_completions"
ZPLGM[SNIPPETS_DIR]="$HOME/.config/zstuff/zplugin/snippets"
source ~/.config/zstuff/zplugin/bin/zplugin.zsh
zplugin snippet OMZ::plugins/git/git.plugin.zsh
zplugin cdclear -q # <- forget completions provided up to this moment
zplugin snippet 'https://github.com/junegunn/fzf/blob/master/shell/completion.zsh'
zplugin snippet 'https://github.com/junegunn/fzf/blob/master/shell/key-bindings.zsh'
zplugin light hlissner/zsh-autopair
zplugin load zdharma history-search-multi-word
zplugin load zdharma/fast-syntax-highlighting
zplugin light djui/alias-tips
zplugin light peterhurford/up.zsh
zplugin ice blockf
zplugin light zsh-users/zsh-completions
# }}}
# History search multi-word {{{
zstyle ":plugin:history-search-multi-word" clear-on-cancel "yes"
zstyle ":history-search-multi-word" page-size "LINES/2"
# }}}
# fzf {{{
export FZF_DEFAULT_OPTS='
--extended
--height 40%
--reverse
--ansi
--color fg:-1,bg:-1,hl:33,fg+:254,bg+:235,hl+:33
--color info:136,prompt:136,pointer:230,marker:230,spinner:166
'
export FZF_COMPLETION_OPTS='+c -x'
export FZF_DEFAULT_COMMAND='ag -l -g ""'
_fzf_compgen_path() {
fd --hidden --follow --exclude ".git" . "$1"
}
_fzf_compgen_dir() {
fd --type d --hidden --follow --exclude ".git" . "$1"
}
export FZF_COMPLETION_TRIGGER='++'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_CTRL_T_OPTS="--select-1 --exit-0 --preview '(highlight -O ansi -l {} 2> /dev/null || cat {} || tree -C {}) 2> /dev/null | head -200'"
export FZF_CTRL_R_OPTS="--preview 'echo {}' --preview-window down:3:hidden:wrap --bind '?:toggle-preview'"
export FZF_ALT_C_OPTS="--select-1 --exit-0 --preview 'tree -C {} | head -200'"
# vf - fuzzy open with vim from anywhere
vf() {
local files
files=(${(f)"$(locate -Ai -0 $@ | grep -z -vE '~$' | fzf --read0 -0 -1 -m)"})
if [[ -n $files ]]
then
nvim -- $files
print -l $files[1]
fi
}
# fkill - kill process using fzf.
function fkill {
local pid
pid=$( pstree -T -p -c | fzf -e -m -i +s --reverse --margin=4%,1%,1%,2% --inline-info --header="TAB to (un)select. ENTER to kill selected process(es). ESC or CTRL+C to quit." --prompt='Enter string to filter list of processes > ' | awk '{print $NF}' | awk -F '(' '{print $NF}' | awk -F ')' '{print $1}' )
if [ "x$pid" != "x" ]
then
echo "$pid" | xargs kill -${1:-9}
fi
}
# fkill - kill process using fzf.
function fkill2 {
local pid
pid=$( pstree -T -p -a | fzf -e -m -i +s --reverse --margin=4%,1%,1%,2% --inline-info --header="TAB to (un)select. ENTER to kill selected process(es). ESC or CTRL+C to quit." --prompt='Enter string to filter list of processes > ' | awk -F ',' '{print $NF}' | awk '{print $1}' )
if [ "x$pid" != "x" ]
then
echo "$pid" | xargs kill -${1:-9}
fi
}
# }}}
# Recolor fast-syntax-highlighting {{{
FAST_HIGHLIGHT_STYLES[default]="fg=252"
FAST_HIGHLIGHT_STYLES[unknown-token]="fg=254,bold,bg=126"
FAST_HIGHLIGHT_STYLES[reserved-word]="fg=yellow,bold"
FAST_HIGHLIGHT_STYLES[alias]="fg=green,bold"
FAST_HIGHLIGHT_STYLES[suffix-alias]="fg=green"
FAST_HIGHLIGHT_STYLES[builtin]="fg=107,bold"
FAST_HIGHLIGHT_STYLES[function]="fg=84,bold"
FAST_HIGHLIGHT_STYLES[command]="fg=105,bold"
FAST_HIGHLIGHT_STYLES[precommand]="none"
FAST_HIGHLIGHT_STYLES[commandseparator]="fg=blue"
FAST_HIGHLIGHT_STYLES[hashed-command]="fg=70"
FAST_HIGHLIGHT_STYLES[path]="fg=33,underline"
FAST_HIGHLIGHT_STYLES[path_pathseparator]=""
FAST_HIGHLIGHT_STYLES[globbing]="fg=green,bold"
FAST_HIGHLIGHT_STYLES[history-expansion]="fg=192"
FAST_HIGHLIGHT_STYLES[single-hyphen-option]="fg=cyan"
FAST_HIGHLIGHT_STYLES[double-hyphen-option]="fg cyan"
FAST_HIGHLIGHT_STYLES[back-quoted-argument]="220,bold"
FAST_HIGHLIGHT_STYLES[single-quoted-argument]="fg=138"
FAST_HIGHLIGHT_STYLES[double-quoted-argument]="fg=138"
FAST_HIGHLIGHT_STYLES[dollar-quoted-argument]="fg=148"
FAST_HIGHLIGHT_STYLES[back-or-dollar-double-quoted-argument]="fg=172,bold"
FAST_HIGHLIGHT_STYLES[back-dollar-quoted-argument]="fg=244"
FAST_HIGHLIGHT_STYLES[assign]="243,bold"
FAST_HIGHLIGHT_STYLES[redirection]="none"
FAST_HIGHLIGHT_STYLES[comment]="fg=55,bold"
FAST_HIGHLIGHT_STYLES[variable]="fg=magenta"
#}}}
# Vi mode and keys {{{
# Fix backspace not working after returning from cmd mode
bindkey '^?' backward-delete-char
bindkey '^h' backward-delete-char
bindkey '^w' backward-kill-word
# Ctrl+Y is a standard in some places, and since Ctrl+R is taken...
bindkey -a u undo
bindkey -a '^y' redo
# Beginning search with arrow keys
# start typing + [Up-Arrow] - fuzzy find history forward
if [[ "${terminfo[kcuu1]}" != "" ]]; then
autoload -U up-line-or-beginning-search
zle -N up-line-or-beginning-search
bindkey "${terminfo[kcuu1]}" up-line-or-beginning-search
fi
# start typing + [Down-Arrow] - fuzzy find history backward
if [[ "${terminfo[kcud1]}" != "" ]]; then
autoload -U down-line-or-beginning-search
zle -N down-line-or-beginning-search
bindkey "${terminfo[kcud1]}" down-line-or-beginning-search
fi
if [[ "${terminfo[kcbt]}" != "" ]]; then
bindkey "${terminfo[kcbt]}" reverse-menu-complete # [Shift-Tab] - move through the completion menu backwards
fi
# file rename magick
bindkey "^[m" copy-prev-shell-word
# Better searching in command mode
bindkey -M vicmd '?' history-incremental-search-backward
bindkey -M vicmd '/' history-incremental-search-forward
bindkey -M vicmd 'k' up-line-or-beginning-search
bindkey -M vicmd 'j' down-line-or-beginning-search
bindkey '^[[7~' beginning-of-line # Home key
bindkey '^[[H' beginning-of-line # Home key
if [[ "${terminfo[khome]}" != "" ]]; then
bindkey "${terminfo[khome]}" beginning-of-line # [Home] - Go to beginning of line
fi
bindkey '^[[8~' end-of-line # End key
bindkey '^[[F' end-of-line # End key
if [[ "${terminfo[kend]}" != "" ]]; then
bindkey "${terminfo[kend]}" end-of-line # [End] - Go to end of line
fi
bindkey '^[[2~' overwrite-mode # Insert key
bindkey '^[[3~' delete-char # Delete key
bindkey '^[[C' forward-char # Right key
bindkey '^[[D' backward-char # Left key
bindkey '^[[5~' history-beginning-search-backward # Page up key
bindkey '^[[6~' history-beginning-search-forward # Page down key
# }}}
# Prompt {{{
autoload -Uz vcs_info
autoload -Uz colors && colors
precmd() { vcs_info }
function away_prompt() {
local roaming
if [[ -n $SSH_CLIENT ]] then
roaming = echo "%m "
fi
}
function user_id_prompt(){
local theuser
if [[ "$EUID" = "0" ]] || [[ "$USER" = 'root' ]]; then
theuser = echo "%{$fg[red]%}Ω "
else
theuser= echo "%{$fg[yellow]%}λ "
fi
}
if [ -n "$RANGER_LEVEL" ]; then RANGERPROMPT='(ranger )'; else RANGERPROMPT=''; fi
PROMPT="
%B%{$fg[green]%}%~%{$reset_color%}%b
%B$(away_prompt)$RANGERPROMPT$(user_id_prompt)%{$reset_color%}%b"
VI_PROMPT_BG_NORMAL="%{$bg[green]%}"
VI_PROMPT_BG_INSERT="%{$bg[blue]%}"
VI_PROMPT_FG="%{$fg[black]%}"
VI_PROMPT_AFTER="%{$reset_color%}"
function vi_prompt_normal() { echo "$VI_PROMPT_BG_NORMAL$VI_PROMPT_FG NORMAL $VI_PROMPT_AFTER" }
function vi_prompt_insert() { echo "$VI_PROMPT_BG_INSERT$VI_PROMPT_FG INSERT $VI_PROMPT_AFTER" }
zstyle ':vcs_info:*' enable git
zstyle ':vcs_info:git*:*' get-revision true
zstyle ':vcs_info:git*:*' check-for-changes true
zstyle ':vcs_info:git*' formats "%F{247}%12.12i%f %c%u %b%m"
zstyle ':vcs_info:git*' actionformats "(%a) %F{247}%12.12i%f %c%u %b%m"
zstyle ':vcs_info:git*:*' stagedstr "%{$fg[green]%}S%{$reset_color%}"
zstyle ':vcs_info:git*:*' unstagedstr "%{$fg[red]%}U%{$reset_color%}"
zstyle ':vcs_info:git*+set-message:*' hooks git-st git-st-compact git-untracked git-stash-compact
function +vi-git-st() {
local ahead behind remote
local -a gitstatus
# Are we on a remote-tracking branch?
remote=${$(git rev-parse --verify ${hook_com[branch]}@{upstream} \
--symbolic-full-name --abbrev-ref 2>/dev/null)}
if [[ -n ${remote} ]] ; then
ahead=$(git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l)
(( $ahead )) && gitstatus+=( "%{$fg[green]%}+${ahead}$%{$reset_color%}" )
behind=$(git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)
(( $behind )) && gitstatus+=( "%{$fg[red]%}-${behind}%{$reset_color%}" )
user_data[gitstatus]=${gitstatus}
fi
}
# Show the above/behind upstream counts more tersely for the compact display
function +vi-git-st-compact() {
[[ -n ${user_data[gitstatus]} ]] \
&& hook_com[misc]="${(j:/:)user_data[gitstatus]}"
}
# Show count of stashed changes
function +vi-git-stash-compact() {
local -a stashes
if [[ -s $(git rev-parse --git-dir)/refs/stash ]] ; then
stashes=$(git stash list 2>/dev/null | wc -l)
hook_com[misc]+=" s# ${stashes}"
fi
}
# Indicate if there are any untracked files present
function +vi-git-untracked() {
local untracked
#check if there's at least 1 untracked file
untracked=${$(git ls-files --exclude-standard --others | head -n 1)}
if [[ -n ${untracked} ]] ; then
hook_com[unstaged]="${hook_com[unstaged]}%{$fg[yellow]%}?%{$reset_color%}"
fi
}
function zle-keymap-select zle-line-init {
# If it's not tmux then can use normal sequences
if [[ -z "${TMUX}" ]]; then
local vicmd_seq="\e[2 q"
local viins_seq="\e[0 q"
else
# In tmux, escape sequences to pass to terminal need to be
# surrounded in a DSC sequence and double-escaped:
# ESC P tmux; {text} ESC \
local vicmd_seq="\ePtmux;\e\e[2 q\e\\"
local viins_seq="\ePtmux;\e\e[0 q\e\\"
fi
RPROMPT="%{$(echotc UP 1)%}${vcs_info_msg_0_} ${${KEYMAP/vicmd/$(vi_prompt_normal)}/(main|viins)/$(vi_prompt_insert)}%{$(echotc DO 1)%}"
zle reset-prompt
}
export KEYTIMEOUT=1 # Don't take 0.4s to change modes
zle -N zle-keymap-select # When vi mode changes
zle -N zle-line-init # When a new line starts
# }}}za
# Assorted Alias {{{
# Programs
alias gdl='gallery-dl'
alias mutt='neomutt'
alias rg='ranger'
alias pmix='ncpamixer'
alias amix='alsamixer'
alias vi='nvim'
alias vim='nvim'
alias chat='irssi'
alias play='ncmpcpp'
alias ts='transmission-remote-cli'
alias cal='calcurse'
alias _='sudo '
alias py='python '
alias py2='python2 '
alias rb='ruby '
alias ytv='youtube-viewer'
alias git='hub'
alias help='run-help'
alias p='pacui'
alias sr='sr -browser=lynx' # open in cli browser
alias surfraw='surfraw -browser=$BROWSER' # open in gui browser
alias pacman-mirrors='sudo pacman-mirrors'
alias foxdot='python -m FoxDot'
# MAXIMUM VERBOSITY YIELDS MAXIMUM RESULTS
alias chmod='chmod -v'
alias chown='chown -v'
alias mv='mv -iv'
alias rmdir='rmdir -v' # rm empty directory only
alias rm='rm -iv' # Always confirm before deleting things
alias mkdir='mkdir -pv' # Make parent directories that don't exist
alias cp="cp -aiv" # Confirm before overwriting something
alias ln='ln -iv'
alias rename='rename -v'
alias mount='mount -v | column -t'
alias umount='umount -v'
# Opinionated
alias tx='tmux -2'
alias imv='imv -sd -e inconsolata:8 -r'
alias ytdl='youtube-dl -ic'
alias ls='ls -F --color=always --group-directories-first'
alias grep='grep --color=tty -d skip'
alias sgrep='grep -R -n -H -C 5 --exclude-dir={.git,.svn,CVS} '
alias dmesg='dmesg --color=always'
alias ag="ag --one-device --color --color-line-number '0;35' --color-match '46;30' --color-path '4;36'"
alias tree='tree -CAFa -I "CVS|*.*.package|.svn|.git|.hg|node_modules|bower_components" --dirsfirst'
alias lsblk='lsblk -o "KNAME,HOTPLUG,SIZE,FSTYPE,TYPE,LABEL,MOUNTPOINT,UUID,MODEL,SERIAL"'
alias dir='dir --color=always'
alias type='type -a' # See what the command you want to run points to
alias df='df -hT --total' # Human readable, print filetype, and total
alias free='free -ht' # Human readable and total
alias du='du -d1 -h' # Human readable, max depth
alias info='info --vi-keys' # GNU info act like man command
alias inxi='inxi -Fz'
alias slop='slop --highlight --tolerance=0 --color=0.3,0.4,0.6,0.4 -f '%wx%h+%x+%y''
alias ping='ping -c 5'
alias dd="dd status=progress"
alias pacaur='pacaur --color always'
alias pacman='pacman --color always'
alias cower='cower --color=always'
# Commands
alias wpp='hsetroot -fill'
alias tis='tig status'
alias til='tig log'
alias tib='tig blame -C'
alias fuck='sudo pacman -Rns'
alias gimme='pacaur -S'
alias upd='pacaur -Syu'
alias ytw='youtube-viewer -C -D -W -f -7 --results=10'
alias hoy='calcurse -a --format-apt=" - %m (%S a %E)\n" --format-recur-apt=" - %m (%S a %E)\n"'
alias week='calcurse -r7 --format-apt=" - %m (%S a %E)\n" --format-recur-apt=" - %m (%S a %E)\n"'
alias todo='calcurse -t --format-todo "(%p) %m\n"'
alias gal='ls | imv &!'
alias vimdiff='nvim -d'
alias winclass='xprop | grep WM_CLASS' # for bspwm rules
alias path='echo -e ${PATH//:/\\n}' # Pretty-print of some PATH variables
alias compare='grep -nFxvf' # Usage: compare <file1> <file2>
alias pwn='chmod +x'
alias ta='tmux attach -t'
alias tnw='tmux new -s'
alias tls='tmux ls'
alias tk='tmux kill-session -t'
alias lst='ls -FAghoBtH --group-directories-first --dereference-command-line-symlink-to-dir --time-style=+"%d-%m-%Y %H:%M"'
alias java='java -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel'
alias disks='echo "╓───── m o u n t . p o i n t s"; echo "╙────────────────────────────────────── ─ ─ "; lsblk -a; echo ""; echo "╓───── d i s k . u s a g e"; echo "╙────────────────────────────────────── ─ ─ "; df -h;'
# Dotfiles
alias hexa='/usr/bin/git --git-dir=$HOME/hexagons/ --work-tree=$HOME'
alias hx-up='hexa add -vu'
alias hx-ls='hexa ls-files -m'
alias hx-diff='hexa diff'
alias hx-push='hexa push'
alias hx-stat='hexa status'
hx-add() { hexa add -v "$@" ;}
hx-rm() { hexa rm --cached "$@" ;}
hx-commit() { hexa commit -m "$@" ;}
# }}}
# Video {{{
ytl() { youtube-viewer -n $@ ;}
ytmp3() { youtube-dl -icw --no-cache-dir --no-call-home --restrict-filenames --extract-audio --audio-format mp3 --audio-quality 0 --prefer-ffmpeg -o "%(title)s.%(ext)s" $@ ;}
yt2mp3() { youtube-dl -icw --no-cache-dir --no-call-home --restrict-filenames -x --audio-format mp3 --audio-quality 0 --prefer-ffmpeg -o "%(title)s.%(ext)s" -f 171 "$@" ;}
gif() { ffmpeg -i "${1:?Error: no input file specified!}" "${2:-${1%.*}.gif}" -threads 0; }
ytconv() {
if [[ "$#" -lt 2 ]]; then
printf "\n %s \n" 'Usage: ytconv <image> <audio> <extension> (Extension is optional: defaults to .mkv)'
return 1
elif [[ -e "out.${3:-mkv}" ]]; then
printf "\n\033[31m%s\033[0m\n" 'Error "out.'"${3:-mkv}"'" exists!'
return 2
else
ffmpeg -loop 1 -y -i "$1" -i "$2" -c:a copy -c:v libx264 \
-strict experimental -b:a 192k -preset ultrafast -pix_fmt yuv420p -tune stillimage \
-threads 0 -shortest "out.${3:-mkv}"
fi
}
# }}}
# Pacman {{{
what() { pacaur -Ss "$1" ;} # package info
show() { pacaur -Sii "$1" ;} # package details
files() { pacman -Ql "$1" ;} # list files owned by package
explicit() { sudo pacman -D --asexplicit "$1" ;} # mark package as explicitly installed
orphans() {
pacman -Qdt
echo "Press ENTER to remove these orphaned packages or CTRL+C to cancel."
read
sudo pacman -Rsn $(pacman -Qqdt) --noconfirm
}
paclist() {
pacman -Qqettn >> ~/paketes.txt
pacman -Qqettm >> ~/paurketos.txt
}
pacfix() {
sudo rm -f /var/lib/pacman/db.lck
sudo pacman-mirrors -g
sudo pacman -Syyuu
sudo pacman -Suu
}
# }}}
source $HOME/.config/zstuff/rc/transmission.zsh
# Functions and things {{{
# Create a directory and enter it automatically
mkcd () {
case "$1" in
*/..|*/../) cd -- "$1";; # that doesn't make any sense unless the directory already exists
/*/../*) (cd "${1%/../*}/.." && mkdir -p "./${1##*/../}") && cd -- "$1";;
/*) mkdir -p "$1" && cd "$1";;
*/../*) (cd "./${1%/../*}/.." && mkdir -p "./${1##*/../}") && cd "./$1";;
../*) (cd .. && mkdir -p "${1#.}") && cd "$1";;
*) mkdir -p "./$1" && cd "./$1";;
esac
}
trash-empty() {
if which gio &>/dev/null; then
gio trash --empty
elif which gvfs-trash &>/dev/null; then
gvfs-trash --empty
else
echo "Requires glib2 (gio) or gvfs (gvfs-trash) package"
fi
}
trash() {
if which gio &>/dev/null; then
gio trash -f $@
elif which gvfs-trash &>/dev/null; then
gvfs-trash -f $@
else
echo "Requires glib2 (gio) or gvfs (gvfs-trash) package"
fi
}
trash-ls() {
if which gio &>/dev/null; then
gio list -h trash://
elif which gvfs-ls &>/dev/null; then
gvfs-ls -h trash://
else
echo "Requires glib2 (gio) or gvfs (gvfs-trash) package"
fi
}
# Take a screenshot
shot() { maim -u ~/Pictures/scrot/$(date +%s).png && notify-send 'Screen captured' ;}
# Convert to mp3
tomp3() {
if [ $# -lt 1 ]; then
echo -e " Usage: $0 <filename>"
echo -e " \nExample:\n$0 file.m4a"
echo -e " $0 file1.m4a file2.m4a file3.m4a"
echo -e " $0 *.m4a"
return 1
fi
files=( "$@" )
for arg in "${files[@]}"; do
while [ ! -f "${arg%.*}".mp3 ]
do
parallel ffmpeg -i "$arg" -codec:a libmp3lame -qscale:a 2 "${arg%.*}".mp3
done
done
}
# PulseAudio Switcher CLI
pa-sources() {
echo -e " List all input and output sound devices (output = speakers, input = microphone)\n"
pacmd list-sources | awk '/index:/ ||/name:/ || /alsa.card_name/ || /device.description/' | grep -E --color 'output|$'
}
pa-global() {
if [ $# -lt 1 ]; then
echo -e " Redirect (pulse)audio of all running apps to another device"
echo -e "\n Usage: $0 <device_index_number>"
echo -e "\n Example: $0 0 \n"
echo " Sound Devices"
pacmd list-sinks | awk '/index/ || /name:/ || /alsa.card_name/ || /device.description/'
return 1
fi
# list all apps in playback tab (ex: cmus, mplayer, vlc)
inputs=($(pacmd list-sink-inputs | awk '/index/ {print $2}'))
# set the default output device
pacmd set-default-sink $1 &> /dev/null
# apply the changes to all running apps to use the new output device
for i in ${inputs[*]}; do pacmd move-sink-input $i $1 &> /dev/null; done
}
pa-solo() {
if [ $# -lt 2 ]; then
echo -e " Redirect (pulse)audio of one running app to another device"
echo -e "\n Usage: $0 <app_index_number> <device_index_number>"
echo -e "\n Example: $0 2302 0 \n"
echo " ═══════════════"
echo " Running Apps "
pacmd list-sink-inputs | awk '/index/ || /application.name /'
echo " ═══════════════"
echo " Sound Devices"
pacmd list-sinks | awk '/index/ || /name:/ || /alsa.card_name/ || /device.description/'
return 1
fi
# set the default output device
pacmd set-default-sink "$2" &> /dev/null
# apply changes to one running app to use the new output device
pacmd move-sink-input "$1" "$2" &> /dev/null
}
# Showing off during live shows
deci() {
echo " "
toilet -t -f 3d " $@! " | lolcat
echo " "
}
function cfg(){
case $1 in
vi) $EDITOR ~/.config/nvim/init.vim ;;
ob) sudo -e $EDITOR /etc/oblogout.conf ;;
start) $EDITOR ~/.config/bspwm/autostart ;;
wm) $EDITOR ~/.config/bspwm/bspwmrc ;;
keys) $EDITOR ~/.config/sxhkd/sxhkdrc ;;
mutt) $EDITOR ~/.mutt/muttrc ;;
nano) $EDITOR ~/.nanorc ;;
zsh) $EDITOR ~/.zshrc ;;
bar) $EDITOR ~/.config/polybar/config ;;
dunst) $EDITOR ~/.config/dunst/dunstrc ;;
term) $EDITOR ~/.config/termite/config ;;
rofi) $EDITOR ~/.config/rofi/config.rasi;;
mpv) $EDITOR ~/.config/mpv/input.conf ;;
mpd) $EDITOR ~/.config/mpd/mpd.conf ;;
play) $EDITOR ~/.config/ncmpcpp/config ;;
rg) $EDITOR ~/.config/ranger/rc.conf ;;
rifle) $EDITOR ~/.config/ranger/rifle.conf ;;
scope) $EDITOR ~/.config/ranger/scope.sh ;;
tx) $EDITOR ~/.tmux.conf ;;
comp) $EDITOR ~/.config/compton.conf ;;
tsd) $EDITOR ~/.config/transmission-daemon/settings.json ;;
tsr) $EDITOR ~/.config/transmission-remote-cli/settings.cfg ;;
xinit) $EDITOR ~/.xinitrc ;;
xres) $EDITOR ~/.Xresources ;;
*) echo "Can't help you with that" ;;
esac
}
function rld(){
case $1 in
zsh) source ~/.zshrc ;;
fonts) fc-cache -v -f ;;
keys) pkill -USR1 -x sxhkd ;;
dunst) ~/.config/dunst/./reload ;;
comp) pkill compton && compton -bcCGf ;;
xres) xrdb ~/.Xresources ;;
*) echo "Can't help you with that" ;;
esac
}
export GREP_COLOR="0;32"
export PULSEMIXER_BAR_STYLE="┌╶┐╴└┘▮ ◆┆"
export RANGER_LOAD_DEFAULT_RC="FALSE"
ranger() {
if [ -z "$RANGER_LEVEL" ]; then
/usr/bin/ranger "$@"
else
exit
fi
}
# Colored man pages using less as pager
man() {
env \
LESS_TERMCAP_mb=$(printf "\e[1;36m") \
LESS_TERMCAP_md=$(printf "\e[1;34m") \
LESS_TERMCAP_me=$(printf "\e[0m") \
LESS_TERMCAP_se=$(printf "\e[0m") \
LESS_TERMCAP_so=$(printf "\e[1;33m") \
LESS_TERMCAP_ue=$(printf "\e[0m") \
LESS_TERMCAP_us=$(printf "\e[1;32m") \
man "$@"
}
# colorized cat
function c() {
for file in "$@"
do
pygmentize -O style=monokai -f console256 -g "$file"
done
}
# colorized less
function l() {
pygmentize -O style=monokai -f console256 -g $1 | less -r
}
# This is a workaround for tmux. When you clear the terminal with ctrl-l
# anything on-screen is not saved (this is compatible with xterm behavior).
# In contrast, GNU screen will first push anything on-screen into the
# scrollback buffer before clearing the screen.
function tmux-clear-screen() {
for line in {1..$(( $LINES ))} ; do echo; done
zle clear-screen
}
zle -N tmux-clear-screen
bindkey "^L" tmux-clear-screen
connected() {
echo "╓───────────── ─ ─ Connected Devices ─ ─ ─────────────╖"
nmap -sn $(netstat -rn | awk 'FNR == 3 {print $2}')/24
echo "╙─────────────────────────────────────────────────────╜"
}
myip() {
echo "╓───────────── ─ ─ Network Information ─ ─ ─────────────╖"
echo "router ip:" $(netstat -rn | awk 'FNR == 3 {print $2}')
ip addr | awk '/global/ {print $1,$2}' | cut -d\/ -f1
ip addr | awk '/global/ {print $3,$4}'
ip addr | awk '/ether/ {print $1,$2}'
ip addr | awk '/scope link/ {print $1,$2}' | cut -d\/ -f1
echo external ip: $(curl -s http://ipecho.net/plain)
echo "╙───────────────────────────────────────────────────────╜"
}
[[ -e /usr/share/doc/pkgfile/command-not-found.zsh ]] && source /usr/share/doc/pkgfile/command-not-found.zsh
# }}}
# vim:foldmethod=marker:foldlevel=0