[zsh] refactor and clean up
This commit is contained in:
parent
b7f226cd4e
commit
b1b70e1449
|
@ -11,54 +11,14 @@ source "$NVM_DIR/nvm.sh"
|
|||
## Python (pip)
|
||||
export PATH="$HOME/.local/bin:$PATH"
|
||||
|
||||
## Lua
|
||||
|
||||
export PATH="$PATH:$HOME/.luarocks/bin/"
|
||||
|
||||
# Misc
|
||||
|
||||
## Local binaries
|
||||
|
||||
export PATH="$HOME/bin:$PATH"
|
||||
|
||||
# Ergonomic
|
||||
|
||||
## Battery percentage
|
||||
alias batt="upower -i /org/freedesktop/UPower/devices/battery_BAT0|grep percentage|awk '{print $2}'"
|
||||
|
||||
## 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 --set-prop "$touchpad" "libinput Send Events Mode Enabled" 1 1
|
||||
notify-send "Touchpad" "Disabled"
|
||||
|
||||
else
|
||||
xinput --set-prop "$touchpad" "libinput Send Events Mode Enabled" 0 0
|
||||
notify-send "Touchpad" "Enabled"
|
||||
fi
|
||||
}
|
||||
# Helpers
|
||||
|
||||
## Terminal font
|
||||
|
||||
function tfont() (
|
||||
[ -z "$1" ] && font="Terminess Powerline" || font="$1"
|
||||
[ -z "$2" ] && fontsize=18 || fontsize="$2"
|
||||
|
@ -67,18 +27,20 @@ function tfont() (
|
|||
|
||||
## resync pulseaudio bluetooth connection
|
||||
function btsync() (
|
||||
card=$(pactl list cards short|grep -E -o 'bluez_card.*[[:space:]]')
|
||||
card=$(pactl list cards short|grep -E -o "bluez_card.*[[:space:]]")
|
||||
pacmd set-card-profile $card off
|
||||
pacmd set-card-profile $card a2dp_sink
|
||||
)
|
||||
|
||||
# Fancy stuff
|
||||
## 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
|
||||
|
@ -139,11 +101,11 @@ function currency() (
|
|||
)
|
||||
|
||||
function urlencode() {
|
||||
python3 -c 'import urllib.parse; print(urllib.parse.quote(open(0, "rb").read()))'
|
||||
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/')
|
||||
mkvextract $1 attachments $(mkvmerge --identify $1|grep "Attachment ID"|sed "s/Attachment ID \([0-9]*\): .*/\1/")
|
||||
}
|
||||
|
||||
# Audacious does not support symlinks; hack around that
|
||||
|
@ -160,22 +122,13 @@ if which exa 2>&1 >> /dev/null;then
|
|||
alias ls="exa"
|
||||
fi
|
||||
alias ipy="ipython3"
|
||||
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"
|
||||
}
|
||||
|
||||
alias line="chromium --user-data-dir=$HOME/.line --app=chrome-extension://ophjlpahpchlmihnnnihgmmeilfjmjjc/index.html"
|
||||
|
||||
## 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
|
||||
export _JAVA_OPTIONS="-Dawt.useSystemAAFontSettings=on" # force antialiasing in java
|
||||
|
||||
## include docker functions
|
||||
source ~/.zshrc.docker
|
||||
|
@ -183,39 +136,42 @@ 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 show devops/docker|head -n 1)" "$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 show accounts/sbruderldap|head -n 1)" "$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 show devops/netlify |grep Drone-Key|cut -d: -f2|tr -d ' ')" "$1"
|
||||
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 show data/minio/personal|grep User|cut -d: -f2|tr -d ' ')" "$1"
|
||||
drone secret add --name aws_secret_access_key --data "$(pass show data/minio/personal|head -n 1)" "$1"
|
||||
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() (
|
||||
source ~/.drone-env
|
||||
export DRONE_SERVER="$(pass-field management/drone Server)"
|
||||
export DRONE_TOKEN="$(pass management/drone|head -n 1)"
|
||||
~/bin/drone $@
|
||||
)
|
||||
|
||||
function docker-ls() {
|
||||
DOCKER_LS_PASSWORD=$(pass show accounts/sbruderldap|head -n 1) ~/bin/docker-ls $@
|
||||
}
|
||||
function docker-ls() (
|
||||
export DOCKER_LS_PASSWORD="$(pass accounts/sbruderldap|head -n 1)"
|
||||
~/bin/docker-ls $@
|
||||
)
|
||||
|
||||
function docker-rm() {
|
||||
DOCKER_LS_PASSWORD=$(pass show accounts/sbruderldap|head -n 1) ~/bin/docker-rm $@
|
||||
}
|
||||
function docker-rm() (
|
||||
export DOCKER_LS_PASSWORD="$(pass accounts/sbruderldap|head -n 1)"
|
||||
~/bin/docker-rm $@
|
||||
)
|
||||
|
||||
## lexicon
|
||||
function lecicon() (
|
||||
LEXICON_HENET_USERNAME="$(pass management/he|grep User|cut -d: -f2|tr -d ' ')"
|
||||
LEXICON_HENET_PASSWORD="$(pass management/he|head -n 1)"
|
||||
export LEXICON_HENET_USERNAME="$(pass-field management/he User)"
|
||||
export LEXICON_HENET_PASSWORD="$(pass management/he|head -n 1)"
|
||||
lexicon $@
|
||||
)
|
||||
|
|
Reference in a new issue