This repository has been archived on 2021-04-06. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/home/.zshrc.local

177 lines
4.7 KiB
Plaintext

# Programming languages
## Go
export GOPATH="$HOME/go"
export PATH="$PATH:$GOPATH/bin"
## Node
export NVM_DIR=$(realpath "$HOME/.nvm")
source "$NVM_DIR/nvm.sh"
## Python (pip)
export PATH="$HOME/.local/bin:$PATH"
# Misc
## Local binaries
export PATH="$HOME/bin:$PATH"
# Helpers
## Terminal font
function tfont() (
[ -z "$1" ] && font="Terminess Powerline" || font="$1"
[ -z "$2" ] && fontsize=18 || fontsize="$2"
echo -en "\033]710;xft:$font:pixelsize=$fontsize\007"
)
## resync pulseaudio bluetooth connection
function btsync() (
card=$(pactl list cards short|grep -E -o "bluez_card.*[[:space:]]")
pacmd set-card-profile $card off
pacmd set-card-profile $card a2dp_sink
)
## get field from pass entry
function pass-field() {
pass "$1"|grep "$2"|cut -d: -f2-|tr -d ' '
}
## dircolors
eval "$(dircolors -b $HOME/.dircolors)"
## fzf
[ -e /usr/share/doc/fzf/examples/key-bindings.zsh ] && source /usr/share/doc/fzf/examples/key-bindings.zsh
## Color switcher
alias dynamic-colors="~/.dynamic-colors/bin/dynamic-colors"
## Timer
function timer() (
if [ -z "$1" ] || [ -z "$2" ]; then
echo "USAGE: $0 [u|f] TIME/DURATION" >&2
return 1
fi
if [ "$1" != "u" ] && [ "$1" != "f" ]; then
echo "Invalid mode “$1” supplied. Valid modes are: u|f" >&2
return 2
fi
[ "$1" = "u" ] && mode="until"
[ "$1" = "f" ] && mode="for"
gosleep --${mode} "$2"
if [ "$?" = 0 ]; then
echo "Press CTRL-C to stop the alarm…" >&2
echo -en "\a" # highlight window
paplay ~/Dokumente/sound/ringtones/Bergentrückung.wav
else
echo "The sleep command failed. Please check the options." >&2
return 3
fi
)
## Wallpaper switcher
function wp() (
if [ -z "$1" ] || ([ "$1" = "rand" ] && [ -z "$2" ]); then
echo "USAGE: $0 rand|restore|default [path]"
return 1
fi
if [ "$1" = "default" ];then
feh --bg-fill /usr/share/wallpapers/wallpaper.jpg
fi
if [ "$1" = "rand" ]; then
base="$HOME/Bilder/wallpaper"
rand=$(shuf -n1 -e $base/$2/*)
[ -z "$rand" ] || feh --bg-fill "$rand"
fi
if [ "$1" = "restore" ]; then
~/.fehbg
fi
)
function currency() (
amount=${1:-1}
fromcurrency=${2:-USD}
tocurrency=${3:-EUR}
rate=$(curl -s "https://api.exchangeratesapi.io/latest?base=$fromcurrency&symbols=$tocurrency"|jq ".rates.$tocurrency")
printf "$amount $fromcurrency: %.02f $tocurrency\n" $(($amount * $rate))
)
function urlencode() {
python3 -c "import urllib.parse; print(urllib.parse.quote(open(0, 'rb').read()))"
}
function mkvextract-all-attachments() {
mkvextract $1 attachments $(mkvmerge --identify $1|grep "Attachment ID"|sed "s/Attachment ID \([0-9]*\): .*/\1/")
}
# Audacious does not support symlinks; hack around that
function audacious-hack() (
IFS=$'\n'
audacious $(/bin/ls -1 $1/**/*(@)|sort -Vd)
)
# Program aliases/env
## Aliases for programs
if which exa 2>&1 >> /dev/null;then
alias exa="exa --git"
alias ls="exa"
fi
alias ipy="ipython3"
alias rls="/bin/ls --color=auto"
alias line="chromium --user-data-dir=$HOME/.line --app=chrome-extension://ophjlpahpchlmihnnnihgmmeilfjmjjc/index.html"
## Environment variables
export HVSC_BASE="$HOME/Dokumente/sound/HVSC/"
export _JAVA_OPTIONS="-Dawt.useSystemAAFontSettings=on" # force antialiasing in java
## include docker functions
source ~/.zshrc.docker
## drone ci
function drone-add-hub() {
drone secret add --name docker_username --data sbruder "$1"
drone secret add --name docker_password --data "$(pass devops/docker|head -n 1)" "$1"
}
function drone-add-registry() {
drone secret add --name docker_username --data simon "$1"
drone secret add --name docker_password --data "$(pass accounts/sbruderldap|head -n 1)" "$1"
}
function drone-add-netlify() {
drone secret add --name netlify_key --data "$(pass-field devops/netlify Drone-Key)" "$1"
}
function drone-add-s3() {
drone secret add --name aws_access_key_id --data "$(pass-field data/minio/personal User)" "$1"
drone secret add --name aws_secret_access_key --data "$(pass data/minio/personal|head -n 1)" "$1"
}
function drone() (
export DRONE_SERVER="$(pass-field management/drone Server)"
export DRONE_TOKEN="$(pass management/drone|head -n 1)"
~/bin/drone $@
)
function docker-ls() (
export DOCKER_LS_PASSWORD="$(pass accounts/sbruderldap|head -n 1)"
~/bin/docker-ls $@
)
function docker-rm() (
export DOCKER_LS_PASSWORD="$(pass accounts/sbruderldap|head -n 1)"
~/bin/docker-rm $@
)
## lexicon
function lecicon() (
export LEXICON_HENET_USERNAME="$(pass-field management/he User)"
export LEXICON_HENET_PASSWORD="$(pass management/he|head -n 1)"
lexicon $@
)