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

265 lines
6.3 KiB
Plaintext

# Programming languages
## Go
export GOPATH="$HOME/go"
PATH="$PATH:$GOPATH/bin"
## Node
PATH="$PATH:/home/simon/opt/node/bin"
## Python (pip)
PATH="$PATH:/home/simon/.local/bin"
## Lua
PATH="$PATH:$HOME/.luarocks/bin/"
# Misc
## Local binaries
PATH="$PATH:$HOME/bin"
# Ergonomic
## Battery percentage
alias batt="upower -i /org/freedesktop/UPower/devices/battery_BAT0|grep percentage|awk '{print $2}'"
## Battery status (overwrites upstream function!)
function batterylinux () {
GRML_BATTERY_LEVEL=''
local batteries bat capacity
batteries=( /sys/class/power_supply/BAT*(N) )
if (( $#batteries > 0 )) ; then
for bat in $batteries ; do
if [[ -e $bat/capacity ]]; then
capacity=$(< $bat/capacity)
else
typeset -F energy_full=$(< $bat/energy_full)
typeset -F energy_now=$(< $bat/energy_now)
typeset -i capacity=$(( 100 * $energy_now / $energy_full))
fi
case $(< $bat/status) in
Charging)
GRML_BATTERY_LEVEL+="%F{blue}^%f"
;;
Discharging)
if (( capacity < 20 )) ; then
GRML_BATTERY_LEVEL+="%F{red}!v%f"
else
GRML_BATTERY_LEVEL+="%F{yellow}v%f"
fi
;;
*) # Full, Unknown
GRML_BATTERY_LEVEL+="%F{green}=%f"
;;
esac
GRML_BATTERY_LEVEL+="${capacity}%%"
done
fi
}
## Upload to transfer.sh
transfer() {
if [ $# -eq 0 ];then
echo -e "No arguments specified. Usage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer test.md"
return 1
fi
tmpfile=$(mktemp -t transferXXX)
if tty -s;then
basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g')
curl --progress-bar --upload-file "$1" "https://transfer.sh/$basefile" >> $tmpfile
else
curl --progress-bar --upload-file "-" "https://transfer.sh/$1" >> $tmpfile
fi
cat $tmpfile
rm -f $tmpfile
}
## Touchpad enabling/disabling
function touchpad() {
touchpad="SynPS/2 Synaptics TouchPad"
if [[ $1 == "disable" ]];then
xinput disable "$touchpad"
notify-send "Touchpad" "Disabled" -i ~/.local/share/icons/Paper/48x48/notifications/notification-touchpad-disabled-symbolic.svg
else
xinput enable "$touchpad"
notify-send "Touchpad" "Enabled" -i ~/.local/share/icons/Paper/48x48/notifications/notification-input-touchpad-symbolic.svg
fi
}
# Fancy stuff
## dircolors
eval "$(dircolors -b $HOME/.dircolors)"
## Color switcher
alias dynamic-colors="~/.dynamic-colors/bin/dynamic-colors"
## Screen settings
function ränder() {
(
case "$1" in
"office")
xrandr \
--output VGA-1 --off \
--output LVDS-1 --primary --mode 1280x800 --pos 0x720 --rotate normal \
--output HDMI-3 --mode 1920x1200 --pos 1280x0 --rotate normal \
--output HDMI-2 --off \
--output HDMI-1 --off \
--output DP-3 --off \
--output DP-2 --off \
--output DP-1 --off
;;
"officealt")
xrandr \
--output VGA-1 --off \
--output LVDS-1 --primary --mode 1280x800 --pos 0x1000 --rotate normal \
--output HDMI-3 --mode 1920x1200 --pos 1280x0 --rotate left \
--output HDMI-2 --off \
--output HDMI-1 --off \
--output DP-3 --off \
--output DP-2 --off \
--output DP-1 --off
;;
"solo")
xrandr \
--output VGA-1 --off \
--output LVDS-1 --primary --mode 1280x800 --rotate normal \
--output HDMI-3 --off \
--output HDMI-2 --off \
--output HDMI-1 --off \
--output DP-3 --off \
--output DP-2 --off \
--output DP-1 --off
;;
"auto")
xrandr --auto
;;
"manual")
arandr
;;
*)
echo "Invalid Preset"
notify-send "ränder" "Invalid Preset $1" -i ~/.local/share/icons/Paper/48x48/devices/video-display.png
invalid="true"
;;
esac
[ -z $invalid ] && notify-send "ränder" "Switched to $1" -i ~/.local/share/icons/Paper/48x48/devices/video-display.png
feh --bg-fill ~/bg.jpg
)
}
## 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
play -q ~/Dokumente/sound/ringtones/commando.ogg
else
echo "The sleep command failed. Please check the options." >&2
return 3
fi
)
}
# Bugs
## silversearcher-ag and not apt-get
unalias ag 2>/dev/null
# Program aliases/env
## Aliases for programs
alias apktool="java -jar ~/opt/apktool_2.3.1.jar"
if which exa 2>&1 >> /dev/null;then
alias exa="exa --git"
alias ls="exa"
fi
alias ipy="ipython3"
alias mc="$GOPATH/bin/mc"
alias mpvhdr="mpv --tone-mapping=hable"
alias rls="/bin/ls --color=auto"
alias shiori="docker exec shiori_shiori_1 shiori"
alias tearstop="compton --backend=glx"
function jitsi-meet() {
chromium --app="https://meet.jit.si/$1"
}
## Environment variables
export HVSC_BASE="$HOME/Dokumente/sound/HVSC/"
export ESP_ROOT="$HOME/projekte/esp8266/esp-open-sdk"
export ANDROID_HOME="$HOME/projekte/android/sdk"
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 --value sbruder "$1"
drone secret add --name docker_password --value "$(pass show devops/docker|head -n 1)" "$1"
)
}
function drone-add-registry() {
(
drone secret add --name docker_username --value sbruder "$1"
drone secret add --name docker_password --value "$(pass show accounts/sbruderldap|head -n 1)" "$1"
)
}
function drone-add-netlify() {
(
drone secret add --name netlify_key --value "$(pass show devops/netlify |grep Drone-Key|cut -d: -f2|tr -d ' ')" "$1"
)
}
function drone-add-s3() {
(
drone secret add --name aws_access_key_id --value "$(pass show management/minio/personal|grep User|cut -d: -f2|tr -d ' ')" "$1"
drone secret add --name aws_secret_access_key --value "$(pass show management/minio/personal|head -n 1)" "$1"
)
}
function drone() {
(
source ~/.drone-env
~/bin/drone $@
)
}
function docker-ls() {
(
DOCKER_LS_PASSWORD=$(pass show accounts/sbruderldap|head -n 1) ~/go/bin/docker-ls $@
)
}
function docker-rm() {
(
DOCKER_LS_PASSWORD=$(pass show accounts/sbruderldap|head -n 1) ~/go/bin/docker-rm $@
)
}