configs

git clone git://git.codymlewis.com/configs.git
Log | Files | Refs | README

.zshrc (4101B)


      1 #!/usr/bin/env zsh
      2 
      3 zmodload zsh/complist
      4 autoload -Uz compinit
      5 autoload -Uz vcs_info
      6 compinit
      7 setopt COMPLETE_ALIASES
      8 precmd_vcs_info() { vcs_info }
      9 precmd_functions+=( precmd_vcs_info )
     10 setopt prompt_subst
     11 
     12 zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
     13 zstyle ':completion:*' completer _expand _complete _ignored _approximate _prefix
     14 zstyle ':completion:*' menu select=2
     15 zstyle ':vcs_info:git:*' formats '%F{240}(%b)%f%F{red}%u%f%F{green}%c%f'
     16 zstyle ':vcs_info:git:*' check-for-changes true
     17 zstyle ':vcs_info:git:*' check-for-staged-changes true
     18 zstyle ':vcs_info:git:*' stagedstr '+'
     19 zstyle ':vcs_info:git:*' unstagedstr '*'
     20 zstyle ':vcs_info:*' enable git
     21 
     22 autoload -Uz up-line-or-beginning-search down-line-or-beginning-search
     23 zle -N up-line-or-beginning-search
     24 zle -N down-line-or-beginning-search
     25 
     26 setopt INC_APPEND_HISTORY
     27 setopt EXTENDED_HISTORY
     28 setopt SHARE_HISTORY
     29 
     30 [[ -n "${key[Up]}"    ]] && bindkey -- "${key[Up]}"   up-line-or-beginning-search
     31 [[ -n "${key[Down]}"  ]] && bindkey -- "${key[Down]}" down-line-or-beginning-search
     32 
     33 export PROMPT="%F{yellow}[%f%(?.%F{green}.%F{red})%?%f%F{yellow}]%f %B%F{magenta}%~%f%b %F{red}%#%f "
     34 export RPROMPT="\$vcs_info_msg_0_"
     35 
     36 bindkey -e
     37 
     38 alias ls="ls -hN --color=auto --group-directories-first"
     39 alias sl="ls"
     40 alias ll="ls -l"
     41 alias l="ls -l"
     42 alias la="ls -a"
     43 alias lla="ls -l -a"
     44 alias lal="ls -l -a"
     45 alias SS="sudo systemctl"
     46 alias ccat="highlight --out-format=ansi --force"
     47 alias grep="grep --color"
     48 alias p="sudo pacman"
     49 alias k="kak"
     50 alias v="nvim"
     51 alias vs="nvim -S"
     52 alias vt="nvim -t"
     53 alias z="zathura"
     54 alias g="git"
     55 alias x='exit'
     56 alias :q='exit'
     57 alias ..='cd ../'
     58 alias ...="cd ../../"
     59 alias ....="cd ../../../"
     60 alias .....="cd ../../../../"
     61 alias tmuxcon='tmux -q has-session && exec tmux attach-session -d || exec tmux new-session -n"$USER" -s"$USER"@"$HOSTNAME"'
     62 bindkey -s '^P' 'f=$(fzf) && open "$f"\n'
     63 bindkey -s "^Z" 'setsid $TERMINAL 2>&1 > /dev/null &\n'
     64 
     65 open () {
     66         for a in $@; do
     67                 ([[ "$a" =~ .*.[(pdf)(djvu)]$ ]] && zathura "$a") ||
     68                         ([[ "$a" =~ .*.[(png)(jpe?g)]$ ]] && sxiv "$a") ||
     69                         ([[ "$a" =~ .*.[(mp4)(mkv)(mp3)(ogg)(wav)(webm)]$ ]] && mpv "$a") ||
     70                         nvim "$a"
     71         done
     72 }
     73 
     74 alias yd="youtube-dl -ic --add-metadata -f 'bestvideo+bestaudio/best'" # Download video link
     75 alias yda="youtube-dl -x -f bestaudio/best" # Download only audio
     76 
     77 gdoc () {
     78         refer -PS -e -p "$HOME/Groff/bibliography" "$1.ms" | \
     79                 groff -ms -e -m "$HOME/Groff/macros" -T pdf > "$1.pdf"
     80                         pgrep -a zathura | grep "$1.pdf" > /dev/null 2>&1 || zathura "$1.pdf" $@ &
     81 }
     82 
     83 alias sxiv="sxiv -a"
     84 alias ct="uctags"
     85 
     86 m () {
     87         find "$2" 1>/dev/null || mkdir -p "$2"
     88         sudo mount "$1" "$2" && echo "Successfully mounted $1 at $2"
     89 }
     90 
     91 u () {
     92         sudo umount "$1" && sync && echo "$1 was successfully unmounted"
     93 }
     94 
     95 b () {
     96         find "$HOME/mnt/backup" 1>/dev/null || mkdir -p "$HOME/mnt/backup"
     97         m "$1" "$HOME/mnt/backup" && \
     98                 bak_fol="$(date | sed 's/ /_/g')" && \
     99                 mkdir "$HOME/mnt/backup/$bak_fol" && \
    100                 echo "Backing up files..." && \
    101                 cp -r "$HOME/Desktop" "$HOME/Music" "$HOME/suckless" "$HOME/mnt/backup/$bak_fol" && echo "Done Backup" && \
    102                 u "$HOME/mnt/backup"
    103 }
    104 
    105 wd () {
    106         config="$HOME/.config/zsh/warprc"
    107         case $1 in
    108                 "list")
    109                        sed 's/ / -> /' "$config"
    110                 ;;
    111                 "add")
    112                        printf "%s %s\n" "$2" "$PWD" >> "$config"
    113                 ;;
    114                 "rm")
    115                        temp=$(grep -v "$2"\\s "$config")
    116                        echo "$temp" > "$config"
    117                 ;;
    118                 *)
    119                        wp=$(grep -m1 "$1[[:space:]]" "$config" | awk '{ print $2 }')
    120                        cd "$wp" || \
    121                               (echo "Could not warp to point $1" && exit)
    122                 ;;
    123         esac
    124 }
    125 
    126 source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh