added new stuff
This commit is contained in:
parent
5024639019
commit
a0d198cdcb
17 changed files with 4244 additions and 5 deletions
33
config/zsh/zshrc.d/cnf.zsh
Normal file
33
config/zsh/zshrc.d/cnf.zsh
Normal file
|
@ -0,0 +1,33 @@
|
|||
# Uses the command-not-found package zsh support
|
||||
# as seen in http://www.porcheron.info/command-not-found-for-zsh/
|
||||
# this is installed in Ubuntu
|
||||
|
||||
[[ -e /etc/zsh_command_not_found ]] && source /etc/zsh_command_not_found
|
||||
|
||||
# Arch Linux command-not-found support, you must have package pkgfile installed
|
||||
# https://wiki.archlinux.org/index.php/Pkgfile#.22Command_not_found.22_hook
|
||||
[[ -e /usr/share/doc/pkgfile/command-not-found.zsh ]] && source /usr/share/doc/pkgfile/command-not-found.zsh
|
||||
|
||||
# Fedora command-not-found support
|
||||
if [ -f /usr/libexec/pk-command-not-found ]; then
|
||||
command_not_found_handler () {
|
||||
runcnf=1
|
||||
retval=127
|
||||
[ ! -S /var/run/dbus/system_bus_socket ] && runcnf=0
|
||||
[ ! -x /usr/libexec/packagekitd ] && runcnf=0
|
||||
if [ $runcnf -eq 1 ]
|
||||
then
|
||||
/usr/libexec/pk-command-not-found $@
|
||||
retval=$?
|
||||
fi
|
||||
return $retval
|
||||
}
|
||||
fi
|
||||
|
||||
# OSX command-not-found support
|
||||
# https://github.com/Homebrew/homebrew-command-not-found
|
||||
if type brew &> /dev/null; then
|
||||
if brew command command-not-found-init > /dev/null 2>&1; then
|
||||
eval "$(brew command-not-found-init)";
|
||||
fi
|
||||
fi
|
23
config/zsh/zshrc.d/dcompose.zsh
Normal file
23
config/zsh/zshrc.d/dcompose.zsh
Normal file
|
@ -0,0 +1,23 @@
|
|||
# Authors:
|
||||
# https://github.com/tristola
|
||||
#
|
||||
# Docker-compose related zsh aliases
|
||||
|
||||
# Aliases ###################################################################
|
||||
|
||||
# Use dco as alias for docker-compose, since dc on *nix is 'dc - an arbitrary precision calculator'
|
||||
# https://www.gnu.org/software/bc/manual/dc-1.05/html_mono/dc.html
|
||||
|
||||
alias dco='docker-compose'
|
||||
|
||||
alias dcb='docker-compose build'
|
||||
alias dce='docker-compose exec'
|
||||
alias dcps='docker-compose ps'
|
||||
alias dcrestart='docker-compose restart'
|
||||
alias dcrm='docker-compose rm'
|
||||
alias dcr='docker-compose run'
|
||||
alias dcstop='docker-compose stop'
|
||||
alias dcup='docker-compose up'
|
||||
alias dcdn='docker-compose down'
|
||||
alias dcl='docker-compose logs'
|
||||
alias dclf='docker-compose logs -f'
|
72
config/zsh/zshrc.d/extract.zsh
Normal file
72
config/zsh/zshrc.d/extract.zsh
Normal file
|
@ -0,0 +1,72 @@
|
|||
alias x=extract
|
||||
|
||||
extract() {
|
||||
local remove_archive
|
||||
local success
|
||||
local extract_dir
|
||||
|
||||
if (( $# == 0 )); then
|
||||
cat <<-'EOF' >&2
|
||||
Usage: extract [-option] [file ...]
|
||||
|
||||
Options:
|
||||
-r, --remove Remove archive.
|
||||
EOF
|
||||
fi
|
||||
|
||||
remove_archive=1
|
||||
if [[ "$1" == "-r" ]] || [[ "$1" == "--remove" ]]; then
|
||||
remove_archive=0
|
||||
shift
|
||||
fi
|
||||
|
||||
while (( $# > 0 )); do
|
||||
if [[ ! -f "$1" ]]; then
|
||||
echo "extract: '$1' is not a valid file" >&2
|
||||
shift
|
||||
continue
|
||||
fi
|
||||
|
||||
success=0
|
||||
extract_dir="${1:t:r}"
|
||||
case "$1" in
|
||||
(*.tar.gz|*.tgz) (( $+commands[pigz] )) && { pigz -dc "$1" | tar xv } || tar zxvf "$1" ;;
|
||||
(*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;;
|
||||
(*.tar.xz|*.txz)
|
||||
tar --xz --help &> /dev/null \
|
||||
&& tar --xz -xvf "$1" \
|
||||
|| xzcat "$1" | tar xvf - ;;
|
||||
(*.tar.zma|*.tlz)
|
||||
tar --lzma --help &> /dev/null \
|
||||
&& tar --lzma -xvf "$1" \
|
||||
|| lzcat "$1" | tar xvf - ;;
|
||||
(*.tar) tar xvf "$1" ;;
|
||||
(*.gz) (( $+commands[pigz] )) && pigz -d "$1" || gunzip "$1" ;;
|
||||
(*.bz2) bunzip2 "$1" ;;
|
||||
(*.xz) unxz "$1" ;;
|
||||
(*.lzma) unlzma "$1" ;;
|
||||
(*.Z) uncompress "$1" ;;
|
||||
(*.zip|*.war|*.jar|*.sublime-package|*.ipsw|*.xpi|*.apk) unzip "$1" -d $extract_dir ;;
|
||||
(*.rar) unrar x -ad "$1" ;;
|
||||
(*.7z) 7za x "$1" ;;
|
||||
(*.deb)
|
||||
mkdir -p "$extract_dir/control"
|
||||
mkdir -p "$extract_dir/data"
|
||||
cd "$extract_dir"; ar vx "../${1}" > /dev/null
|
||||
cd control; tar xzvf ../control.tar.gz
|
||||
cd ../data; extract ../data.tar.*
|
||||
cd ..; rm *.tar.* debian-binary
|
||||
cd ..
|
||||
;;
|
||||
(*)
|
||||
echo "extract: '$1' cannot be extracted" >&2
|
||||
success=1
|
||||
;;
|
||||
esac
|
||||
|
||||
(( success = $success > 0 ? $success : $? ))
|
||||
(( $success == 0 )) && (( $remove_archive == 0 )) && rm "$1"
|
||||
shift
|
||||
done
|
||||
}
|
||||
|
242
config/zsh/zshrc.d/git.zsh
Normal file
242
config/zsh/zshrc.d/git.zsh
Normal file
|
@ -0,0 +1,242 @@
|
|||
# Query/use custom command for `git`.
|
||||
zstyle -s ":vcs_info:git:*:-all-" "command" _omz_git_git_cmd
|
||||
: ${_omz_git_git_cmd:=git}
|
||||
|
||||
#
|
||||
# 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
|
||||
}
|
||||
# The list of remotes
|
||||
function current_repository() {
|
||||
if ! $_omz_git_git_cmd rev-parse --is-inside-work-tree &> /dev/null; then
|
||||
return
|
||||
fi
|
||||
echo $($_omz_git_git_cmd remote -v | cut -d':' -f 2)
|
||||
}
|
||||
# Pretty log messages
|
||||
function _git_log_prettily(){
|
||||
if ! [ -z $1 ]; then
|
||||
git log --pretty=$1
|
||||
fi
|
||||
}
|
||||
# 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
|
||||
}
|
||||
|
||||
#
|
||||
# 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 gb='git branch'
|
||||
alias gba='git branch -a'
|
||||
alias gbd='git branch -d'
|
||||
alias gbda='git branch --no-color --merged | command grep -vE "^(\*|\s*(master|develop|dev)\s*$)" | command xargs -n 1 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 --recursive'
|
||||
alias gclean='git clean -fd'
|
||||
alias gpristine='git reset --hard && git clean -dfx'
|
||||
alias gcm='git checkout master'
|
||||
alias gcd='git checkout develop'
|
||||
alias gcmsg='git commit -m'
|
||||
alias gco='git checkout'
|
||||
alias gcount='git shortlog -sn'
|
||||
compdef _git gcount
|
||||
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 gdct='git describe --tags `git rev-list --tags --max-count=1`'
|
||||
alias gdt='git diff-tree --no-commit-id --name-only -r'
|
||||
alias gdw='git diff --word-diff'
|
||||
|
||||
gdv() { git diff -w "$@" | view - }
|
||||
compdef _git gdv=git-diff
|
||||
|
||||
alias gf='git fetch'
|
||||
alias gfa='git fetch --all --prune'
|
||||
alias gfo='git fetch origin'
|
||||
|
||||
function gfg() { git ls-files | grep $@ }
|
||||
compdef _grep gfg
|
||||
|
||||
alias gg='git gui citool'
|
||||
alias gga='git gui citool --amend'
|
||||
|
||||
ggf() {
|
||||
[[ "$#" != 1 ]] && local b="$(git_current_branch)"
|
||||
git push --force origin "${b:=$1}"
|
||||
}
|
||||
compdef _git ggf=git-checkout
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
ggpnp() {
|
||||
if [[ "$#" == 0 ]]; then
|
||||
ggl && ggp
|
||||
else
|
||||
ggl "${*}" && ggp "${*}"
|
||||
fi
|
||||
}
|
||||
compdef _git ggpnp=git-checkout
|
||||
|
||||
ggu() {
|
||||
[[ "$#" != 1 ]] && local b="$(git_current_branch)"
|
||||
git pull --rebase origin "${b:=$1}"
|
||||
}
|
||||
compdef _git ggu=git-checkout
|
||||
|
||||
alias ggpur='ggu'
|
||||
compdef _git ggpur=git-checkout
|
||||
|
||||
alias ggpull='git pull origin $(git_current_branch)'
|
||||
compdef _git ggpull=git-checkout
|
||||
|
||||
alias ggpush='git push origin $(git_current_branch)'
|
||||
compdef _git ggpush=git-checkout
|
||||
|
||||
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 master:svntrunk'
|
||||
compdef _git git-svn-dcommit-push=git
|
||||
|
||||
alias gk='\gitk --all --branches'
|
||||
compdef _git gk='gitk'
|
||||
alias gke='\gitk --all $(git log -g --pretty=%h)'
|
||||
compdef _git gke='gitk'
|
||||
|
||||
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(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
|
||||
alias glola="git log --graph --pretty='%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --all"
|
||||
alias glog='git log --oneline --decorate --graph'
|
||||
alias gloga='git log --oneline --decorate --graph --all'
|
||||
alias glp="_git_log_prettily"
|
||||
compdef _git glp=git-log
|
||||
|
||||
alias gm='git merge'
|
||||
alias gmom='git merge origin/master'
|
||||
alias gmt='git mergetool --no-prompt'
|
||||
alias gmtvim='git mergetool --no-prompt --tool=vimdiff'
|
||||
alias gmum='git merge upstream/master'
|
||||
|
||||
alias gp='git push'
|
||||
alias gpd='git push --dry-run'
|
||||
alias gpoat='git push origin --all && git push origin --tags'
|
||||
compdef _git gpoat=git-push
|
||||
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 grbi='git rebase -i'
|
||||
alias grbm='git rebase master'
|
||||
alias grbs='git rebase --skip'
|
||||
alias grh='git reset HEAD'
|
||||
alias grhh='git reset HEAD --hard'
|
||||
alias grmv='git remote rename'
|
||||
alias grrm='git remote remove'
|
||||
alias grset='git remote set-url'
|
||||
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 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'
|
||||
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 gsu='git submodule update'
|
||||
|
||||
alias gts='git tag -s'
|
||||
alias gtv='git tag | sort -V'
|
||||
|
||||
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 glum='git pull upstream master'
|
||||
|
||||
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 -m "--wip-- [skip ci]"'
|
||||
|
16
config/zsh/zshrc.d/systemd.zsh
Normal file
16
config/zsh/zshrc.d/systemd.zsh
Normal file
|
@ -0,0 +1,16 @@
|
|||
user_commands=(
|
||||
list-units is-active status show help list-unit-files
|
||||
is-enabled list-jobs show-environment cat list-timers)
|
||||
|
||||
sudo_commands=(
|
||||
start stop reload restart try-restart isolate kill
|
||||
reset-failed enable disable reenable preset mask unmask
|
||||
link load cancel set-environment unset-environment
|
||||
edit daemon-reload)
|
||||
|
||||
for c in $user_commands; do; alias sc-$c="systemctl $c"; done
|
||||
for c in $sudo_commands; do; alias sc-$c="sudo systemctl $c"; done
|
||||
|
||||
alias sc-enable-now="sc-enable --now"
|
||||
alias sc-disable-now="sc-disable --now"
|
||||
alias sc-mask-now="sc-mask --now"
|
99
config/zsh/zshrc.d/tmux.zsh
Normal file
99
config/zsh/zshrc.d/tmux.zsh
Normal file
|
@ -0,0 +1,99 @@
|
|||
#
|
||||
# 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'
|
||||
|
||||
# Only run if tmux is actually installed
|
||||
if which tmux &> /dev/null
|
||||
then
|
||||
# Configuration variables
|
||||
#
|
||||
# Automatically start tmux
|
||||
[[ -n "$ZSH_TMUX_AUTOSTART" ]] || ZSH_TMUX_AUTOSTART=false
|
||||
# Only autostart once. If set to false, tmux will attempt to
|
||||
# autostart every time your zsh configs are reloaded.
|
||||
[[ -n "$ZSH_TMUX_AUTOSTART_ONCE" ]] || ZSH_TMUX_AUTOSTART_ONCE=true
|
||||
# Automatically connect to a previous session if it exists
|
||||
[[ -n "$ZSH_TMUX_AUTOCONNECT" ]] || ZSH_TMUX_AUTOCONNECT=true
|
||||
# Automatically close the terminal when tmux exits
|
||||
[[ -n "$ZSH_TMUX_AUTOQUIT" ]] || ZSH_TMUX_AUTOQUIT=$ZSH_TMUX_AUTOSTART
|
||||
# Set term to screen or screen-256color based on current terminal support
|
||||
[[ -n "$ZSH_TMUX_FIXTERM" ]] || ZSH_TMUX_FIXTERM=true
|
||||
# Set '-CC' option for iTerm2 tmux integration
|
||||
[[ -n "$ZSH_TMUX_ITERM2" ]] || 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
|
||||
[[ -n "$ZSH_TMUX_FIXTERM_WITHOUT_256COLOR" ]] || 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
|
||||
[[ -n "$ZSH_TMUX_FIXTERM_WITH_256COLOR" ]] || ZSH_TMUX_FIXTERM_WITH_256COLOR="screen-256color"
|
||||
|
||||
|
||||
# Get the absolute path to the current directory
|
||||
local zsh_tmux_plugin_path="$(cd "$(dirname "$0")" && pwd)"
|
||||
|
||||
# Determine if the terminal supports 256 colors
|
||||
if [[ `tput 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" ]] && [[ -f $HOME/.tmux.conf || -h $HOME/.tmux.conf ]]
|
||||
then
|
||||
#use this when they have a ~/.tmux.conf
|
||||
export _ZSH_TMUX_FIXED_CONFIG="$zsh_tmux_plugin_path/tmux.extra.conf"
|
||||
else
|
||||
#use this when they don't have a ~/.tmux.conf
|
||||
export _ZSH_TMUX_FIXED_CONFIG="$zsh_tmux_plugin_path/tmux.only.conf"
|
||||
fi
|
||||
|
||||
# Wrapper function for tmux.
|
||||
function _zsh_tmux_plugin_run()
|
||||
{
|
||||
# We have other arguments, just run them
|
||||
if [[ -n "$@" ]]
|
||||
then
|
||||
\tmux $@
|
||||
# Try to connect to an existing session.
|
||||
elif [[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]]
|
||||
then
|
||||
\tmux `[[ "$ZSH_TMUX_ITERM2" == "true" ]] && echo '-CC '` attach || \tmux `[[ "$ZSH_TMUX_ITERM2" == "true" ]] && echo '-CC '` `[[ "$ZSH_TMUX_FIXTERM" == "true" ]] && echo '-f '$_ZSH_TMUX_FIXED_CONFIG` new-session
|
||||
[[ "$ZSH_TMUX_AUTOQUIT" == "true" ]] && exit
|
||||
# Just run tmux, fixing the TERM variable if requested.
|
||||
else
|
||||
\tmux `[[ "$ZSH_TMUX_ITERM2" == "true" ]] && echo '-CC '` `[[ "$ZSH_TMUX_FIXTERM" == "true" ]] && echo '-f '$_ZSH_TMUX_FIXED_CONFIG`
|
||||
[[ "$ZSH_TMUX_AUTOQUIT" == "true" ]] && 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 [[ ! -n "$TMUX" && "$ZSH_TMUX_AUTOSTART" == "true" ]]
|
||||
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
|
||||
else
|
||||
print "zsh tmux plugin: tmux not found. Please install tmux before using this plugin."
|
||||
fi
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue