2021-08-26 10:40:51 +02:00
|
|
|
# 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
|
|
|
|
|
2013-01-19 17:49:34 +01:00
|
|
|
# some more ls aliases
|
|
|
|
alias ll='ls -l'
|
|
|
|
alias la='ls -A'
|
2013-01-19 18:12:29 +01:00
|
|
|
alias lla='ll -A'
|
2013-01-19 17:49:34 +01:00
|
|
|
alias l='ls -CF'
|
|
|
|
|
|
|
|
alias ..='cd ..'
|
|
|
|
alias ...='cd ../..'
|
|
|
|
|
2013-01-19 18:12:29 +01:00
|
|
|
alias rm='rm -I'
|
2013-01-19 17:49:34 +01:00
|
|
|
alias mv='mv -i'
|
|
|
|
alias cp='cp -i'
|
|
|
|
|
2016-11-23 20:24:30 -05:00
|
|
|
alias psa='ps aux'
|
|
|
|
alias psag='ps aux | grep'
|
|
|
|
alias ka=killall
|
|
|
|
|
2020-04-20 21:50:06 +02:00
|
|
|
alias s=sudo
|
2019-07-21 10:08:15 +02:00
|
|
|
alias g=git
|
2018-12-26 11:21:51 +01:00
|
|
|
alias k=kubectl
|
2019-07-21 10:08:15 +02:00
|
|
|
alias a=ansible
|
2019-12-03 21:42:10 +01:00
|
|
|
alias c=code
|
2019-07-21 10:08:15 +02:00
|
|
|
alias e=$EDITOR
|
2021-08-26 10:35:41 +02:00
|
|
|
alias h=helm
|
|
|
|
alias d=docker
|
2020-04-20 21:50:06 +02:00
|
|
|
alias r=rancher
|
2021-08-26 10:40:51 +02:00
|
|
|
alias n="code ~/workspace/notes"
|
|
|
|
|
|
|
|
alias vi=vim
|
|
|
|
alias nano=vim
|
2019-07-21 15:01:24 +02:00
|
|
|
|
2016-03-27 20:55:28 +02:00
|
|
|
# Some shortcuts for me
|
2016-03-28 00:37:36 +02:00
|
|
|
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)}
|
|
|
|
|
2016-03-29 08:34:58 +02:00
|
|
|
[ -z "$HOP" ] || [ -z "$PORT" ] || [ -z "$PORT_LOCAL" ] && \
|
|
|
|
{ echo "usage: $FUNCNAME destination:port [local_port [tunnel_host]]"; return 1; }
|
2016-03-28 00:37:36 +02:00
|
|
|
|
|
|
|
ssh $HOP -L $PORT_LOCAL:$DEST:$PORT -N -o ExitOnForwardFailure=yes -f
|
|
|
|
|
|
|
|
PID=$(ssh $HOP -O check 2>&1 | sed -re "s/.*\(pid=(.*)\)+/\1/")
|
2016-03-29 08:34:58 +02:00
|
|
|
|
|
|
|
echo "Destination: $DEST:$PORT"
|
|
|
|
echo "Tunnelhost: $HOP"
|
|
|
|
echo "Local port: $PORT_LOCAL"
|
2016-03-28 00:37:36 +02:00
|
|
|
echo "SSH Tunnel PID: $PID"
|
|
|
|
}
|
|
|
|
|
|
|
|
function rdp-tunnel() {
|
|
|
|
IFS=: read DEST PORT <<<$1
|
|
|
|
HOP=${2:-$(jumphost $DEST)}
|
|
|
|
|
2016-04-16 10:11:25 +02:00
|
|
|
PORT=${PORT:-3389}
|
|
|
|
PORT_LOCAL=$((RANDOM%100+42325))
|
|
|
|
|
2016-03-29 08:34:58 +02:00
|
|
|
[ -z "$DEST" ] || [ -z "$HOP" ] && \
|
|
|
|
{ echo "usage: $FUNCNAME destination[:port] [tunnel_host]"; return 1; }
|
2016-03-28 00:37:36 +02:00
|
|
|
|
2016-03-29 08:34:58 +02:00
|
|
|
tunnel $DEST:$PORT $PORT_LOCAL $HOP && rdp localhost:$PORT_LOCAL
|
2016-03-28 00:37:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function rdp() {
|
2016-03-29 08:34:58 +02:00
|
|
|
PORT=3389
|
|
|
|
|
2016-03-28 00:37:36 +02:00
|
|
|
IFS=: read DEST PORT <<<$1
|
|
|
|
|
2016-03-29 08:34:58 +02:00
|
|
|
[ -n "$DEST" ] || \
|
|
|
|
{ echo "usage: $FUNCNAME destination:port"; return 1; }
|
2016-03-28 00:37:36 +02:00
|
|
|
|
2016-04-05 22:39:45 +02:00
|
|
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
|
|
|
open rdp://full%20address=s:$DEST:$PORT
|
|
|
|
else
|
|
|
|
rdesktop -P -k de -a 32 -z $DEST:$PORT
|
|
|
|
fi
|
2016-03-28 00:37:36 +02:00
|
|
|
}
|
2016-04-03 13:09:18 +02:00
|
|
|
|
2016-04-03 13:10:10 +02:00
|
|
|
function restic() {
|
|
|
|
local RESTIC=$(which restic)
|
|
|
|
|
|
|
|
# Start original restic executable with short-lived keys
|
2021-08-26 10:40:51 +02:00
|
|
|
(
|
|
|
|
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
|
2016-04-03 13:10:10 +02:00
|
|
|
}
|
2018-12-26 11:21:05 +01:00
|
|
|
|
2021-08-26 10:35:41 +02:00
|
|
|
function oath() {
|
|
|
|
ykman oath accounts code -s $1 | wl-copy
|
|
|
|
}
|
|
|
|
|
2019-11-11 02:11:45 +01:00
|
|
|
alias acs-pass='PASSWORD_STORE_DIR=~/workspace/rwth/acs/lab/passwords pass'
|
2019-04-17 10:25:55 +02:00
|
|
|
|
2020-04-20 21:50:06 +02:00
|
|
|
alias chaos-family-invite='kubectl --context=nulll --namespace=ssb exec svc/pub -- sbot invite.create 1 | jq -r . | pbcopy'
|
2019-11-11 02:11:45 +01:00
|
|
|
|
|
|
|
alias new-mac=$'openssl rand -hex 6 | sed \'s/\(..\)/\1:/g; s/.$//\' | xargs sudo ifconfig en0 ether'
|
2021-08-26 10:35:41 +02:00
|
|
|
|
|
|
|
if type xdg-open > /dev/null 2>&1; then
|
|
|
|
alias open=xdg-open
|
|
|
|
fi
|
|
|
|
|
|
|
|
alias chrome="chromium-browser --enable-features=UseOzonePlatform --ozone-platform=wayland"
|
2021-08-25 15:13:59 +02:00
|
|
|
|
|
|
|
. ~/.homesick/repos/dotfiles/z.sh
|