*
-!*.zsh
!.gitignore
+!*.zsh
+!*.sh
!.zshrc
!.zshenv
!.zprofile
!include/
+!completions/
# shell variables
export SHELL="/bin/zsh"
export ZSH="$ZDOTDIR"
+export ZSHEXTRA="$ZDOTDIR/extra"
+export ZSHINCLUDE="$ZDOTDIR/include"
+export ZSHCOMPLETION="$ZSH/completions"
export ZSH_COMPDUMP="$ZSH/cache/.zcompdump-$HOST"
# my folders
export DOTFILES="$REPOS/dotfiles"
export SCRIPTS="$REPOS/script"
export DOWNLOADS="$HOME/downloads"
+export PACKAGES="$HOME/.packages"
+export CONFIG="$XDG_CONFIG_HOME"
# system variables
export LANG=en_US.UTF-8
# path variables
-export PATH="$PATH:$HOME/.cargo/bin:$HOME/.local/bin:$REPOS/script:."
-export CDPATH=".:$HOME:$REPOS:$XDG_CONFIG_HOME:/"
+export PATH="$PATH:$HOME/.local/bin:$REPOS/script:$REPOS/ruby:$XDG_DATA_HOME/cargo/bin:."
+export CDPATH=".:$HOME:$HOME/$REPOS:$HOME/$XDG_CONFIG_HOME:/"
+
+# language variables
+export GOPATH="$XDG_DATA_HOME/go"
+export PERL_LOCAL_LIB_ROOT="$XDG_DATA_HOME/perl5"
+export CARGO_HOME="$XDG_DATA_HOME/cargo"
+export RUSTUP_HOME="$XDG_DATA_HOME/rustup"
+
+# terminal setting:
+# [[ -n $TMUX ]] && export TERM=tmux-256color || export TERM=alacritty
# preferred programs
export PAGER='less'
-export LESS='-R --use-color'
-export MANPAGER='less -R --use-color'
+export LESS='-R --use-color -Dd+r$Du+b'
+export MANPAGER='less -R --use-color -Dd+r -Du+b'
export EDITOR="/usr/bin/nvim"
+export DIFFPROG="/usr/bin/nvim -d"
+export VISUAL="/usr/bin/nvim"
+export BROWSER="/usr/bin/firefox"
export EMAIL='huck@huck.website'
# config paths
export TERMINFO_DIRS="$XDG_DATA_HOME/terminfo:/usr/share/terminfo"
export PASSWORD_STORE_DIR="$XDG_DATA_HOME/pass"
export INPUTRC="$XDG_CONFIG_HOME/readline/inputrc"
+
+# zoxide
+export _ZO_ECHO='1'
+export _ZO_RESOLVE_SYMLINKS='1'
#shellcheck disable=all
-# sourcing -------------------------------------------------
-. $ZSH/.zshenv
-ZSHEXTRA=$ZSH/extra
-ZSHINCLUDE=$ZSH/include
-[[ ! -d $ZSH ]] && mkdir $ZSH/{cache,extra,include}
+# setup ~/.config/zsh
+. $ZDOTDIR/.zshenv
+[[ ! -d $ZSH ]] && mkdir -p $ZSH/cache $ZSHINCLUDE $ZSHCOMPLETION $ZSHEXTRA
-# source files from include dir
-for file in $ZSHINCLUDE/*; do
- . ${file}
-done
-
-# start programs
-eval $(dircolors -b $XDG_CONFIG_HOME/.dircolors)
-eval "$(zoxide init zsh --cmd z)"
-[[ -f /usr/share/fzf/key-bindings.zsh ]] && . /usr/share/fzf/key-bindings.zsh
-
-# keybindings -------------------------------------------------------
-bindkey "\e[1~" beginning-of-line
-bindkey "\e[4~" end-of-line
-bindkey "\e[5~" beginning-of-history
-bindkey "\e[6~" end-of-history
-bindkey "\e[3~" delete-char
-bindkey "\e[2~" quoted-insert
-
-# options ------------------------------------------------------------
+# options
ENABLE_CORRECTION="true"
COMPLETION_WAITING_DOTS="true"
-HISTFILE=$ZSH/.zsh-history
-HISTORY_LOG=$ZSH/.zsh-history.log
-SAVEHIST=100000
+HISTFILE=$ZSH/history/zsh-history
+HISTORY_LOG=$ZSH/history/zsh-history.log
+SAVEHIST=1000000
HISTSIZE=10000
-HIST_STAMPS="mm/dd/yyyy"
+HIST_STAMPS="yyyy-mm-dd"
REPORTTIME=5
DIRSTACKSISZE=10
-setopt autopushd pushdminus pushdsilent pushdtohome pushdignoredups
+setopt autopushd chase_links
setopt share_history append_history inc_append_history extended_history
-setopt hist_expire_dups_first hist_ignore_dups hist_find_no_dups hist_save_no_dups hist_reduce_blanks
+setopt hist_expire_dups_first hist_ignore_dups hist_find_no_dups hist_ignore_all_dups hist_reduce_blanks
setopt correct correct_all
setopt list_ambiguous
-setopt mark_dirs interactivecomments
+setopt mark_dirs interactive_comments
setopt append_create clobber_empty
setopt hash_cmds hash_dirs
setopt path_script prompt_subst
setopt auto_param_keys auto_param_slash auto_remove_slash
-setopt null_glob glob glob_dots glob_star_short
+setopt null_glob glob glob_dots glob_star_short bang_hist
unsetopt flow_control
-# completion ---------------------------------------------------------
-zstyle ':completion:*' auto-description '%d'
-zstyle ':completion:*' completer _expand _complete _ignored _correct _approximate
-zstyle ':completion:*' completions 1
-zstyle ':completion:*' expand prefix suffix
-zstyle ':completion:*' file-sort access
-zstyle ':completion:*' format '%d'
-zstyle ':completion:*' glob 1
-zstyle ':completion:*' group-name ''
-zstyle ':completion:*' ignore-parents parent pwd
-zstyle ':completion:*' insert-unambiguous true
-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:*' matcher-list '' 'm:{[:lower:]}={[:upper:]}' 'r:|[._-,]=** r:|=**' 'l:|=* r:|=*'
-zstyle ':completion:*' max-errors 3
-zstyle ':completion:*' menu select=long interactive
-zstyle ':completion:*' original true
-zstyle ':completion:*' prompt '%e'
-zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
-zstyle ':completion:*' squeeze-slashes true
-zstyle ':completion:*' substitute 1
-zstyle ':completion:*' verbose true
+# completion
+fpath=($ZSHCOMPLETION $fpath)
+[[ -f $ZSHCOMPLETION/completions.zsh ]] && source $ZSHCOMPLETION/completions.zsh
-autoload -Uz compinit
-for dump in ~/.zcompdump(N.mh+24); do
- compinit
-done
-compinit -C
-zshcache_time="$(date +%s%N)"
+# source files from include dir
+for file in $ZSHINCLUDE/*; do . ${file}; done
+
+# start programs
+[[ -f $XDG_CONFIG_HOME/.dircolors ]] && eval $(dircolors -b $XDG_CONFIG_HOME/.dircolors)
+[[ $(which zoxide) ]] && eval "$(zoxide init zsh --cmd z)"
-# zle plugins -------------------------------------------------------
+# zle plugins
autoload -Uz chpwd_recent_dirs cdr add-zsh-hook
-add-zsh-hook chpwd chpwd_recent_dirs
+autoload -Uz run-help
-chpwd() { lsd -A }
+add-zsh-hook chpwd chpwd_recent_dirs
-autoload -U insert-files
-zle -N insert-files
-bindkey -M vicmd '^f' insert-files
+chpwd() { ls -Ah }
-autoload -Uz run-help
+# keybindings
+bindkey "\e[1~" beginning-of-line
+bindkey "\e[4~" end-of-line
+bindkey "\e[5~" beginning-of-history
+bindkey "\e[6~" end-of-history
+bindkey "\e[3~" delete-char
+bindkey "\e[2~" quoted-insert
-# custom prompt -----------------------------------------------------
+# custom prompt
if [[ -n $SSH_CONNECTION ]]; then
-PROMPT='%(?..%B%F{red}x)
-%B%F{yellow}%n%b%f@%B%F{blue}%M%b%f -> %F{green}%d %F{red}[SSH] %B%F{magenta}%t %W
+PROMPT='%(?..%B%F{red}x)
+%B%F{yellow}%n%b%f@%B%F{blue}%m%b%f: %F{cyan}%~ %F{red}[SSH] $F{magenta}[gentoo] %f$(git_prompt_enhanced_status)
%B%F{green}%(!.#.$) %f%b> '
-RPROMPT='$(git_prompt_enhanced_status) %f[%!]'
+RPROMPT='%f[%!]'
else
PROMPT='%(?..%B%F{red}x)
%B%F{green}%n%b%f@%B%F{red}%m%b%f: %F{blue}%~ %f$(git_prompt_enhanced_status)
RPROMPT='%f[%!]'
fi
-PS2='%B%F{green}%(!.#.$)%f%b %F{cyan}*%f '
+PS2='%B%F{green}%(!.#.$)%f%b > %F{cyan}*%f '
PS3='%B%F{green}%(!.#.$)%f%b %B%F{magenta}? '
-
--- /dev/null
+LIST_PACKED=true
+GLOB_COMPLETE=true
+
+zstyle ':completion:*' completer _expand _extensions _complete _approximate
+zstyle ':completion:*' completions true
+zstyle ':completion:*' expand prefix suffix
+zstyle ':completion:*' insert-unambiguous true
+zstyle ':completion:*' max-errors 3
+
+zstyle ':completion:*' file-sort time follow
+zstyle ':completion:*' file-list all
+
+zstyle ':completion:*' path-completion true
+zstyle ':completion:*' glob true
+zstyle ':completion:*' group-name ''
+zstyle ':completion:*' ignore-parents parent pwd
+zstyle ':completion:*' substitute true
+zstyle ':completion:*' squeeze-slashes true
+
+zstyle ':completion:*' menu select=long search
+zstyle ':completion:*' original true
+zstyle ':completion:*' verbose true
+zstyle ':completion:*' prompt '%e'
+zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
+zstyle ':completion:*' matcher-list '' 'm:{[:lower:]}={[:upper:]}' 'r:|[._-,]=** r:|=**' 'l:|=* r:|=*'
+
+zstyle ':completion:*' gain-privileges true
+
+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:*' auto-description '%d'
+zstyle ':completion:*:*:*:*:descriptions' format '%F{green}-- %d --%f'
+zstyle ':completion:*:corrections' format '%F{yellow}!- %d -!%f'
+zstyle ':completion:*:warnings' format '%F{red}no matches%f'
+zstyle ':completion:*:messages' format '%F{blue}== %d ==%f'
+
+autoload -Uz compinit
+for dump in ~/.zcompdump(N.mh+24); do
+ compinit
+done
+compinit -C
+zshcache_time="$(date +%s%N)"
-#ALIASES:
-
-#shell aliases
alias cp='cp -vr'
alias rm='rm -v'
alias mv='mv -v'
alias mkdir='mkdir -pv'
alias mount='mount --mkdir'
alias lsblk='lsblk -f'
+
alias reload='source $ZSH/.zshrc'
alias quit='disown -a && exit'
-alias msg='sudo dmesg -H --level=err'
alias :q='exit'
-# convinience aliases
alias v='nvim'
-alias sv='sudoedit'
alias vsesh='nvim -S'
alias vdiff='nvim -d'
+
+alias sv='sudoedit'
+alias sudo="sudo "
+
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
+
alias h='history 0'
alias j='jobs -l'
alias c='clear'
-alias zc='z;clear'
-alias cd='z'
+alias zc='cd;clear'
+alias cd='z '
+
alias make='make -j8 -l4 CFLAGS="-march=skylake -O2 -pipe -fomit-frame-pointer"'
alias dust='dust -rb'
-# ls/exa aliases
alias ls='lsd'
alias l='ls'
alias ll='ls -lAh'
# color aliases
alias ip='ip --color=auto'
alias grep='grep --color=auto'
-alias fgrep='fgrep --color=auto'
-alias egrep='egrep --color=auto'
# tmux aliases
-alias tmux='tmux'
-alias tlist='tmux list-sessions'
-alias tsesh='tmux new-session -s'
-alias tkill='tmux kill-session -t'
alias tattach='tmux attach-session -t'
# config aliases
#!/bin/bash
-# grep through history
-hg() {
- history 0 | grep "$1";
-}
-
# easy find files
f() {
find . | grep "$1";
if [ "$(ls -A $arg)" ]; then # move to trash if non empty dir
mv -f "$arg" "$HOME/.trash/$1"
elif [ -d "$arg" ]; then # delete empty directories
- rmdir "$arg"
+ rmdir "$arg"
elif [ -f "$arg" ]; then # move files to trash
- mv -f "$arg" "$HOME/.trash/$1"
+ mv -f "$arg" "$HOME/.trash/$1"
else
echo -e "\n\033[31;1;4mFile Not Found:\033[0m\033[34;1m $1\033[0m\n"
fi
-if [[ -d $ZSHEXTRA/zsh-autosuggestions ]]; then
- source $ZSHEXTRA/zsh-autosuggestions/zsh-autosuggestions.zsh
- ZSH_AUTOSUGGEST_STRATEGY=(history completion)
- set ZSH_AUTOSUGGEST_USE_ASYNC
+# fish like autosuggestions
+if [[ ! -d $ZSHEXTRA/zsh-autosuggestions ]]; then
+ cd $ZSHEXTRA
+ git clone 'https://github.com/zsh-users/zsh-autosuggestions' "$ZSHEXTRA/zsh-autosuggestions"
fi
+source "$ZSHEXTRA/zsh-autosuggestions/zsh-autosuggestions.zsh"
+ZSH_AUTOSUGGEST_STRATEGY=(history completion)
+set ZSH_AUTOSUGGEST_USE_ASYNC
-if [[ -d $ZSHEXTRA/zsh-fast-syntax-highlighting ]]; then
- source $ZSHEXTRA/zsh-fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh
- fast-theme -q $ZSHEXTRA/zsh-fast-syntax-highlighting/themes/custom.ini
+# syntax highlighing
+if [[ ! -d $ZSHEXTRA/zsh-fast-syntax-highlighting ]]; then
+ cd $ZSHEXTRA
+ git clone 'https://github.com/zdharma-continuum/fast-syntax-highlighting' "$ZSHEXTRA/zsh-fast-syntax-highlighting"
fi
+source $ZSHEXTRA/zsh-fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh
+fast-theme -q $ZSH/extra/zsh-fast-syntax-highlighting/themes/custom.ini
-if [[ -d $ZSHEXTRA/zsh-history-substring-search ]]; then
- source $ZSHEXTRA/zsh-history-substring-search/zsh-history-substring-search.zsh
- bindkey '^[[A' history-substring-search-up
- bindkey '^[[B' history-substring-search-down
+# up arrow history search of partial commands
+if [[ ! -d $ZSHEXTRA/zsh-history-substring-search ]]; then
+ cd $ZSHEXTRA
+ git clone 'https://github.com/zsh-users/zsh-history-substring-search'
fi
+source $ZSHEXTRA/zsh-history-substring-search/zsh-history-substring-search.zsh "$ZSHEXTRA/zsh-history-substring-search"
+bindkey '^[[A' history-substring-search-up
+bindkey '^[[B' history-substring-search-down
#
# For example:
# ZVM_VI_HIGHLIGHT_FOREGROUND=green # Color name
-# ZVM_VI_HIGHLIGHT_FOREGROUND=#008800 # Hex value
+ZVM_VI_HIGHLIGHT_FOREGROUND=#b8d68c
# ZVM_VI_HIGHLIGHT_BACKGROUND=red # Color name
-# ZVM_VI_HIGHLIGHT_BACKGROUND=#ff0000 # Hex value
+ZVM_VI_HIGHLIGHT_BACKGROUND=#e84f4f
# ZVM_VI_HIGHLIGHT_EXTRASTYLE=bold,underline # bold and underline
#
# ZVM_VI_SURROUND_BINDKEY
# ZVM_LINE_INIT_MODE=$ZVM_MODE_INSERT
# ZVM_LINE_INIT_MODE=$ZVM_MODE_NORMAL
#
-# ZVM_LAZY_KEYBINDINGS:
+ZVM_LAZY_KEYBINDINGS=false
# the setting for lazy keybindings (default is true), and lazy keybindings
# will postpone the keybindings of vicmd and visual keymaps to the first
# time entering normal mode
zvm_bindkey vicmd '^[[3~' delete-char
# History search
- # zvm_bindkey viins '^R' history-incremental-search-backward
+ #zvm_bindkey viins '^R' history-incremental-search-backward
zvm_bindkey viins '^S' history-incremental-search-forward
zvm_bindkey viins '^P' up-line-or-history
zvm_bindkey viins '^N' down-line-or-history
sourcing) zvm_init;;
*) precmd_functions+=(zvm_init);;
esac
-
--- /dev/null
+#!/bin/bash
+
+# start tmux server if it's not already running
+[[ ! $(pgrep tmux) ]] && tmux start
+
+# exit if already in a tmux session
+[[ -n $TMUX ]] && return
+
+# check if any sessions exit
+if [[ $(tmux list-sessions | wc -l) -ne 0 ]]; then
+ if [[ $(tmux list-sessions -F"#{?session_attached,,x}" | grep "x" | wc -l) -eq 1 ]] && [[ -z $SSH_CLIENT ]]; then
+ tmux attach-session -t $(tmux list-sessions -F"#{?session_attached,,#S}" )
+ return
+ else
+ printf '\033[32;1mcurrent \033[33;1mtmux \033[32;1msessions\033[0m:\n'
+ tmux list-sessions -F"#S - (#{?session_attached,attached,not attached})"
+ printf '\033[34;1mattach session?\033[0;m: [\033[35;1mname\033[0m] \033[37;2m(empty if none)\033[0m: '
+ fi
+else
+ printf '\033[34;1mno \033[33;1mtmux \033[34;1msessions active\n'
+ printf '\033[34;1mcreate new session?\033[0;m: [\033[35;1mname\033[0m] \033[37;2m(empty if none)\033[0m: '
+fi
+
+read session
+
+# start requested session - since it uses grep you just have to put enough of a unique identifier to select
+if [[ -n $session ]]; then
+ if tmux list-sessions -F"#S" | grep -q "$session"; then
+ tmux attach-session -t $session
+ return
+ elif [[ $session == new ]]; then
+ tmux new-session
+ return
+ else
+ tmux new-session -s $session
+ return
+ fi
+fi
+
+return