# enable color support of ls and also add handy aliases if hash dircolors 2>/dev/null; then if [ -r ~/.dircolors ]; then eval "$(dircolors -b ~/.dircolors)" else eval "$(dircolors -b)" fi alias ls='ls --color=auto' alias grep='grep --color=auto' alias fgrep='fgrep --color=auto' alias egrep='egrep --color=auto' fi # some more ls aliases alias ll='ls -l' alias la='ls -A' alias lla='ll -A' alias l='ls -CF' alias ..='cd ..' alias ...='cd ../..' alias rm='rm -I' alias mv='mv -i' alias cp='cp -i' alias psa='ps aux' alias psag='ps aux | grep' alias ka=killall alias s=sudo alias g=git alias k=kubectl alias a=ansible alias c=code alias e=$EDITOR alias h=helm alias d=docker alias r=rancher alias n="code ~/workspace/notes" alias vi=vim alias nano=vim # Some shortcuts for me function jumphost() { DEST=$1 while read PATTERN JUMPHOST; do echo $DEST | grep -q $PATTERN && echo $JUMPHOST done <~/.ssh/jumphosts } function tunnel() { IFS=: read DEST PORT <<<$1 PORT_LOCAL=${2:-$PORT} HOP=${3:-$(jumphost $DEST)} [ -z "$HOP" ] || [ -z "$PORT" ] || [ -z "$PORT_LOCAL" ] && \ { echo "usage: $FUNCNAME destination:port [local_port [tunnel_host]]"; return 1; } ssh $HOP -L $PORT_LOCAL:$DEST:$PORT -N -o ExitOnForwardFailure=yes -f PID=$(ssh $HOP -O check 2>&1 | sed -re "s/.*\(pid=(.*)\)+/\1/") echo "Destination: $DEST:$PORT" echo "Tunnelhost: $HOP" echo "Local port: $PORT_LOCAL" echo "SSH Tunnel PID: $PID" } function rdp-tunnel() { IFS=: read DEST PORT <<<$1 HOP=${2:-$(jumphost $DEST)} PORT=${PORT:-3389} PORT_LOCAL=$((RANDOM%100+42325)) [ -z "$DEST" ] || [ -z "$HOP" ] && \ { echo "usage: $FUNCNAME destination[:port] [tunnel_host]"; return 1; } tunnel $DEST:$PORT $PORT_LOCAL $HOP && rdp localhost:$PORT_LOCAL } function rdp() { PORT=3389 IFS=: read DEST PORT <<<$1 [ -n "$DEST" ] || \ { echo "usage: $FUNCNAME destination:port"; return 1; } if [[ "$OSTYPE" == "darwin"* ]]; then open rdp://full%20address=s:$DEST:$PORT else rdesktop -P -k de -a 32 -z $DEST:$PORT fi } function restic() { local RESTIC=$(which restic) # Start original restic executable with short-lived keys ( export RESTIC_PASSWORD="$(pass restic/macbook)" s3 minio-restic $RESTIC $@ ) } function backup() { restic backup --exclude-if-present .resticignore ~ } # Load S3 credentials from password-store function s3() { if [ "${AWS_ACCESS_KEY_PASS}" == $1 ]; then return fi OUT=$(pass s3/$1) AWS_SECRET_ACCESS_KEY=$(sed -n 1p <<< ${OUT}) AWS_ACCESS_KEY_ID=$(sed -En 's/^User: (.*)/\1/p' <<< ${OUT}) AWS_ACCESS_KEY_PASS=$1 export AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY } function backup-phone() { pushd ~/annex/ git annex sync --no-push --content android popd } function oath() { ykman oath accounts code -s $1 | wl-copy } alias acs-pass='PASSWORD_STORE_DIR=~/workspace/rwth/acs/lab/passwords pass' alias chaos-family-invite='kubectl --context=nulll --namespace=ssb exec svc/pub -- sbot invite.create 1 | jq -r . | pbcopy' alias new-mac=$'openssl rand -hex 6 | sed \'s/\(..\)/\1:/g; s/.$//\' | xargs sudo ifconfig en0 ether' if type xdg-open > /dev/null 2>&1; then alias open=xdg-open fi alias chrome="chromium-browser --enable-features=UseOzonePlatform --ozone-platform=wayland" . ~/.homesick/repos/dotfiles/z.sh