[zsh] use syntastic sugar for function that creates subshell

This commit is contained in:
Simon Bruder 2019-06-14 14:59:16 +00:00
parent 9c352f8f40
commit b7f226cd4e
No known key found for this signature in database
GPG key ID: 6F03E0000CC5B62F

View file

@ -27,7 +27,7 @@ export PATH="$HOME/bin:$PATH"
alias batt="upower -i /org/freedesktop/UPower/devices/battery_BAT0|grep percentage|awk '{print $2}'" alias batt="upower -i /org/freedesktop/UPower/devices/battery_BAT0|grep percentage|awk '{print $2}'"
## Upload to transfer.sh ## Upload to transfer.sh
transfer() { transfer() (
if [ $# -eq 0 ];then if [ $# -eq 0 ];then
echo -e "No arguments specified. Usage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer test.md" echo -e "No arguments specified. Usage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer test.md"
return 1 return 1
@ -41,7 +41,7 @@ transfer() {
fi fi
cat $tmpfile cat $tmpfile
rm -f $tmpfile rm -f $tmpfile
} )
## Touchpad enabling/disabling ## Touchpad enabling/disabling
@ -59,22 +59,18 @@ function touchpad() {
## Terminal font ## Terminal font
function tfont() { function tfont() (
(
[ -z "$1" ] && font="Terminess Powerline" || font="$1" [ -z "$1" ] && font="Terminess Powerline" || font="$1"
[ -z "$2" ] && fontsize=18 || fontsize="$2" [ -z "$2" ] && fontsize=18 || fontsize="$2"
echo -en "\033]710;xft:$font:pixelsize=$fontsize\007" echo -en "\033]710;xft:$font:pixelsize=$fontsize\007"
) )
}
## resync pulseaudio bluetooth connection ## resync pulseaudio bluetooth connection
function btsync() { 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 off
pacmd set-card-profile $card a2dp_sink pacmd set-card-profile $card a2dp_sink
) )
}
# Fancy stuff # Fancy stuff
@ -89,8 +85,7 @@ eval "$(dircolors -b $HOME/.dircolors)"
alias dynamic-colors="~/.dynamic-colors/bin/dynamic-colors" alias dynamic-colors="~/.dynamic-colors/bin/dynamic-colors"
## Timer ## Timer
function timer() { function timer() (
(
if [ -z "$1" ] || [ -z "$2" ]; then if [ -z "$1" ] || [ -z "$2" ]; then
echo "USAGE: $0 [u|f] TIME/DURATION" >&2 echo "USAGE: $0 [u|f] TIME/DURATION" >&2
return 1 return 1
@ -114,12 +109,10 @@ function timer() {
echo "The sleep command failed. Please check the options." >&2 echo "The sleep command failed. Please check the options." >&2
return 3 return 3
fi fi
) )
}
## Wallpaper switcher ## Wallpaper switcher
function wp() { function wp() (
(
if [ -z "$1" ] || ([ "$1" = "rand" ] && [ -z "$2" ]); then if [ -z "$1" ] || ([ "$1" = "rand" ] && [ -z "$2" ]); then
echo "USAGE: $0 rand|restore|default [path]" echo "USAGE: $0 rand|restore|default [path]"
return 1 return 1
@ -135,18 +128,15 @@ function wp() {
if [ "$1" = "restore" ]; then if [ "$1" = "restore" ]; then
~/.fehbg ~/.fehbg
fi fi
) )
}
function currency() { function currency() (
(
amount=${1:-1} amount=${1:-1}
fromcurrency=${2:-USD} fromcurrency=${2:-USD}
tocurrency=${3:-EUR} tocurrency=${3:-EUR}
rate=$(curl -s "https://api.exchangeratesapi.io/latest?base=$fromcurrency&symbols=$tocurrency"|jq ".rates.$tocurrency") rate=$(curl -s "https://api.exchangeratesapi.io/latest?base=$fromcurrency&symbols=$tocurrency"|jq ".rates.$tocurrency")
printf "$amount $fromcurrency: %.02f $tocurrency\n" $(($amount * $rate)) printf "$amount $fromcurrency: %.02f $tocurrency\n" $(($amount * $rate))
) )
}
function urlencode() { 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()))'
@ -157,12 +147,10 @@ function mkvextract-all-attachments() {
} }
# Audacious does not support symlinks; hack around that # Audacious does not support symlinks; hack around that
function audacious-hack() { function audacious-hack() (
(
IFS=$'\n' IFS=$'\n'
audacious $(/bin/ls -1 $1/**/*(@)|sort -Vd) audacious $(/bin/ls -1 $1/**/*(@)|sort -Vd)
) )
}
# Program aliases/env # Program aliases/env
@ -212,12 +200,10 @@ function drone-add-s3() {
drone secret add --name aws_secret_access_key --data "$(pass show data/minio/personal|head -n 1)" "$1" drone secret add --name aws_secret_access_key --data "$(pass show data/minio/personal|head -n 1)" "$1"
} }
function drone() { function drone() (
(
source ~/.drone-env source ~/.drone-env
~/bin/drone $@ ~/bin/drone $@
) )
}
function docker-ls() { function docker-ls() {
DOCKER_LS_PASSWORD=$(pass show accounts/sbruderldap|head -n 1) ~/bin/docker-ls $@ DOCKER_LS_PASSWORD=$(pass show accounts/sbruderldap|head -n 1) ~/bin/docker-ls $@
@ -228,10 +214,8 @@ function docker-rm() {
} }
## lexicon ## lexicon
function lecicon() { function lecicon() (
(
LEXICON_HENET_USERNAME="$(pass management/he|grep User|cut -d: -f2|tr -d ' ')" LEXICON_HENET_USERNAME="$(pass management/he|grep User|cut -d: -f2|tr -d ' ')"
LEXICON_HENET_PASSWORD="$(pass management/he|head -n 1)" LEXICON_HENET_PASSWORD="$(pass management/he|head -n 1)"
lexicon $@ lexicon $@
) )
}