2017-02-22 10:30:28 +00:00
|
|
|
#!/usr/bin/zsh
|
|
|
|
|
2016-03-31 02:03:55 +00:00
|
|
|
# Common Aliases
|
2016-04-23 12:18:13 +00:00
|
|
|
alias -g ...=../..
|
|
|
|
alias -g ....=../../..
|
|
|
|
alias -g .....=../../../..
|
|
|
|
alias -g ......=../../../../..
|
2016-03-31 02:03:55 +00:00
|
|
|
|
|
|
|
alias ..la="cd ..;la"
|
|
|
|
alias ..ll="cd..;ll"
|
|
|
|
alias ..l="..ll"
|
|
|
|
|
|
|
|
alias l=ll
|
|
|
|
alias ll="ls -lFh"
|
|
|
|
alias la="ls -lAFh"
|
2016-05-01 13:29:03 +00:00
|
|
|
alias lat='la -t'
|
2016-04-01 12:55:26 +00:00
|
|
|
alias al=la # No, I don't need the Mono Assembly Linker
|
2016-03-31 02:03:55 +00:00
|
|
|
|
|
|
|
alias md="mkdir -p"
|
|
|
|
mcd(){
|
2016-08-03 16:10:37 +00:00
|
|
|
mkdir -p $1 && cd $1
|
2016-03-31 02:03:55 +00:00
|
|
|
}
|
2017-11-10 12:31:33 +00:00
|
|
|
alias cdt='cd `mktemp -d`'
|
2016-03-31 18:21:23 +00:00
|
|
|
alias grep='grep --color'
|
|
|
|
alias -g H='| head'
|
|
|
|
alias -g T='| tail'
|
|
|
|
alias -g G='| grep'
|
|
|
|
alias -g L="| less"
|
2016-04-01 16:54:28 +00:00
|
|
|
alias -g C="| wc -l"
|
2016-04-02 17:25:04 +00:00
|
|
|
alias -g S="| sort"
|
2016-05-21 12:48:25 +00:00
|
|
|
alias -g U="| uniq"
|
2016-04-01 16:54:28 +00:00
|
|
|
alias -g count="| wc -l"
|
2016-03-31 18:21:23 +00:00
|
|
|
alias -g NE="2> /dev/null"
|
2016-04-16 17:00:03 +00:00
|
|
|
alias -g NUL="&> /dev/null"
|
|
|
|
alias -g BG="&;disown"
|
2016-04-23 12:18:54 +00:00
|
|
|
alias -g COL="| column -t"
|
2016-10-04 23:47:17 +00:00
|
|
|
alias -g CLIP="| xclip -i -selection primary -f | xclip -i -selection clipboard"
|
2017-08-27 15:41:16 +00:00
|
|
|
calc() { bc -l <<< "$@"; }
|
2016-03-31 02:03:55 +00:00
|
|
|
|
|
|
|
alias svi=sudoedit
|
2016-04-23 12:18:54 +00:00
|
|
|
# This will enable us to use aliases in sudo.
|
|
|
|
# (If alias finishes with a space or tab, the shell will check if the next command is also aliased.)
|
|
|
|
# Source: https://github.com/mayah/home/blob/master/.zsh/zshrc.d/alias.zsh
|
2017-02-25 02:46:21 +00:00
|
|
|
alias sudo='sudo -E '
|
2016-04-30 13:18:38 +00:00
|
|
|
alias open=xdg-open
|
2016-03-31 02:03:55 +00:00
|
|
|
|
2016-04-30 13:18:38 +00:00
|
|
|
# Command rewrites
|
2016-05-01 13:29:37 +00:00
|
|
|
alias ls='ls --color=always'
|
2016-03-31 18:21:23 +00:00
|
|
|
alias rm='rm -i'
|
|
|
|
alias mv='mv -i'
|
2017-02-02 00:30:16 +00:00
|
|
|
alias cp='cp -ir'
|
|
|
|
alias pacman='pacman --color=always'
|
|
|
|
alias pacaur='pacaur --color=always'
|
2016-05-01 13:28:39 +00:00
|
|
|
alias less='less -R'
|
2016-11-14 13:54:01 +00:00
|
|
|
alias tree='tree --dirsfirst -C -F'
|
2016-07-27 08:36:47 +00:00
|
|
|
alias dd='dd status=progress'
|
2017-08-27 15:41:31 +00:00
|
|
|
alias env='env | sort'
|
|
|
|
alias ssh="ssh -tt"
|
2017-10-03 08:36:10 +00:00
|
|
|
alias grip='grip --user=frebib --pass=$GRIP_API_KEY'
|
2017-11-10 12:33:01 +00:00
|
|
|
which gopass &>/dev/null && alias pass='gopass'
|
2017-11-10 12:42:23 +00:00
|
|
|
alias abuild='docker run -ti --rm \
|
|
|
|
-e USER \
|
|
|
|
-e PWD \
|
|
|
|
-w $PWD \
|
2017-11-15 23:20:55 +00:00
|
|
|
-v $PWD:$PWD \
|
2017-11-10 12:42:23 +00:00
|
|
|
-v ~/.abuild:/home/$USER/.abuild \
|
|
|
|
-v ~/.config/git:/home/$USER/.config/git:ro \
|
|
|
|
-v ~/.gnupg:/home/$USER/.gnupg \
|
2017-11-15 23:20:55 +00:00
|
|
|
frebib/alpine-sdk:edge abuild'
|
2016-03-31 18:21:23 +00:00
|
|
|
|
2016-04-01 12:37:15 +00:00
|
|
|
# System aliases
|
2017-07-08 23:10:54 +00:00
|
|
|
alias s="sudo systemctl"
|
2017-02-02 00:30:16 +00:00
|
|
|
alias j=journalctl
|
2016-05-21 11:50:55 +00:00
|
|
|
alias p=pacaur
|
2016-04-01 12:37:15 +00:00
|
|
|
alias ps='ps aux'
|
2017-02-02 00:30:16 +00:00
|
|
|
alias catn='tail -n +1 --'
|
|
|
|
alias kl='killall -s 9'
|
2016-10-04 23:47:55 +00:00
|
|
|
alias chx='chmod +x'
|
2016-03-31 18:21:23 +00:00
|
|
|
|
|
|
|
# File default aliases
|
2016-05-01 13:32:37 +00:00
|
|
|
pdf() {
|
|
|
|
evince $@ NE BG
|
|
|
|
}
|
|
|
|
alias -s pdf=pdf
|
2016-03-31 18:21:23 +00:00
|
|
|
alias -s zip="unzip -l"
|
|
|
|
alias -s rar="unrar l"
|
|
|
|
alias -s tar="tar tf"
|
2017-03-21 05:18:07 +00:00
|
|
|
alias -s gz="tar tf"
|
2016-04-16 17:00:03 +00:00
|
|
|
alias -s jar="java -jar"
|
2017-10-03 08:36:42 +00:00
|
|
|
alias -s git="git clone --recursive"
|
2016-03-31 18:21:23 +00:00
|
|
|
|
|
|
|
|
2016-03-31 02:03:55 +00:00
|
|
|
# Git Aliases
|
|
|
|
alias g=git
|
2017-01-25 14:02:30 +00:00
|
|
|
alias gignore='$EDITOR .gitignore'
|
2016-03-31 02:03:55 +00:00
|
|
|
alias gcl="git clone --recursive"
|
|
|
|
alias gco="git checkout"
|
2016-04-18 13:06:14 +00:00
|
|
|
alias gcom="git checkout master"
|
2016-03-31 02:03:55 +00:00
|
|
|
alias ga="git add"
|
2017-11-15 23:21:27 +00:00
|
|
|
alias gap="git -c interactive.diffFilter=\"git diff --color-words\" add -p"
|
2016-03-31 02:03:55 +00:00
|
|
|
alias gaa="ga -A"
|
2017-02-07 00:35:45 +00:00
|
|
|
alias grm="git rm"
|
2016-03-31 02:03:55 +00:00
|
|
|
alias gc="git commit"
|
|
|
|
alias gcm="gc -m"
|
2016-10-20 23:05:56 +00:00
|
|
|
alias gca="git commit --amend"
|
|
|
|
alias gcan="git commit --amend --no-edit"
|
2017-08-27 15:41:52 +00:00
|
|
|
alias gcam="git commit --amend -m"
|
2016-03-31 02:03:55 +00:00
|
|
|
alias gst="git status"
|
|
|
|
|
|
|
|
alias gm="git merge"
|
|
|
|
alias gma="git merge --abort"
|
|
|
|
alias grb="git rebase"
|
|
|
|
alias grba="grb --abort"
|
|
|
|
alias grbc="grb --continue"
|
|
|
|
|
|
|
|
alias gf="git fetch"
|
|
|
|
alias gp="git push"
|
|
|
|
alias gpf="gp --force"
|
2017-03-21 05:13:29 +00:00
|
|
|
alias gpsu="git push --set-upstream"
|
|
|
|
alias gpsuom="git push --set-upstream origin master"
|
2017-11-15 23:21:27 +00:00
|
|
|
alias gpall="git remote | xargs -L1 git push"
|
2016-03-31 02:03:55 +00:00
|
|
|
alias gl="git pull --rebase"
|
2016-07-06 07:39:52 +00:00
|
|
|
alias glp="gl && gp"
|
2016-09-01 13:50:13 +00:00
|
|
|
gd() {
|
|
|
|
local commit=$1
|
|
|
|
if [ -z "$commit" ] || [ ${commit:0:1} != '@' ]; then
|
2017-11-15 23:21:27 +00:00
|
|
|
git diff --color-words $@
|
2016-09-01 13:50:13 +00:00
|
|
|
return
|
|
|
|
else
|
2017-11-15 23:21:27 +00:00
|
|
|
git diff --color-words "@~${commit:1}^!"
|
2016-09-01 13:50:13 +00:00
|
|
|
fi
|
|
|
|
}
|
2017-11-15 23:21:27 +00:00
|
|
|
alias gds="git diff --staged --color-words"
|
2016-03-31 02:03:55 +00:00
|
|
|
alias glg="git log --stat --color"
|
|
|
|
alias glog="git log --oneline --decorate --color --graph"
|
|
|
|
|
2016-04-18 13:06:14 +00:00
|
|
|
alias grst="git reset"
|
|
|
|
alias gundo="git reset @~1"
|
2016-03-31 02:03:55 +00:00
|
|
|
alias gclean="git clean"
|
|
|
|
alias gbr="git branch"
|
|
|
|
alias gr="git remote"
|
2017-10-10 10:01:03 +00:00
|
|
|
alias grv="git remote -v"
|
2016-03-31 02:03:55 +00:00
|
|
|
alias gra="gr add"
|
|
|
|
alias grr="gr rm"
|
|
|
|
alias grao="gra origin"
|
|
|
|
alias grro="grr origin"
|
|
|
|
|
|
|
|
alias gsta='git stash'
|
|
|
|
alias gstd='gsta drop'
|
|
|
|
alias gstl='gsta list'
|
|
|
|
alias gstp='gsta pop'
|
|
|
|
alias gstv="gsta show -p stash@{0}"
|
|
|
|
|
2016-06-21 23:23:19 +00:00
|
|
|
# Docker aliases
|
|
|
|
alias d=docker
|
|
|
|
alias dps='docker ps'
|
|
|
|
alias dpsa='docker ps -a'
|
|
|
|
alias drm='docker rm'
|
|
|
|
alias drmi='docker rmi'
|
|
|
|
alias dim='docker images'
|
2017-05-14 21:25:18 +00:00
|
|
|
alias dbl='docker build --pull'
|
|
|
|
alias dbl.='docker build --pull .'
|
2016-06-21 23:23:19 +00:00
|
|
|
alias drun='docker run -ti'
|
2016-07-20 15:26:06 +00:00
|
|
|
alias dkl='docker kill'
|
2017-05-25 09:26:40 +00:00
|
|
|
dklrm() { docker kill $@ ; docker rm $@ }
|
2016-08-12 14:54:08 +00:00
|
|
|
alias dst='docker stop'
|
2017-01-18 17:04:20 +00:00
|
|
|
alias drst='docker restart'
|
|
|
|
alias dnet='docker network'
|
|
|
|
alias dvol='docker volume'
|
2016-08-12 14:54:08 +00:00
|
|
|
alias dlg='docker logs -f'
|
2016-09-01 13:22:49 +00:00
|
|
|
alias dalpine='docker run -ti --rm alpine /bin/sh'
|
2017-05-22 17:20:46 +00:00
|
|
|
alias drm-stopped='docker container prune'
|
|
|
|
alias drmi-untag='docker image prune'
|
2017-08-27 15:36:11 +00:00
|
|
|
alias dprune='docker system prune -f'
|
2017-07-15 12:32:22 +00:00
|
|
|
alias dsh='_CMD=dsh _dsh exec'
|
2017-08-27 15:37:17 +00:00
|
|
|
alias drsh='_CMD=drsh _dsh run --rm --entrypoint='
|
2016-12-18 12:29:51 +00:00
|
|
|
_dsh() {
|
2017-07-15 12:32:22 +00:00
|
|
|
if [ $# -lt 2 ]; then
|
|
|
|
echo "Usage: ${_CMD:-$0} [user@]container [program [args]]" >&2
|
|
|
|
return 64
|
|
|
|
fi
|
|
|
|
|
2016-12-18 12:29:51 +00:00
|
|
|
local dowhat="$1"
|
2017-07-16 00:51:28 +00:00
|
|
|
local docker_args=()
|
|
|
|
shift
|
|
|
|
|
|
|
|
while [ "${1:0:1}" = '-' ]; do
|
2017-08-27 15:37:45 +00:00
|
|
|
if [ "${1:0:2}" != '--' ]; then
|
|
|
|
docker_args+=("$1")
|
|
|
|
shift
|
|
|
|
fi
|
2017-07-16 00:51:28 +00:00
|
|
|
docker_args+=("$1")
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
local user="$(echo "$1" | cut -d'@' -f1 -s)"
|
|
|
|
local prog="${@:2:$#}"
|
2016-12-18 12:29:51 +00:00
|
|
|
local usercmd=""
|
|
|
|
if [ -z "$user" ]; then
|
2017-07-16 00:51:28 +00:00
|
|
|
host="$1"
|
2016-08-12 14:54:08 +00:00
|
|
|
else
|
2017-07-16 00:51:28 +00:00
|
|
|
host=`echo $1 | cut -d'@' -f2 -s`
|
2017-10-03 08:37:10 +00:00
|
|
|
usercmd="--user=$user"
|
2016-08-12 14:54:08 +00:00
|
|
|
fi
|
|
|
|
|
2017-08-27 15:40:13 +00:00
|
|
|
if [ "$dowhat" = 'exec' -a -z "$(docker ps -q -f name="$host")" <&- ]; then
|
2017-07-15 12:32:22 +00:00
|
|
|
echo "No such container $host" >&2
|
|
|
|
return 5
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$prog" ]; then
|
|
|
|
set -o pipefail
|
2017-08-27 15:40:58 +00:00
|
|
|
local rm=
|
|
|
|
if [ "$dowhat" = 'run' ]; then
|
|
|
|
rm='--rm --entrypoint='
|
|
|
|
fi
|
2017-07-15 12:32:22 +00:00
|
|
|
for shell in bash sh; do
|
2017-08-27 15:40:13 +00:00
|
|
|
if shell_path="$(eval "docker $dowhat $rm $host which $shell" <&- | sed 's|[\r\n]||g')"; then
|
2017-07-15 12:32:22 +00:00
|
|
|
prog="$shell_path"
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
set +o pipefail
|
|
|
|
if [ -z "$prog" ]; then
|
|
|
|
echo "Warning: No shell found in path.. trying /bin/sh" >&2
|
|
|
|
prog=/bin/sh
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2017-07-16 00:51:28 +00:00
|
|
|
docker $dowhat ${docker_args[@]} -ti $usercmd $host $(xargs <<< $prog)
|
2016-07-20 15:41:52 +00:00
|
|
|
}
|
2016-06-21 23:23:19 +00:00
|
|
|
|
2016-07-19 22:38:07 +00:00
|
|
|
alias dm='docker-machine'
|
|
|
|
dm-con() {
|
|
|
|
eval $(docker-machine env $1)
|
|
|
|
}
|
2016-09-01 13:22:49 +00:00
|
|
|
alias dmc=dm-con
|
|
|
|
|
|
|
|
alias dc='docker-compose'
|
|
|
|
|
|
|
|
# ZFS aliases
|
|
|
|
alias zfs='sudo zfs'
|
|
|
|
alias zpool='sudo zpool'
|
|
|
|
alias z=zfs
|
|
|
|
alias zp=zpool
|
|
|
|
|
2016-03-31 02:03:55 +00:00
|
|
|
# General Aliases
|
2016-05-10 16:06:06 +00:00
|
|
|
alias ssha='eval `ssh-agent` ; ssh-add'
|
2017-11-15 23:21:54 +00:00
|
|
|
alias aliases="$EDITOR $DOTFILES/aliases ; exec zsh"
|
2016-03-31 02:03:55 +00:00
|
|
|
alias vimrc="$EDITOR ~/.vimrc"
|
2017-11-15 23:21:54 +00:00
|
|
|
alias zshrc="$EDITOR ~/.zshrc ; exec zsh"
|
2016-03-31 02:03:55 +00:00
|
|
|
alias xinitrc="$EDITOR ~/.xinitrc"
|
|
|
|
alias xresources="$EDITOR ~/.Xresources ; xrdb merge ~/.Xresources"
|
2016-04-17 14:27:20 +00:00
|
|
|
alias xsession="$EDITOR ~/.xsession"
|
2016-03-31 02:03:55 +00:00
|
|
|
alias sshc="$EDITOR ~/.ssh/config"
|
|
|
|
alias dotfiles="cd $DOTFILES"
|
|
|
|
alias i3c="$EDITOR ~/.config/i3/config ; i3-msg restart"
|
2016-05-01 13:09:45 +00:00
|
|
|
alias i3bc="$EDITOR ~/.config/i3/blocks/config ; i3-msg restart"
|
2016-08-03 16:10:56 +00:00
|
|
|
i3b() {
|
|
|
|
$EDITOR ~/.config/i3/blocks/$@
|
|
|
|
}
|
2016-03-31 02:03:55 +00:00
|
|
|
alias sf=screenfetch
|
2016-04-02 17:29:23 +00:00
|
|
|
alias nf=neofetch
|
2017-11-10 12:42:42 +00:00
|
|
|
randstr() { tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w $1 | head -n 1; }
|
2017-10-03 10:49:23 +00:00
|
|
|
alias rot13="tr '[A-Za-z]' '[N-ZA-Mn-za-m]'"
|
2016-03-31 02:03:55 +00:00
|
|
|
|
|
|
|
alias lab="ssh -tt tw '~/ctl' 2>/dev/null"
|
2016-09-01 13:50:36 +00:00
|
|
|
|
|
|
|
# vim: ft=sh
|