mirror of
https://github.com/frebib/dotfiles.git
synced 2024-06-14 12:57:23 +00:00
Compare commits
No commits in common. "6ceb993208b983d01e2f535922d3a7a84a6e9bb4" and "24dfc13c3f782b803ad7a27f16ba4ec44055c51e" have entirely different histories.
6ceb993208
...
24dfc13c3f
133
aliases
133
aliases
@ -1,7 +1,7 @@
|
|||||||
case "$(basename "$(readlink -f /proc/$$/exe)")" in
|
case "$(basename "$(readlink -f /proc/$$/exe)")" in
|
||||||
zsh) thisfile="$(readlink -f "${(%):-%N}")";;
|
zsh) thisfile="$(readlink -f "${(%):-%N}")";;
|
||||||
bash) thisfile="$(readlink -f "${BASH_SOURCE[0]}")";;
|
bash) thisfile="$(readlink -f "${BASH_SOURCE[0]}")";;
|
||||||
*) thisfile="$(find /proc/$$/fd/ -print0 | xargs -0 -n1 -r readlink -f | grep aliases | head -n1)";;
|
*) thisfile="$(find /proc/$$/fd/ | xargs -n1 -r readlink -f | grep aliases | head -n1)";;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Global aliases for ZSH
|
# Global aliases for ZSH
|
||||||
@ -10,32 +10,49 @@ if alias -g 2>/dev/null; then
|
|||||||
alias -g ....=../../..
|
alias -g ....=../../..
|
||||||
alias -g .....=../../../..
|
alias -g .....=../../../..
|
||||||
alias -g ......=../../../../..
|
alias -g ......=../../../../..
|
||||||
|
alias -g H='| head'
|
||||||
|
alias -g T='| tail'
|
||||||
|
alias -g G='| grep'
|
||||||
|
alias -g L="| less"
|
||||||
|
alias -g C="| wc -l"
|
||||||
|
alias -g S="| sort"
|
||||||
|
alias -g U="| uniq"
|
||||||
|
alias -g count="| wc -l"
|
||||||
alias -g NO="1> /dev/null"
|
alias -g NO="1> /dev/null"
|
||||||
alias -g NE="2> /dev/null"
|
alias -g NE="2> /dev/null"
|
||||||
alias -g NUL="&> /dev/null"
|
alias -g NUL="&> /dev/null"
|
||||||
alias -g BG="&;disown"
|
alias -g BG="&;disown"
|
||||||
|
alias -g COL="| column -t"
|
||||||
|
alias -g CLIP="| xclip -i -selection primary -f | xclip -i -selection clipboard"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# File default aliases
|
# File default aliases
|
||||||
if alias -s 2>/dev/null; then
|
if alias -s 2>/dev/null; then
|
||||||
alias -s pdf="open"
|
alias -s pdf="open"
|
||||||
|
alias -s zip="unzip -l"
|
||||||
|
alias -s rar="unrar l"
|
||||||
|
alias -s tar="tar tf"
|
||||||
|
alias -s gz="tar tf"
|
||||||
alias -s jar="java -jar"
|
alias -s jar="java -jar"
|
||||||
alias -s git="git clone --recursive"
|
alias -s git="git clone --recursive"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
alias ..la="cd ..;la"
|
||||||
|
alias ..ll="cd..;ll"
|
||||||
|
alias ..l="..ll"
|
||||||
|
|
||||||
alias l=ll
|
alias l=ll
|
||||||
alias ls='ls --color=auto'
|
alias ls='ls --color=auto'
|
||||||
alias ll='ls -lFh --group-directories-first'
|
alias ll="ls -lFh --group-directories-first"
|
||||||
alias la='ls -lAFh --group-directories-first'
|
alias la="ls -lAFh --group-directories-first"
|
||||||
alias lt='ls -lFh --sort=time'
|
alias lt='ls -lAFh --sort=time'
|
||||||
alias lat='ls -lAFh --sort=time'
|
|
||||||
alias lsz='ls -lAFh --sort=size'
|
alias lsz='ls -lAFh --sort=size'
|
||||||
alias al=la # No, I don't need the Mono Assembly Linker
|
alias al=la # No, I don't need the Mono Assembly Linker
|
||||||
|
|
||||||
alias md='mkdir -p'
|
alias md="mkdir -p"
|
||||||
alias rd='rmdir -p'
|
alias rd="rmdir -p"
|
||||||
alias -- -='cd -'
|
alias -- -='cd -'
|
||||||
cdt() { cd "$(mktemp -d "${1:-tmp}.XXXXXXXX")"; }
|
alias cdt='cd `mktemp -d`'
|
||||||
|
|
||||||
alias svi=sudoedit
|
alias svi=sudoedit
|
||||||
alias svim=sudoedit
|
alias svim=sudoedit
|
||||||
@ -51,21 +68,22 @@ alias mv='mv -i'
|
|||||||
alias cp='cp -ir'
|
alias cp='cp -ir'
|
||||||
alias scp='scp -r'
|
alias scp='scp -r'
|
||||||
alias dd='dd status=progress'
|
alias dd='dd status=progress'
|
||||||
alias wget='wget --hsts-file=$XDG_DATA_HOME/wget/hsts-file'
|
alias ssh="ssh -tt"
|
||||||
|
alias wget="wget --hsts-file=$XDG_DATA_HOME/wget/hsts-file"
|
||||||
alias vi=vim
|
alias vi=vim
|
||||||
alias grip='grip --user=frebib --pass=$GRIP_API_KEY'
|
alias grip='grip --user=frebib --pass=$GRIP_API_KEY'
|
||||||
alias acme.sh='$XDG_CONFIG_HOME/acme.sh/acme.sh --home $XDG_CONFIG_HOME/acme.sh --config-home $XDG_CONFIG_HOME/acme.sh --log $XDG_CONFIG_HOME/acme.sh/acme.sh.log'
|
alias acme.sh='$XDG_CONFIG_HOME/acme.sh/acme.sh --home $XDG_CONFIG_HOME/acme.sh --config-home $XDG_CONFIG_HOME/acme.sh --log $XDG_CONFIG_HOME/acme.sh/acme.sh.log'
|
||||||
alias acmesh='$XDG_CONFIG_HOME/acme.sh/acme.sh --home $XDG_CONFIG_HOME/acme.sh --config-home $XDG_CONFIG_HOME/acme.sh --log $XDG_CONFIG_HOME/acme.sh/acme.sh.log'
|
alias acmesh='$XDG_CONFIG_HOME/acme.sh/acme.sh --home $XDG_CONFIG_HOME/acme.sh --config-home $XDG_CONFIG_HOME/acme.sh --log $XDG_CONFIG_HOME/acme.sh/acme.sh.log'
|
||||||
alias alpine-sdk="docker run -ti --rm \
|
alias alpine-sdk='docker run -ti --rm \
|
||||||
-e USER \
|
-e USER \
|
||||||
-e UID=\"\$(id -u)\" \
|
-e UID="$(id -u)" \
|
||||||
-e PWD \
|
-e PWD \
|
||||||
-e HOME \
|
-e HOME \
|
||||||
-w \$PWD \
|
-w $PWD \
|
||||||
-v \$PWD:\$PWD \
|
-v $PWD:$PWD \
|
||||||
-v ~/.abuild:\$HOME/.abuild \
|
-v ~/.abuild:$HOME/.abuild \
|
||||||
-v ~/.abuild/distfiles:/var/cache/distfiles \
|
-v ~/.abuild/distfiles:/var/cache/distfiles \
|
||||||
frebib/alpine-sdk:edge"
|
frebib/alpine-sdk:edge'
|
||||||
alias abuild='alpine-sdk abuild'
|
alias abuild='alpine-sdk abuild'
|
||||||
alias abuild-sign='alpine-sdk abuild-sign'
|
alias abuild-sign='alpine-sdk abuild-sign'
|
||||||
alias apk='alpine-sdk apk'
|
alias apk='alpine-sdk apk'
|
||||||
@ -89,9 +107,9 @@ vim --version 2>/dev/null | command grep -q +clientserver && \
|
|||||||
alias vim="vim --servername vim -p"
|
alias vim="vim --servername vim -p"
|
||||||
|
|
||||||
# Function aliases
|
# Function aliases
|
||||||
env() { command env "$@" | stripansi | sort; }
|
env() { command env $@ | stripansi | sort; }
|
||||||
mcd(){ mkdir -p -- "$@" && cd -- "$@"; }
|
mcd(){ mkdir -p -- $@ && cd -- $@; }
|
||||||
randstr() { tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w "$1" | head -n 1; }
|
randstr() { tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w $1 | head -n 1; }
|
||||||
|
|
||||||
# System aliases
|
# System aliases
|
||||||
alias sc="systemctl"
|
alias sc="systemctl"
|
||||||
@ -121,7 +139,7 @@ alias gaa="ga -A"
|
|||||||
alias grm="git rm"
|
alias grm="git rm"
|
||||||
alias gc="git commit -s"
|
alias gc="git commit -s"
|
||||||
alias gcm="git commit -s -em"
|
alias gcm="git commit -s -em"
|
||||||
alias gca="git commit -s --amend --date=\"\$(date -R)\""
|
alias gca="git commit -s --amend --date=\"$(date -R)\""
|
||||||
alias gcn="git commit -s --no-edit"
|
alias gcn="git commit -s --no-edit"
|
||||||
alias gcan="gca -s --no-edit"
|
alias gcan="gca -s --no-edit"
|
||||||
alias gcam="gca -s -m"
|
alias gcam="gca -s -m"
|
||||||
@ -188,7 +206,7 @@ alias d=docker
|
|||||||
alias dps="docker ps --format='table {{.ID}}\t{{.Image}}\t{{.Label \"org.label-schema.version\"}}\t{{.Networks}}\t{{.RunningFor}}\t{{.Status}}\t{{.Names}}' | sed '1s/version/VERSION/'"
|
alias dps="docker ps --format='table {{.ID}}\t{{.Image}}\t{{.Label \"org.label-schema.version\"}}\t{{.Networks}}\t{{.RunningFor}}\t{{.Status}}\t{{.Names}}' | sed '1s/version/VERSION/'"
|
||||||
alias dpsa="docker ps -a --format='table {{.ID}}\t{{.Image}}\t{{.Label \"org.label-schema.version\"}}\t{{.Networks}}\t{{.RunningFor}}\t{{.Status}}\t{{.Names}}' | sed '1s/version/VERSION/'"
|
alias dpsa="docker ps -a --format='table {{.ID}}\t{{.Image}}\t{{.Label \"org.label-schema.version\"}}\t{{.Networks}}\t{{.RunningFor}}\t{{.Status}}\t{{.Names}}' | sed '1s/version/VERSION/'"
|
||||||
alias dnets="docker network ls -q | xargs docker inspect | jq '.[] | select(.Name != \"host\" and .Name != \"none\") | [.] | map(.Name + \"\t\" + (.IPAM.Config | map(.Subnet) | join(\"\t\")))[]' -r | sort -V -k2,3 | column -t"
|
alias dnets="docker network ls -q | xargs docker inspect | jq '.[] | select(.Name != \"host\" and .Name != \"none\") | [.] | map(.Name + \"\t\" + (.IPAM.Config | map(.Subnet) | join(\"\t\")))[]' -r | sort -V -k2,3 | column -t"
|
||||||
daddrs() { docker inspect "${1:-bridge}" | jq '.[0].Containers | map(.Name + "\t" + .IPv4Address + "\t" + .IPv6Address)[]' -r | sort -V -k2,3 | column -t; }
|
daddrs() { docker inspect ${1:-bridge} | jq '.[0].Containers | map(.Name + "\t" + .IPv4Address + "\t" + .IPv6Address)[]' -r | sort -V -k2,3 | column -t; }
|
||||||
alias din='docker inspect'
|
alias din='docker inspect'
|
||||||
alias drm='docker rm'
|
alias drm='docker rm'
|
||||||
alias drmi='docker rmi'
|
alias drmi='docker rmi'
|
||||||
@ -207,21 +225,20 @@ alias dalpine='docker run -ti --rm spritsail/alpine /bin/sh'
|
|||||||
alias drm-stopped='docker container prune'
|
alias drm-stopped='docker container prune'
|
||||||
alias drmi-untag='docker image prune'
|
alias drmi-untag='docker image prune'
|
||||||
alias dprune='docker system prune -f'
|
alias dprune='docker system prune -f'
|
||||||
dsh() { do_dsh 2 exec "$@"; return $?; }
|
dsh() { do_dsh 2 exec $@; return $?; }
|
||||||
_dsh() { __docker_complete_running_containers "$@"; }
|
_dsh() { __docker_complete_running_containers $@; }
|
||||||
drsh() { do_dsh 4 run --rm --entrypoint= "$@"; return $?; }
|
drsh() { do_dsh 4 run --rm --entrypoint= $@; return $?; }
|
||||||
_drsh() { __docker_container_subcommand "$@"; }
|
_drsh() { __docker_container_subcommand $@; }
|
||||||
do_dsh() {
|
do_dsh() {
|
||||||
local minargs=$1
|
local minargs=$1
|
||||||
shift
|
shift
|
||||||
if [ $# -lt "$minargs" ]; then
|
if [ $# -lt $minargs ]; then
|
||||||
# shellcheck disable=SC2154
|
|
||||||
echo "Usage: ${funcstack[2]} [user@]container [program [args]]" >&2
|
echo "Usage: ${funcstack[2]} [user@]container [program [args]]" >&2
|
||||||
return 64
|
return 64
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local dowhat="$1"
|
local dowhat="$1"
|
||||||
local docker_args=("$dowhat" -ti)
|
local docker_args=()
|
||||||
shift
|
shift
|
||||||
|
|
||||||
while [ "${1:0:1}" = '-' ]; do
|
while [ "${1:0:1}" = '-' ]; do
|
||||||
@ -233,74 +250,68 @@ do_dsh() {
|
|||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
local user
|
local user="$(echo "$1" | cut -d'@' -f1 -s)"
|
||||||
user="$(echo "$1" | cut -d@ -f1 -s)"
|
local prog="${@:2:$#}"
|
||||||
|
local usercmd=""
|
||||||
declare -a prog
|
|
||||||
prog=("${@:2:$#}")
|
|
||||||
if [ -z "$user" ]; then
|
if [ -z "$user" ]; then
|
||||||
host="$1"
|
host="$1"
|
||||||
else
|
else
|
||||||
host="$(cut -d@ -f2 -s <<< "$1")"
|
host=`echo $1 | cut -d'@' -f2 -s`
|
||||||
docker_args+=("--user=$user")
|
usercmd="--user=$user"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$dowhat" = exec ] && [ -z "$(docker ps -q -f name="$host" <&-)" ]; then
|
if [ "$dowhat" = 'exec' -a -z "$(docker ps -q -f name="$host")" <&- ]; then
|
||||||
echo "No such container $host" >&2
|
echo "No such container $host" >&2
|
||||||
return 5
|
return 5
|
||||||
fi
|
fi
|
||||||
if [ "$dowhat" = run ]; then
|
|
||||||
docker image pull "$host"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ${#prog[@]} = 0 ]; then
|
if [ -z "$prog" ]; then
|
||||||
shell_args=("$dowhat")
|
shell_args=()
|
||||||
if [ "$dowhat" = 'run' ]; then
|
if [ "$dowhat" = 'run' ]; then
|
||||||
shell_args+=(--rm --entrypoint=)
|
shell_args=(--rm --entrypoint=)
|
||||||
fi
|
fi
|
||||||
for shell in bash sh; do
|
for shell in bash sh; do
|
||||||
shell_path="$(set -o pipefail; docker "${shell_args[@]}" "$host" which "$shell" <&- | sed 's|[\r\n]||g')"
|
shell_path="$(set -o pipefail; docker $dowhat ${shell_args[@]} "$host" which "$shell" <&- | sed 's|[\r\n]||g')"
|
||||||
retval=$?
|
retval=$?
|
||||||
if [ $retval -eq 0 ]; then
|
if [ $retval -eq 0 ]; then
|
||||||
prog=("$shell_path")
|
prog="$shell_path"
|
||||||
break
|
break
|
||||||
elif [ $retval -ge 125 ]; then
|
elif [ $retval -ge 125 ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [ ${#prog[@]} = 0 ]; then
|
if [ -z "$prog" ]; then
|
||||||
echo "Warning: No shell found in path.. trying /bin/sh" >&2
|
echo "Warning: No shell found in path.. trying /bin/sh" >&2
|
||||||
prog=(/bin/sh)
|
prog=/bin/sh
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
docker "${docker_args[@]}" "$host" "${prog[@]}"
|
docker $dowhat ${docker_args[@]} -ti $usercmd $host $(xargs <<< $prog)
|
||||||
}
|
}
|
||||||
|
|
||||||
alias dc='docker-compose'
|
alias dc='docker-compose'
|
||||||
alias dm='docker-machine'
|
alias dm='docker-machine'
|
||||||
dmc() { eval "$(docker-machine env "$1")"; }
|
dmc() { eval $(docker-machine env $1); }
|
||||||
|
|
||||||
# ZFS aliases
|
# ZFS aliases
|
||||||
alias zfs='sudo zfs'
|
alias zfs='sudo zfs'
|
||||||
alias zpool='sudo zpool'
|
alias zpool='sudo zpool'
|
||||||
alias zp=zpool
|
alias zp=zpool
|
||||||
zl() { (set -o pipefail; command zfs list "$@" | grep -Ev 'docker/[0-9a-f]{64}' | column -t -R 2,3,4); return $?; }
|
zl() { (set -o pipefail; command zfs list $@ | grep -Ev 'docker/[0-9a-f]{64}' | column -t -R 2,3,4); return $?; }
|
||||||
_zl() { _zfs "list $*"; }
|
_zl() { _zfs "list $@"; }
|
||||||
|
|
||||||
# General Aliases
|
# General Aliases
|
||||||
alias ssha="eval \"\$(ssh-agent)\"; ssh-add"
|
alias ssha='eval `ssh-agent` ; ssh-add'
|
||||||
# shellcheck disable=SC2139
|
alias aliases="$EDITOR $thisfile ; exec zsh"
|
||||||
alias aliases="\$EDITOR $thisfile ; exec zsh"
|
alias vimrc="$EDITOR $VIMRC"
|
||||||
alias vimrc="\$EDITOR \$VIMRC"
|
alias zshrc="$EDITOR ${ZDOTDIR:-$HOME}/.zshrc ; exec zsh"
|
||||||
alias zshrc="\$EDITOR \${ZDOTDIR:-\$HOME}/.zshrc ; exec zsh"
|
alias gitrc="$EDITOR $XDG_CONFIG_HOME/git/config"
|
||||||
alias gitrc="\$EDITOR \$XDG_CONFIG_HOME/git/config"
|
alias xinitrc="$EDITOR $XDG_CONFIG_HOME/X11/xinitrc"
|
||||||
alias xinitrc="\$EDITOR \$XDG_CONFIG_HOME/X11/xinitrc"
|
alias xresources="$EDITOR $XDG_CONFIG_HOME/X11/xresources ; xrdb merge $XDG_CONFIG_HOME/X11/xresources"
|
||||||
alias xresources="\$EDITOR \$XDG_CONFIG_HOME/X11/xresources ; xrdb merge \$XDG_CONFIG_HOME/X11/xresources"
|
alias sshc="$EDITOR ~/.ssh/config"
|
||||||
alias sshc="\$EDITOR ~/.ssh/config"
|
alias dotfiles="cd $XDG_CONFIG_HOME"
|
||||||
alias dotfiles="cd \$XDG_CONFIG_HOME"
|
alias i3c="$EDITOR $XDG_CONFIG_HOME/i3/config; systemctl --user reload i3"
|
||||||
alias i3c="\$EDITOR \$XDG_CONFIG_HOME/i3/config; systemctl --user reload i3"
|
alias polybarc="$EDITOR $XDG_CONFIG_HOME/polybar/config; systemctl --user reload polybar@i3bar"
|
||||||
alias polybarc="\$EDITOR \$XDG_CONFIG_HOME/polybar/config; systemctl --user reload polybar@i3bar"
|
|
||||||
|
|
||||||
alias rot13="tr '[A-Za-z]' '[N-ZA-Mn-za-m]'"
|
alias rot13="tr '[A-Za-z]' '[N-ZA-Mn-za-m]'"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user