mirror of
https://github.com/Lissy93/dotfiles.git
synced 2025-06-26 12:01:21 +02:00
Adds ZSH files
This commit is contained in:
parent
f3b5c2b0c2
commit
c14833bea6
@ -18,8 +18,11 @@
|
|||||||
|
|
||||||
#ZSH
|
#ZSH
|
||||||
~/.zshrc: zsh/zshrc
|
~/.zshrc: zsh/zshrc
|
||||||
|
~/.p10k.zsh: zsh/p10k.zsh
|
||||||
~/.zsh/antigen: zsh/antigen
|
~/.zsh/antigen: zsh/antigen
|
||||||
~/.oh-my-zsh/themes: zsh/themes
|
~/.zsh/themes: zsh/themes
|
||||||
|
~/.zsh/aliases: zsh/aliases
|
||||||
|
~/.zsh/plugins: zsh/plugins
|
||||||
|
|
||||||
# bash
|
# bash
|
||||||
~/.bash:
|
~/.bash:
|
||||||
|
28
zsh/aliases/ansible-aliases.zsh
Normal file
28
zsh/aliases/ansible-aliases.zsh
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
# Functions
|
||||||
|
function ansible-version(){
|
||||||
|
ansible --version
|
||||||
|
}
|
||||||
|
|
||||||
|
function ansible-role-init(){
|
||||||
|
if ! [ -z $1 ] ; then
|
||||||
|
echo "Ansible Role : $1 Creating...."
|
||||||
|
ansible-galaxy init $1
|
||||||
|
tree $1
|
||||||
|
else
|
||||||
|
echo "Usage : ansible-role-init <role name>"
|
||||||
|
echo "Example : ansible-role-init role1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Alias
|
||||||
|
alias a='ansible '
|
||||||
|
alias aconf='ansible-config '
|
||||||
|
alias acon='ansible-console '
|
||||||
|
alias aver='ansible-version'
|
||||||
|
alias arinit='ansible-role-init'
|
||||||
|
alias aplaybook='ansible-playbook '
|
||||||
|
alias ainv='ansible-inventory '
|
||||||
|
alias adoc='ansible-doc '
|
||||||
|
alias agal='ansible-galaxy '
|
||||||
|
alias apull='ansible-pull '
|
||||||
|
alias aval='ansible-vault'
|
88
zsh/aliases/common-aliases.zsh
Normal file
88
zsh/aliases/common-aliases.zsh
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
# Advanced Aliases.
|
||||||
|
# Use with caution
|
||||||
|
#
|
||||||
|
|
||||||
|
# ls, the common ones I use a lot shortened for rapid fire usage
|
||||||
|
alias l='ls -lFh' #size,show type,human readable
|
||||||
|
alias la='ls -lAFh' #long list,show almost all,show type,human readable
|
||||||
|
alias lr='ls -tRFh' #sorted by date,recursive,show type,human readable
|
||||||
|
alias lt='ls -ltFh' #long list,sorted by date,show type,human readable
|
||||||
|
alias ll='ls -l' #long list
|
||||||
|
alias ldot='ls -ld .*'
|
||||||
|
alias lS='ls -1FSsh'
|
||||||
|
alias lart='ls -1Fcart'
|
||||||
|
alias lrt='ls -1Fcrt'
|
||||||
|
|
||||||
|
alias zshrc='${=EDITOR} ${ZDOTDIR:-$HOME}/.zshrc' # Quick access to the .zshrc file
|
||||||
|
|
||||||
|
alias grep='grep --color'
|
||||||
|
alias sgrep='grep -R -n -H -C 5 --exclude-dir={.git,.svn,CVS} '
|
||||||
|
|
||||||
|
alias t='tail -f'
|
||||||
|
|
||||||
|
# Command line head / tail shortcuts
|
||||||
|
alias -g H='| head'
|
||||||
|
alias -g T='| tail'
|
||||||
|
alias -g G='| grep'
|
||||||
|
alias -g L="| less"
|
||||||
|
alias -g M="| most"
|
||||||
|
alias -g LL="2>&1 | less"
|
||||||
|
alias -g CA="2>&1 | cat -A"
|
||||||
|
alias -g NE="2> /dev/null"
|
||||||
|
alias -g NUL="> /dev/null 2>&1"
|
||||||
|
alias -g P="2>&1| pygmentize -l pytb"
|
||||||
|
|
||||||
|
alias dud='du -d 1 -h'
|
||||||
|
alias duf='du -sh *'
|
||||||
|
(( $+commands[fd] )) || alias fd='find . -type d -name'
|
||||||
|
alias ff='find . -type f -name'
|
||||||
|
|
||||||
|
alias h='history'
|
||||||
|
alias hgrep="fc -El 0 | grep"
|
||||||
|
alias help='man'
|
||||||
|
alias p='ps -f'
|
||||||
|
alias sortnr='sort -n -r'
|
||||||
|
alias unexport='unset'
|
||||||
|
|
||||||
|
alias rm='rm -i'
|
||||||
|
alias cp='cp -i'
|
||||||
|
alias mv='mv -i'
|
||||||
|
|
||||||
|
# zsh is able to auto-do some kungfoo
|
||||||
|
# depends on the SUFFIX :)
|
||||||
|
autoload -Uz is-at-least
|
||||||
|
if is-at-least 4.2.0; then
|
||||||
|
# open browser on urls
|
||||||
|
if [[ -n "$BROWSER" ]]; then
|
||||||
|
_browser_fts=(htm html de org net com at cx nl se dk)
|
||||||
|
for ft in $_browser_fts; do alias -s $ft='$BROWSER'; done
|
||||||
|
fi
|
||||||
|
|
||||||
|
_editor_fts=(cpp cxx cc c hh h inl asc txt TXT tex)
|
||||||
|
for ft in $_editor_fts; do alias -s $ft='$EDITOR'; done
|
||||||
|
|
||||||
|
if [[ -n "$XIVIEWER" ]]; then
|
||||||
|
_image_fts=(jpg jpeg png gif mng tiff tif xpm)
|
||||||
|
for ft in $_image_fts; do alias -s $ft='$XIVIEWER'; done
|
||||||
|
fi
|
||||||
|
|
||||||
|
_media_fts=(ape avi flv m4a mkv mov mp3 mpeg mpg ogg ogm rm wav webm)
|
||||||
|
for ft in $_media_fts; do alias -s $ft=mplayer; done
|
||||||
|
|
||||||
|
#read documents
|
||||||
|
alias -s pdf=acroread
|
||||||
|
alias -s ps=gv
|
||||||
|
alias -s dvi=xdvi
|
||||||
|
alias -s chm=xchm
|
||||||
|
alias -s djvu=djview
|
||||||
|
|
||||||
|
#list whats inside packed file
|
||||||
|
alias -s zip="unzip -l"
|
||||||
|
alias -s rar="unrar l"
|
||||||
|
alias -s tar="tar tf"
|
||||||
|
alias -s tar.gz="echo "
|
||||||
|
alias -s ace="unace l"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Make zsh know about hosts already accessed by SSH
|
||||||
|
zstyle -e ':completion:*:(ssh|scp|sftp|rsh|rsync):hosts' hosts 'reply=(${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) /dev/null)"}%%[# ]*}//,/ })'
|
307
zsh/aliases/git-aliases.zsh
Normal file
307
zsh/aliases/git-aliases.zsh
Normal file
@ -0,0 +1,307 @@
|
|||||||
|
# Git version checking
|
||||||
|
autoload -Uz is-at-least
|
||||||
|
git_version="${${(As: :)$(git version 2>/dev/null)}[3]}"
|
||||||
|
|
||||||
|
#
|
||||||
|
# Functions
|
||||||
|
#
|
||||||
|
|
||||||
|
# The name of the current branch
|
||||||
|
# Back-compatibility wrapper for when this function was defined here in
|
||||||
|
# the plugin, before being pulled in to core lib/git.zsh as git_current_branch()
|
||||||
|
# to fix the core -> git plugin dependency.
|
||||||
|
function current_branch() {
|
||||||
|
git_current_branch
|
||||||
|
}
|
||||||
|
|
||||||
|
# Pretty log messages
|
||||||
|
function _git_log_prettily(){
|
||||||
|
if ! [ -z $1 ]; then
|
||||||
|
git log --pretty=$1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
compdef _git _git_log_prettily=git-log
|
||||||
|
|
||||||
|
# Warn if the current branch is a WIP
|
||||||
|
function work_in_progress() {
|
||||||
|
if $(git log -n 1 2>/dev/null | grep -q -c "\-\-wip\-\-"); then
|
||||||
|
echo "WIP!!"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if main exists and use instead of master
|
||||||
|
function git_main_branch() {
|
||||||
|
command git rev-parse --git-dir &>/dev/null || return
|
||||||
|
local branch
|
||||||
|
for branch in main trunk; do
|
||||||
|
if command git show-ref -q --verify refs/heads/$branch; then
|
||||||
|
echo $branch
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo master
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Aliases
|
||||||
|
# (sorted alphabetically)
|
||||||
|
#
|
||||||
|
|
||||||
|
alias g='git'
|
||||||
|
|
||||||
|
alias ga='git add'
|
||||||
|
alias gaa='git add --all'
|
||||||
|
alias gapa='git add --patch'
|
||||||
|
alias gau='git add --update'
|
||||||
|
alias gav='git add --verbose'
|
||||||
|
alias gap='git apply'
|
||||||
|
alias gapt='git apply --3way'
|
||||||
|
|
||||||
|
alias gb='git branch'
|
||||||
|
alias gba='git branch -a'
|
||||||
|
alias gbd='git branch -d'
|
||||||
|
alias gbda='git branch --no-color --merged | command grep -vE "^(\+|\*|\s*($(git_main_branch)|development|develop|devel|dev)\s*$)" | command xargs -n 1 git branch -d'
|
||||||
|
alias gbD='git branch -D'
|
||||||
|
alias gbl='git blame -b -w'
|
||||||
|
alias gbnm='git branch --no-merged'
|
||||||
|
alias gbr='git branch --remote'
|
||||||
|
alias gbs='git bisect'
|
||||||
|
alias gbsb='git bisect bad'
|
||||||
|
alias gbsg='git bisect good'
|
||||||
|
alias gbsr='git bisect reset'
|
||||||
|
alias gbss='git bisect start'
|
||||||
|
|
||||||
|
alias gc='git commit -v'
|
||||||
|
alias gc!='git commit -v --amend'
|
||||||
|
alias gcn!='git commit -v --no-edit --amend'
|
||||||
|
alias gca='git commit -v -a'
|
||||||
|
alias gca!='git commit -v -a --amend'
|
||||||
|
alias gcan!='git commit -v -a --no-edit --amend'
|
||||||
|
alias gcans!='git commit -v -a -s --no-edit --amend'
|
||||||
|
alias gcam='git commit -a -m'
|
||||||
|
alias gcsm='git commit -s -m'
|
||||||
|
alias gcb='git checkout -b'
|
||||||
|
alias gcf='git config --list'
|
||||||
|
alias gcl='git clone --recurse-submodules'
|
||||||
|
alias gclean='git clean -id'
|
||||||
|
alias gpristine='git reset --hard && git clean -dffx'
|
||||||
|
alias gcm='git checkout $(git_main_branch)'
|
||||||
|
alias gcd='git checkout develop'
|
||||||
|
alias gcmsg='git commit -m'
|
||||||
|
alias gco='git checkout'
|
||||||
|
alias gcount='git shortlog -sn'
|
||||||
|
alias gcp='git cherry-pick'
|
||||||
|
alias gcpa='git cherry-pick --abort'
|
||||||
|
alias gcpc='git cherry-pick --continue'
|
||||||
|
alias gcs='git commit -S'
|
||||||
|
|
||||||
|
alias gd='git diff'
|
||||||
|
alias gdca='git diff --cached'
|
||||||
|
alias gdcw='git diff --cached --word-diff'
|
||||||
|
alias gdct='git describe --tags $(git rev-list --tags --max-count=1)'
|
||||||
|
alias gds='git diff --staged'
|
||||||
|
alias gdt='git diff-tree --no-commit-id --name-only -r'
|
||||||
|
alias gdw='git diff --word-diff'
|
||||||
|
|
||||||
|
function gdnolock() {
|
||||||
|
git diff "$@" ":(exclude)package-lock.json" ":(exclude)*.lock"
|
||||||
|
}
|
||||||
|
compdef _git gdnolock=git-diff
|
||||||
|
|
||||||
|
function gdv() { git diff -w "$@" | view - }
|
||||||
|
compdef _git gdv=git-diff
|
||||||
|
|
||||||
|
alias gf='git fetch'
|
||||||
|
# --jobs=<n> was added in git 2.8
|
||||||
|
is-at-least 2.8 "$git_version" \
|
||||||
|
&& alias gfa='git fetch --all --prune --jobs=10' \
|
||||||
|
|| alias gfa='git fetch --all --prune'
|
||||||
|
alias gfo='git fetch origin'
|
||||||
|
|
||||||
|
alias gfg='git ls-files | grep'
|
||||||
|
|
||||||
|
alias gg='git gui citool'
|
||||||
|
alias gga='git gui citool --amend'
|
||||||
|
|
||||||
|
function ggf() {
|
||||||
|
[[ "$#" != 1 ]] && local b="$(git_current_branch)"
|
||||||
|
git push --force origin "${b:=$1}"
|
||||||
|
}
|
||||||
|
compdef _git ggf=git-checkout
|
||||||
|
function ggfl() {
|
||||||
|
[[ "$#" != 1 ]] && local b="$(git_current_branch)"
|
||||||
|
git push --force-with-lease origin "${b:=$1}"
|
||||||
|
}
|
||||||
|
compdef _git ggfl=git-checkout
|
||||||
|
|
||||||
|
function ggl() {
|
||||||
|
if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then
|
||||||
|
git pull origin "${*}"
|
||||||
|
else
|
||||||
|
[[ "$#" == 0 ]] && local b="$(git_current_branch)"
|
||||||
|
git pull origin "${b:=$1}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
compdef _git ggl=git-checkout
|
||||||
|
|
||||||
|
function ggp() {
|
||||||
|
if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then
|
||||||
|
git push origin "${*}"
|
||||||
|
else
|
||||||
|
[[ "$#" == 0 ]] && local b="$(git_current_branch)"
|
||||||
|
git push origin "${b:=$1}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
compdef _git ggp=git-checkout
|
||||||
|
|
||||||
|
function ggpnp() {
|
||||||
|
if [[ "$#" == 0 ]]; then
|
||||||
|
ggl && ggp
|
||||||
|
else
|
||||||
|
ggl "${*}" && ggp "${*}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
compdef _git ggpnp=git-checkout
|
||||||
|
|
||||||
|
function ggu() {
|
||||||
|
[[ "$#" != 1 ]] && local b="$(git_current_branch)"
|
||||||
|
git pull --rebase origin "${b:=$1}"
|
||||||
|
}
|
||||||
|
compdef _git ggu=git-checkout
|
||||||
|
|
||||||
|
alias ggpur='ggu'
|
||||||
|
alias ggpull='git pull origin "$(git_current_branch)"'
|
||||||
|
alias ggpush='git push origin "$(git_current_branch)"'
|
||||||
|
|
||||||
|
alias ggsup='git branch --set-upstream-to=origin/$(git_current_branch)'
|
||||||
|
alias gpsup='git push --set-upstream origin $(git_current_branch)'
|
||||||
|
|
||||||
|
alias ghh='git help'
|
||||||
|
|
||||||
|
alias gignore='git update-index --assume-unchanged'
|
||||||
|
alias gignored='git ls-files -v | grep "^[[:lower:]]"'
|
||||||
|
alias git-svn-dcommit-push='git svn dcommit && git push github $(git_main_branch):svntrunk'
|
||||||
|
|
||||||
|
alias gk='\gitk --all --branches'
|
||||||
|
alias gke='\gitk --all $(git log -g --pretty=%h)'
|
||||||
|
|
||||||
|
alias gl='git pull'
|
||||||
|
alias glg='git log --stat'
|
||||||
|
alias glgp='git log --stat -p'
|
||||||
|
alias glgg='git log --graph'
|
||||||
|
alias glgga='git log --graph --decorate --all'
|
||||||
|
alias glgm='git log --graph --max-count=10'
|
||||||
|
alias glo='git log --oneline --decorate'
|
||||||
|
alias glol="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'"
|
||||||
|
alias glols="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --stat"
|
||||||
|
alias glod="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset'"
|
||||||
|
alias glods="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short"
|
||||||
|
alias glola="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --all"
|
||||||
|
alias glog='git log --oneline --decorate --graph'
|
||||||
|
alias gloga='git log --oneline --decorate --graph --all'
|
||||||
|
alias glp="_git_log_prettily"
|
||||||
|
|
||||||
|
alias gm='git merge'
|
||||||
|
alias gmom='git merge origin/$(git_main_branch)'
|
||||||
|
alias gmt='git mergetool --no-prompt'
|
||||||
|
alias gmtvim='git mergetool --no-prompt --tool=vimdiff'
|
||||||
|
alias gmum='git merge upstream/$(git_main_branch)'
|
||||||
|
alias gma='git merge --abort'
|
||||||
|
|
||||||
|
alias gp='git push'
|
||||||
|
alias gpd='git push --dry-run'
|
||||||
|
alias gpf='git push --force-with-lease'
|
||||||
|
alias gpf!='git push --force'
|
||||||
|
alias gpoat='git push origin --all && git push origin --tags'
|
||||||
|
alias gpu='git push upstream'
|
||||||
|
alias gpv='git push -v'
|
||||||
|
|
||||||
|
alias gr='git remote'
|
||||||
|
alias gra='git remote add'
|
||||||
|
alias grb='git rebase'
|
||||||
|
alias grba='git rebase --abort'
|
||||||
|
alias grbc='git rebase --continue'
|
||||||
|
alias grbd='git rebase develop'
|
||||||
|
alias grbi='git rebase -i'
|
||||||
|
alias grbm='git rebase $(git_main_branch)'
|
||||||
|
alias grbs='git rebase --skip'
|
||||||
|
alias grev='git revert'
|
||||||
|
alias grh='git reset'
|
||||||
|
alias grhh='git reset --hard'
|
||||||
|
alias groh='git reset origin/$(git_current_branch) --hard'
|
||||||
|
alias grm='git rm'
|
||||||
|
alias grmc='git rm --cached'
|
||||||
|
alias grmv='git remote rename'
|
||||||
|
alias grrm='git remote remove'
|
||||||
|
alias grs='git restore'
|
||||||
|
alias grset='git remote set-url'
|
||||||
|
alias grss='git restore --source'
|
||||||
|
alias grst='git restore --staged'
|
||||||
|
alias grt='cd "$(git rev-parse --show-toplevel || echo .)"'
|
||||||
|
alias gru='git reset --'
|
||||||
|
alias grup='git remote update'
|
||||||
|
alias grv='git remote -v'
|
||||||
|
|
||||||
|
alias gsb='git status -sb'
|
||||||
|
alias gsd='git svn dcommit'
|
||||||
|
alias gsh='git show'
|
||||||
|
alias gsi='git submodule init'
|
||||||
|
alias gsps='git show --pretty=short --show-signature'
|
||||||
|
alias gsr='git svn rebase'
|
||||||
|
alias gss='git status -s'
|
||||||
|
alias gst='git status'
|
||||||
|
|
||||||
|
# use the default stash push on git 2.13 and newer
|
||||||
|
is-at-least 2.13 "$git_version" \
|
||||||
|
&& alias gsta='git stash push' \
|
||||||
|
|| alias gsta='git stash save'
|
||||||
|
|
||||||
|
alias gstaa='git stash apply'
|
||||||
|
alias gstc='git stash clear'
|
||||||
|
alias gstd='git stash drop'
|
||||||
|
alias gstl='git stash list'
|
||||||
|
alias gstp='git stash pop'
|
||||||
|
alias gsts='git stash show --text'
|
||||||
|
alias gstu='git stash --include-untracked'
|
||||||
|
alias gstall='git stash --all'
|
||||||
|
alias gsu='git submodule update'
|
||||||
|
alias gsw='git switch'
|
||||||
|
alias gswc='git switch -c'
|
||||||
|
|
||||||
|
alias gts='git tag -s'
|
||||||
|
alias gtv='git tag | sort -V'
|
||||||
|
alias gtl='gtl(){ git tag --sort=-v:refname -n -l "${1}*" }; noglob gtl'
|
||||||
|
|
||||||
|
alias gunignore='git update-index --no-assume-unchanged'
|
||||||
|
alias gunwip='git log -n 1 | grep -q -c "\-\-wip\-\-" && git reset HEAD~1'
|
||||||
|
alias gup='git pull --rebase'
|
||||||
|
alias gupv='git pull --rebase -v'
|
||||||
|
alias gupa='git pull --rebase --autostash'
|
||||||
|
alias gupav='git pull --rebase --autostash -v'
|
||||||
|
alias glum='git pull upstream $(git_main_branch)'
|
||||||
|
|
||||||
|
alias gwch='git whatchanged -p --abbrev-commit --pretty=medium'
|
||||||
|
alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign -m "--wip-- [skip ci]"'
|
||||||
|
|
||||||
|
alias gam='git am'
|
||||||
|
alias gamc='git am --continue'
|
||||||
|
alias gams='git am --skip'
|
||||||
|
alias gama='git am --abort'
|
||||||
|
alias gamscp='git am --show-current-patch'
|
||||||
|
|
||||||
|
function grename() {
|
||||||
|
if [[ -z "$1" || -z "$2" ]]; then
|
||||||
|
echo "Usage: $0 old_branch new_branch"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Rename branch locally
|
||||||
|
git branch -m "$1" "$2"
|
||||||
|
# Rename branch in origin remote
|
||||||
|
if git push origin :"$1"; then
|
||||||
|
git push --set-upstream origin "$2"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
unset git_version
|
||||||
|
|
44
zsh/aliases/lol-aliases.zsh
Normal file
44
zsh/aliases/lol-aliases.zsh
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
# LOL!!1
|
||||||
|
# Source: https://aur.archlinux.org/packages/lolbash/lolbash/lolbash.sh
|
||||||
|
|
||||||
|
alias wtf='dmesg'
|
||||||
|
alias onoz='cat /var/log/errors.log'
|
||||||
|
alias rtfm='man'
|
||||||
|
|
||||||
|
alias :3='echo'
|
||||||
|
alias visible='echo'
|
||||||
|
alias invisible='cat'
|
||||||
|
alias moar='more'
|
||||||
|
alias tldr='less'
|
||||||
|
alias alwayz='tail -f'
|
||||||
|
|
||||||
|
alias icanhas='mkdir'
|
||||||
|
alias gimmeh='touch'
|
||||||
|
alias donotwant='rm'
|
||||||
|
alias dowant='cp'
|
||||||
|
alias gtfo='mv'
|
||||||
|
alias nowai='chmod'
|
||||||
|
|
||||||
|
alias hai='cd'
|
||||||
|
alias iz='ls'
|
||||||
|
alias plz='pwd'
|
||||||
|
alias ihasbucket='df -h'
|
||||||
|
|
||||||
|
alias inur='locate'
|
||||||
|
alias iminurbase='finger'
|
||||||
|
|
||||||
|
alias btw='nice'
|
||||||
|
alias obtw='nohup'
|
||||||
|
|
||||||
|
alias nomz='ps aux'
|
||||||
|
alias nomnom='killall'
|
||||||
|
|
||||||
|
alias byes='exit'
|
||||||
|
alias cyal8r='reboot'
|
||||||
|
|
||||||
|
alias rulz='git push'
|
||||||
|
alias bringz='git pull'
|
||||||
|
alias chicken='git add'
|
||||||
|
alias oanward='git commit -m'
|
||||||
|
|
||||||
|
|
59
zsh/aliases/npm-aliases.zsh
Normal file
59
zsh/aliases/npm-aliases.zsh
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
(( $+commands[npm] )) && {
|
||||||
|
rm -f "${ZSH_CACHE_DIR:-$ZSH/cache}/npm_completion"
|
||||||
|
|
||||||
|
_npm_completion() {
|
||||||
|
local si=$IFS
|
||||||
|
compadd -- $(COMP_CWORD=$((CURRENT-1)) \
|
||||||
|
COMP_LINE=$BUFFER \
|
||||||
|
COMP_POINT=0 \
|
||||||
|
npm completion -- "${words[@]}" \
|
||||||
|
2>/dev/null)
|
||||||
|
IFS=$si
|
||||||
|
}
|
||||||
|
compdef _npm_completion npm
|
||||||
|
}
|
||||||
|
|
||||||
|
# Install dependencies globally
|
||||||
|
alias npmg="npm i -g "
|
||||||
|
|
||||||
|
# npm package names are lowercase
|
||||||
|
# Thus, we've used camelCase for the following aliases:
|
||||||
|
|
||||||
|
# Install and save to dependencies in your package.json
|
||||||
|
# npms is used by https://www.npmjs.com/package/npms
|
||||||
|
alias npmS="npm i -S "
|
||||||
|
|
||||||
|
# Install and save to dev-dependencies in your package.json
|
||||||
|
# npmd is used by https://github.com/dominictarr/npmd
|
||||||
|
alias npmD="npm i -D "
|
||||||
|
|
||||||
|
# Execute command from node_modules folder based on current directory
|
||||||
|
# i.e npmE gulp
|
||||||
|
alias npmE='PATH="$(npm bin)":"$PATH"'
|
||||||
|
|
||||||
|
# Check which npm modules are outdated
|
||||||
|
alias npmO="npm outdated"
|
||||||
|
|
||||||
|
# Check package versions
|
||||||
|
alias npmV="npm -v"
|
||||||
|
|
||||||
|
# List packages
|
||||||
|
alias npmL="npm list"
|
||||||
|
|
||||||
|
# List top-level installed packages
|
||||||
|
alias npmL0="npm ls --depth=0"
|
||||||
|
|
||||||
|
# Run npm start
|
||||||
|
alias npmst="npm start"
|
||||||
|
|
||||||
|
# Run npm test
|
||||||
|
alias npmt="npm test"
|
||||||
|
|
||||||
|
# Run npm scripts
|
||||||
|
alias npmR="npm run"
|
||||||
|
|
||||||
|
# Run npm publish
|
||||||
|
alias npmP="npm publish"
|
||||||
|
|
||||||
|
# Run npm init
|
||||||
|
alias npmI="npm init"
|
99
zsh/aliases/tmux-aliases.zsh
Normal file
99
zsh/aliases/tmux-aliases.zsh
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
if ! (( $+commands[tmux] )); then
|
||||||
|
print "zsh tmux plugin: tmux not found. Please install tmux before using this plugin." >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ALIASES
|
||||||
|
|
||||||
|
alias ta='tmux attach -t'
|
||||||
|
alias tad='tmux attach -d -t'
|
||||||
|
alias ts='tmux new-session -s'
|
||||||
|
alias tl='tmux list-sessions'
|
||||||
|
alias tksv='tmux kill-server'
|
||||||
|
alias tkss='tmux kill-session -t'
|
||||||
|
|
||||||
|
# CONFIGURATION VARIABLES
|
||||||
|
# Automatically start tmux
|
||||||
|
: ${ZSH_TMUX_AUTOSTART:=false}
|
||||||
|
# Only autostart once. If set to false, tmux will attempt to
|
||||||
|
# autostart every time your zsh configs are reloaded.
|
||||||
|
: ${ZSH_TMUX_AUTOSTART_ONCE:=true}
|
||||||
|
# Automatically connect to a previous session if it exists
|
||||||
|
: ${ZSH_TMUX_AUTOCONNECT:=true}
|
||||||
|
# Automatically close the terminal when tmux exits
|
||||||
|
: ${ZSH_TMUX_AUTOQUIT:=$ZSH_TMUX_AUTOSTART}
|
||||||
|
# Set term to screen or screen-256color based on current terminal support
|
||||||
|
: ${ZSH_TMUX_FIXTERM:=true}
|
||||||
|
# Set '-CC' option for iTerm2 tmux integration
|
||||||
|
: ${ZSH_TMUX_ITERM2:=false}
|
||||||
|
# The TERM to use for non-256 color terminals.
|
||||||
|
# Tmux states this should be screen, but you may need to change it on
|
||||||
|
# systems without the proper terminfo
|
||||||
|
: ${ZSH_TMUX_FIXTERM_WITHOUT_256COLOR:=screen}
|
||||||
|
# The TERM to use for 256 color terminals.
|
||||||
|
# Tmux states this should be screen-256color, but you may need to change it on
|
||||||
|
# systems without the proper terminfo
|
||||||
|
: ${ZSH_TMUX_FIXTERM_WITH_256COLOR:=screen-256color}
|
||||||
|
# Set the configuration path
|
||||||
|
: ${ZSH_TMUX_CONFIG:=$HOME/.tmux.conf}
|
||||||
|
# Set -u option to support unicode
|
||||||
|
: ${ZSH_TMUX_UNICODE:=false}
|
||||||
|
|
||||||
|
# Determine if the terminal supports 256 colors
|
||||||
|
if [[ $terminfo[colors] == 256 ]]; then
|
||||||
|
export ZSH_TMUX_TERM=$ZSH_TMUX_FIXTERM_WITH_256COLOR
|
||||||
|
else
|
||||||
|
export ZSH_TMUX_TERM=$ZSH_TMUX_FIXTERM_WITHOUT_256COLOR
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Set the correct local config file to use.
|
||||||
|
if [[ "$ZSH_TMUX_ITERM2" == "false" && -e "$ZSH_TMUX_CONFIG" ]]; then
|
||||||
|
export ZSH_TMUX_CONFIG
|
||||||
|
export _ZSH_TMUX_FIXED_CONFIG="${0:h:a}/tmux.extra.conf"
|
||||||
|
else
|
||||||
|
export _ZSH_TMUX_FIXED_CONFIG="${0:h:a}/tmux.only.conf"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Wrapper function for tmux.
|
||||||
|
function _zsh_tmux_plugin_run() {
|
||||||
|
if [[ -n "$@" ]]; then
|
||||||
|
command tmux "$@"
|
||||||
|
return $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
local -a tmux_cmd
|
||||||
|
tmux_cmd=(command tmux)
|
||||||
|
[[ "$ZSH_TMUX_ITERM2" == "true" ]] && tmux_cmd+=(-CC)
|
||||||
|
[[ "$ZSH_TMUX_UNICODE" == "true" ]] && tmux_cmd+=(-u)
|
||||||
|
|
||||||
|
# Try to connect to an existing session.
|
||||||
|
[[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach
|
||||||
|
|
||||||
|
# If failed, just run tmux, fixing the TERM variable if requested.
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
if [[ "$ZSH_TMUX_FIXTERM" == "true" ]]; then
|
||||||
|
tmux_cmd+=(-f "$_ZSH_TMUX_FIXED_CONFIG")
|
||||||
|
elif [[ -e "$ZSH_TMUX_CONFIG" ]]; then
|
||||||
|
tmux_cmd+=(-f "$ZSH_TMUX_CONFIG")
|
||||||
|
fi
|
||||||
|
$tmux_cmd new-session
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$ZSH_TMUX_AUTOQUIT" == "true" ]]; then
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Use the completions for tmux for our function
|
||||||
|
compdef _tmux _zsh_tmux_plugin_run
|
||||||
|
# Alias tmux to our wrapper function.
|
||||||
|
alias tmux=_zsh_tmux_plugin_run
|
||||||
|
|
||||||
|
# Autostart if not already in tmux and enabled.
|
||||||
|
if [[ -z "$TMUX" && "$ZSH_TMUX_AUTOSTART" == "true" && -z "$INSIDE_EMACS" && -z "$EMACS" && -z "$VIM" ]]; then
|
||||||
|
# Actually don't autostart if we already did and multiple autostarts are disabled.
|
||||||
|
if [[ "$ZSH_TMUX_AUTOSTART_ONCE" == "false" || "$ZSH_TMUX_AUTOSTARTED" != "true" ]]; then
|
||||||
|
export ZSH_TMUX_AUTOSTARTED=true
|
||||||
|
_zsh_tmux_plugin_run
|
||||||
|
fi
|
||||||
|
fi
|
1603
zsh/p10k.zsh
Normal file
1603
zsh/p10k.zsh
Normal file
File diff suppressed because it is too large
Load Diff
48
zsh/plugins/colored-man-pages.zsh
Normal file
48
zsh/plugins/colored-man-pages.zsh
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
# Requires colors autoload.
|
||||||
|
# See termcap(5).
|
||||||
|
|
||||||
|
# Set up once, and then reuse. This way it supports user overrides after the
|
||||||
|
# plugin is loaded.
|
||||||
|
typeset -AHg less_termcap
|
||||||
|
|
||||||
|
# bold & blinking mode
|
||||||
|
less_termcap[mb]="${fg_bold[red]}"
|
||||||
|
less_termcap[md]="${fg_bold[red]}"
|
||||||
|
less_termcap[me]="${reset_color}"
|
||||||
|
# standout mode
|
||||||
|
less_termcap[so]="${fg_bold[yellow]}${bg[blue]}"
|
||||||
|
less_termcap[se]="${reset_color}"
|
||||||
|
# underlining
|
||||||
|
less_termcap[us]="${fg_bold[green]}"
|
||||||
|
less_termcap[ue]="${reset_color}"
|
||||||
|
|
||||||
|
# Absolute path to this file's directory.
|
||||||
|
typeset __colored_man_pages_dir="${0:A:h}"
|
||||||
|
|
||||||
|
function colored() {
|
||||||
|
local -a environment
|
||||||
|
|
||||||
|
# Convert associative array to plain array of NAME=VALUE items.
|
||||||
|
local k v
|
||||||
|
for k v in "${(@kv)less_termcap}"; do
|
||||||
|
environment+=( "LESS_TERMCAP_${k}=${v}" )
|
||||||
|
done
|
||||||
|
|
||||||
|
# Prefer `less` whenever available, since we specifically configured
|
||||||
|
# environment for it.
|
||||||
|
environment+=( PAGER="${commands[less]:-$PAGER}" )
|
||||||
|
|
||||||
|
# See ./nroff script.
|
||||||
|
if [[ "$OSTYPE" = solaris* ]]; then
|
||||||
|
environment+=( PATH="${__colored_man_pages_dir}:$PATH" )
|
||||||
|
fi
|
||||||
|
|
||||||
|
command env $environment "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Colorize man and dman/debman (from debian-goodies)
|
||||||
|
function man \
|
||||||
|
dman \
|
||||||
|
debman {
|
||||||
|
colored $0 "$@"
|
||||||
|
}
|
114
zsh/plugins/colorize.zsh
Normal file
114
zsh/plugins/colorize.zsh
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
# Easier alias to use the plugin
|
||||||
|
alias ccat="colorize_cat"
|
||||||
|
alias cless="colorize_less"
|
||||||
|
|
||||||
|
# '$0:A' gets the absolute path of this file
|
||||||
|
ZSH_COLORIZE_PLUGIN_PATH=$0:A
|
||||||
|
|
||||||
|
colorize_check_requirements() {
|
||||||
|
local -a available_tools
|
||||||
|
available_tools=("chroma" "pygmentize")
|
||||||
|
|
||||||
|
if [ -z "$ZSH_COLORIZE_TOOL" ]; then
|
||||||
|
if (( $+commands[pygmentize] )); then
|
||||||
|
ZSH_COLORIZE_TOOL="pygmentize"
|
||||||
|
elif (( $+commands[chroma] )); then
|
||||||
|
ZSH_COLORIZE_TOOL="chroma"
|
||||||
|
else
|
||||||
|
echo "Neither 'pygments' nor 'chroma' is installed!" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ${available_tools[(Ie)$ZSH_COLORIZE_TOOL]} -eq 0 ]]; then
|
||||||
|
echo "ZSH_COLORIZE_TOOL '$ZSH_COLORIZE_TOOL' not recognized. Available options are 'pygmentize' and 'chroma'." >&2
|
||||||
|
return 1
|
||||||
|
elif (( $+commands["$ZSH_COLORIZE_TOOL"] )); then
|
||||||
|
echo "Package '$ZSH_COLORIZE_TOOL' is not installed!" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
colorize_cat() {
|
||||||
|
if ! colorize_check_requirements; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If the environment variable ZSH_COLORIZE_STYLE
|
||||||
|
# is set, use that theme instead. Otherwise,
|
||||||
|
# use the default.
|
||||||
|
if [ -z "$ZSH_COLORIZE_STYLE" ]; then
|
||||||
|
# Both pygmentize & chroma support 'emacs'
|
||||||
|
ZSH_COLORIZE_STYLE="emacs"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use stdin if no arguments have been passed.
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
if [[ "$ZSH_COLORIZE_TOOL" == "pygmentize" ]]; then
|
||||||
|
pygmentize -O style="$ZSH_COLORIZE_STYLE" -g
|
||||||
|
else
|
||||||
|
chroma --style="$ZSH_COLORIZE_STYLE" --formatter="${ZSH_COLORIZE_CHROMA_FORMATTER:-terminal}"
|
||||||
|
fi
|
||||||
|
return $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Guess lexer from file extension, or guess it from file contents if unsuccessful.
|
||||||
|
local FNAME lexer
|
||||||
|
for FNAME in "$@"; do
|
||||||
|
if [[ "$ZSH_COLORIZE_TOOL" == "pygmentize" ]]; then
|
||||||
|
lexer=$(pygmentize -N "$FNAME")
|
||||||
|
if [[ $lexer != text ]]; then
|
||||||
|
pygmentize -O style="$ZSH_COLORIZE_STYLE" -l "$lexer" "$FNAME"
|
||||||
|
else
|
||||||
|
pygmentize -O style="$ZSH_COLORIZE_STYLE" -g "$FNAME"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
chroma --style="$ZSH_COLORIZE_STYLE" --formatter="${ZSH_COLORIZE_CHROMA_FORMATTER:-terminal}" "$FNAME"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# The less option 'F - Forward forever; like "tail -f".' will not work in this implementation
|
||||||
|
# caused by the lack of the ability to follow the file within pygmentize.
|
||||||
|
colorize_less() {
|
||||||
|
if ! colorize_check_requirements; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
_cless() {
|
||||||
|
# LESS="-R $LESS" enables raw ANSI colors, while maintain already set options.
|
||||||
|
local LESS="-R $LESS"
|
||||||
|
|
||||||
|
# This variable tells less to pipe every file through the specified command
|
||||||
|
# (see the man page of less INPUT PREPROCESSOR).
|
||||||
|
# 'zsh -ic "colorize_cat %s 2> /dev/null"' would not work for huge files like
|
||||||
|
# the ~/.zsh_history. For such files the tty of the preprocessor will be supended.
|
||||||
|
# Therefore we must source this file to make colorize_cat available in the
|
||||||
|
# preprocessor without the interactive mode.
|
||||||
|
# `2>/dev/null` will suppress the error for large files 'broken pipe' of the python
|
||||||
|
# script pygmentize, which will show up if less has not fully "loaded the file"
|
||||||
|
# (e.g. when not scrolled to the bottom) while already the next file will be displayed.
|
||||||
|
local LESSOPEN="| zsh -c 'source \"$ZSH_COLORIZE_PLUGIN_PATH\"; \
|
||||||
|
ZSH_COLORIZE_TOOL=$ZSH_COLORIZE_TOOL ZSH_COLORIZE_STYLE=$ZSH_COLORIZE_STYLE \
|
||||||
|
colorize_cat %s 2> /dev/null'"
|
||||||
|
|
||||||
|
# LESSCLOSE will be set to prevent any errors by executing a user script
|
||||||
|
# which assumes that his LESSOPEN has been executed.
|
||||||
|
local LESSCLOSE=""
|
||||||
|
|
||||||
|
LESS="$LESS" LESSOPEN="$LESSOPEN" LESSCLOSE="$LESSCLOSE" command less "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -t 0 ]; then
|
||||||
|
_cless "$@"
|
||||||
|
else
|
||||||
|
# The input is not associated with a terminal, therefore colorize_cat will
|
||||||
|
# colorize this input and pass it to less.
|
||||||
|
# Less has now to decide what to use. If any files have been provided, less
|
||||||
|
# will ignore the input by default, otherwise the colorized input will be used.
|
||||||
|
# If files have been supplied and the input has been redirected, this will
|
||||||
|
# lead to unnecessary overhead, but retains the ability to use the less options
|
||||||
|
# without checking for them inside this script.
|
||||||
|
colorize_cat | _cless "$@"
|
||||||
|
fi
|
||||||
|
}
|
3049
zsh/plugins/docker-auto-complete.zsh
Normal file
3049
zsh/plugins/docker-auto-complete.zsh
Normal file
File diff suppressed because it is too large
Load Diff
148
zsh/plugins/interactive-cd.zsh
Normal file
148
zsh/plugins/interactive-cd.zsh
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
# Copyright (c) 2017 Henry Chang
|
||||||
|
|
||||||
|
__zic_fzf_prog() {
|
||||||
|
[ -n "$TMUX_PANE" ] && [ "${FZF_TMUX:-0}" != 0 ] && [ ${LINES:-40} -gt 15 ] \
|
||||||
|
&& echo "fzf-tmux -d${FZF_TMUX_HEIGHT:-40%}" || echo "fzf"
|
||||||
|
}
|
||||||
|
|
||||||
|
__zic_matched_subdir_list() {
|
||||||
|
local dir length seg starts_with_dir
|
||||||
|
if [[ "$1" == */ ]]; then
|
||||||
|
dir="$1"
|
||||||
|
if [[ "$dir" != / ]]; then
|
||||||
|
dir="${dir: : -1}"
|
||||||
|
fi
|
||||||
|
length=$(echo -n "$dir" | wc -c)
|
||||||
|
if [ "$dir" = "/" ]; then
|
||||||
|
length=0
|
||||||
|
fi
|
||||||
|
find -L "$dir" -mindepth 1 -maxdepth 1 -type d 2>/dev/null \
|
||||||
|
| cut -b $(( ${length} + 2 ))- | sed '/^$/d' | while read -r line; do
|
||||||
|
if [[ "${line[1]}" == "." ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
echo "$line"
|
||||||
|
done
|
||||||
|
else
|
||||||
|
dir=$(dirname -- "$1")
|
||||||
|
length=$(echo -n "$dir" | wc -c)
|
||||||
|
if [ "$dir" = "/" ]; then
|
||||||
|
length=0
|
||||||
|
fi
|
||||||
|
seg=$(basename -- "$1")
|
||||||
|
starts_with_dir=$( \
|
||||||
|
find -L "$dir" -mindepth 1 -maxdepth 1 -type d \
|
||||||
|
2>/dev/null | cut -b $(( ${length} + 2 ))- | sed '/^$/d' \
|
||||||
|
| while read -r line; do
|
||||||
|
if [[ "${seg[1]}" != "." && "${line[1]}" == "." ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
if [[ "$line" == "$seg"* ]]; then
|
||||||
|
echo "$line"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
)
|
||||||
|
if [ -n "$starts_with_dir" ]; then
|
||||||
|
echo "$starts_with_dir"
|
||||||
|
else
|
||||||
|
find -L "$dir" -mindepth 1 -maxdepth 1 -type d \
|
||||||
|
2>/dev/null | cut -b $(( ${length} + 2 ))- | sed '/^$/d' \
|
||||||
|
| while read -r line; do
|
||||||
|
if [[ "${seg[1]}" != "." && "${line[1]}" == "." ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
if [[ "$line" == *"$seg"* ]]; then
|
||||||
|
echo "$line"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
_zic_list_generator() {
|
||||||
|
__zic_matched_subdir_list "${(Q)@[-1]}" | sort
|
||||||
|
}
|
||||||
|
|
||||||
|
_zic_complete() {
|
||||||
|
setopt localoptions nonomatch
|
||||||
|
local l matches fzf tokens base
|
||||||
|
|
||||||
|
l=$(_zic_list_generator $@)
|
||||||
|
|
||||||
|
if [ -z "$l" ]; then
|
||||||
|
zle ${__zic_default_completion:-expand-or-complete}
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
fzf=$(__zic_fzf_prog)
|
||||||
|
|
||||||
|
if [ $(echo $l | wc -l) -eq 1 ]; then
|
||||||
|
matches=${(q)l}
|
||||||
|
else
|
||||||
|
matches=$(echo $l \
|
||||||
|
| FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} \
|
||||||
|
--reverse $FZF_DEFAULT_OPTS $FZF_COMPLETION_OPTS \
|
||||||
|
--bind 'shift-tab:up,tab:down'" ${=fzf} \
|
||||||
|
| while read -r item; do
|
||||||
|
echo -n "${(q)item} "
|
||||||
|
done)
|
||||||
|
fi
|
||||||
|
|
||||||
|
matches=${matches% }
|
||||||
|
if [ -n "$matches" ]; then
|
||||||
|
tokens=(${(z)LBUFFER})
|
||||||
|
base="${(Q)@[-1]}"
|
||||||
|
if [[ "$base" != */ ]]; then
|
||||||
|
if [[ "$base" == */* ]]; then
|
||||||
|
base="$(dirname -- "$base")"
|
||||||
|
if [[ ${base[-1]} != / ]]; then
|
||||||
|
base="$base/"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
base=""
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
LBUFFER="${tokens[1]} "
|
||||||
|
if [ -n "$base" ]; then
|
||||||
|
base="${(q)base}"
|
||||||
|
if [ "${tokens[2][1]}" = "~" ]; then
|
||||||
|
base="${base/#$HOME/~}"
|
||||||
|
fi
|
||||||
|
LBUFFER="${LBUFFER}${base}"
|
||||||
|
fi
|
||||||
|
LBUFFER="${LBUFFER}${matches}/"
|
||||||
|
fi
|
||||||
|
zle redisplay
|
||||||
|
typeset -f zle-line-init >/dev/null && zle zle-line-init
|
||||||
|
}
|
||||||
|
|
||||||
|
zic-completion() {
|
||||||
|
setopt localoptions noshwordsplit noksh_arrays noposixbuiltins
|
||||||
|
local tokens cmd
|
||||||
|
|
||||||
|
tokens=(${(z)LBUFFER})
|
||||||
|
cmd=${tokens[1]}
|
||||||
|
|
||||||
|
if [[ "$LBUFFER" =~ "^\ *cd$" ]]; then
|
||||||
|
zle ${__zic_default_completion:-expand-or-complete}
|
||||||
|
elif [ "$cmd" = cd ]; then
|
||||||
|
_zic_complete ${tokens[2,${#tokens}]/#\~/$HOME}
|
||||||
|
else
|
||||||
|
zle ${__zic_default_completion:-expand-or-complete}
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
[ -z "$__zic_default_completion" ] && {
|
||||||
|
binding=$(bindkey '^I')
|
||||||
|
# $binding[(s: :w)2]
|
||||||
|
# The command substitution and following word splitting to determine the
|
||||||
|
# default zle widget for ^I formerly only works if the IFS parameter contains
|
||||||
|
# a space via $binding[(w)2]. Now it specifically splits at spaces, regardless
|
||||||
|
# of IFS.
|
||||||
|
[[ $binding =~ 'undefined-key' ]] || __zic_default_completion=$binding[(s: :w)2]
|
||||||
|
unset binding
|
||||||
|
}
|
||||||
|
|
||||||
|
zle -N zic-completion
|
||||||
|
bindkey -M emacs '^I' zic-completion
|
||||||
|
bindkey -M viins '^I' zic-completion
|
115
zsh/plugins/ufw.zsh
Normal file
115
zsh/plugins/ufw.zsh
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
#compdef ufw
|
||||||
|
#autoload
|
||||||
|
|
||||||
|
typeset -A opt_args
|
||||||
|
|
||||||
|
function _ufw_delete_rules {
|
||||||
|
if ufw status &> /dev/null ; then
|
||||||
|
ufw status numbered \
|
||||||
|
| perl -n -e'/\[ +(\d+)\] +([^ ].+)/ && print "\"$1\[$2\]\" "'
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function _ufw_app_profiles {
|
||||||
|
grep -rhoP "(?<=\[)[^\]]+" /etc/ufw/applications.d/ \
|
||||||
|
| awk '{ print "\""$0"\""}' \
|
||||||
|
| tr '\n' ' '
|
||||||
|
}
|
||||||
|
|
||||||
|
local -a _1st_arguments
|
||||||
|
_1st_arguments=(
|
||||||
|
'allow:add allow rule'
|
||||||
|
'app:Application profile commands'
|
||||||
|
'default:set default policy'
|
||||||
|
'delete:delete RULE'
|
||||||
|
'deny:add deny rule'
|
||||||
|
'disable:disables the firewall'
|
||||||
|
'enable:enables the firewall'
|
||||||
|
'insert:insert RULE at NUM'
|
||||||
|
'limit:add limit rule'
|
||||||
|
'logging:set logging to LEVEL'
|
||||||
|
'reject:add reject rule'
|
||||||
|
'reload:reloads firewall'
|
||||||
|
'reset:reset firewall'
|
||||||
|
'show:show firewall report'
|
||||||
|
'status:show firewall status'
|
||||||
|
'version:display version information'
|
||||||
|
)
|
||||||
|
|
||||||
|
local context state line curcontext="$curcontext"
|
||||||
|
|
||||||
|
_arguments -C \
|
||||||
|
'(--dry-run)--dry-run[dry run]' \
|
||||||
|
'1:: :->cmds' \
|
||||||
|
'2:: :->subcmds' \
|
||||||
|
'3:: :->subsubcmds' \
|
||||||
|
&& return 0
|
||||||
|
|
||||||
|
local rules
|
||||||
|
|
||||||
|
case "$state" in
|
||||||
|
(cmds)
|
||||||
|
_describe -t commands "ufw commands" _1st_arguments
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
(subcmds)
|
||||||
|
case "$line[1]" in
|
||||||
|
(app)
|
||||||
|
_values 'app' \
|
||||||
|
'list[list application profiles]' \
|
||||||
|
'info[show information on PROFILE]' \
|
||||||
|
'update[update PROFILE]' \
|
||||||
|
'default[set default application policy]' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
(status)
|
||||||
|
_values 'status' \
|
||||||
|
'numbered[show firewall status as numbered list of RULES]' \
|
||||||
|
'verbose[show verbose firewall status]' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
(logging)
|
||||||
|
_values 'logging' \
|
||||||
|
'on' 'off' 'low' 'medium' 'high' 'full' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
(default)
|
||||||
|
_values 'default' \
|
||||||
|
'allow' 'deny' 'reject' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
(show)
|
||||||
|
_values 'show' \
|
||||||
|
'raw' 'builtins' 'before-rules' 'user-rules' 'after-rules' 'logging-rules' 'listening' 'added' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
(delete)
|
||||||
|
rules="$(_ufw_delete_rules)"
|
||||||
|
if [[ -n "$rules" ]] ; then
|
||||||
|
_values 'delete' \
|
||||||
|
${(Q)${(z)"$(_ufw_delete_rules)"}} \
|
||||||
|
&& ret=0
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
(subsubcmds)
|
||||||
|
case "$line[1]" in
|
||||||
|
(app)
|
||||||
|
case "$line[2]" in
|
||||||
|
(info|update)
|
||||||
|
_values 'profiles' \
|
||||||
|
${(Q)${(z)"$(_ufw_app_profiles)"}} \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
(default)
|
||||||
|
_values 'default-direction' \
|
||||||
|
'incoming' 'outgoing' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
esac
|
||||||
|
|
||||||
|
return
|
49
zsh/zshrc
49
zsh/zshrc
@ -1,23 +1,48 @@
|
|||||||
|
# Enable Powerlevel10k Prompt
|
||||||
|
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
|
||||||
|
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
|
||||||
|
fi
|
||||||
|
|
||||||
ZSH_BASE=$HOME/dotfiles
|
|
||||||
|
|
||||||
source ~/.zsh/antigen/antigen.zsh
|
# Specify directory for Antigen bundles
|
||||||
|
ADOTDIR=$HOME/.zsh/antigen-bundles
|
||||||
|
|
||||||
|
# Include Antigen Script
|
||||||
|
source $HOME/.zsh/antigen/antigen.zsh
|
||||||
|
|
||||||
# Load the oh-my-zsh's library.
|
# Load the oh-my-zsh's library.
|
||||||
antigen use oh-my-zsh
|
antigen use oh-my-zsh
|
||||||
|
|
||||||
# Bundles from the default repo (robbyrussell's oh-my-zsh).
|
# Import local plugins
|
||||||
antigen bundle git
|
source $HOME/.zsh/plugins/colored-man-pages.zsh
|
||||||
antigen bundle heroku
|
source $HOME/.zsh/plugins/colorize.zsh
|
||||||
antigen bundle pip
|
source $HOME/.zsh/plugins/docker-auto-complete.zsh
|
||||||
antigen bundle lein
|
source $HOME/.zsh/plugins/interactive-cd.zsh
|
||||||
antigen bundle command-not-found
|
|
||||||
|
# Import local aliases
|
||||||
|
source $HOME/.zsh/aliases/ansible-aliases.zsh
|
||||||
|
source $HOME/.zsh/aliases/common-aliases.zsh
|
||||||
|
#source $HOME/.zsh/aliases/git-aliases.zsh
|
||||||
|
source $HOME/.zsh/aliases/lol-aliases.zsh
|
||||||
|
source $HOME/.zsh/aliases/npm-aliases.zsh
|
||||||
|
source $HOME/.zsh/aliases/tmux-aliases.zsh
|
||||||
|
|
||||||
|
|
||||||
|
# Add plugins to bundle
|
||||||
|
antigen bundles <<EOBUNDLES
|
||||||
|
command-not-found
|
||||||
|
zsh-users/zsh-autosuggestions
|
||||||
|
zsh-users/zsh-syntax-highlighting
|
||||||
|
psprint/zsh-navigation-tools
|
||||||
|
EOBUNDLES
|
||||||
|
|
||||||
# Syntax highlighting bundle.
|
|
||||||
antigen bundle zsh-users/zsh-syntax-highlighting
|
|
||||||
|
|
||||||
# Load the theme.
|
# Load the theme.
|
||||||
antigen theme robbyrussell
|
antigen theme romkatv/powerlevel10k
|
||||||
|
|
||||||
# Tell Antigen that you're done.
|
|
||||||
|
# I'm done- let's go
|
||||||
antigen apply
|
antigen apply
|
||||||
|
|
||||||
|
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
|
||||||
|
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
|
||||||
|
Loading…
x
Reference in New Issue
Block a user