bin: simplify scripts through expr and improve formatting
This commit is contained in:
parent
51da712040
commit
81f4e66774
|
@ -1,7 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
suffix="${2:-bak}"
|
suffix="${2:-bak}"
|
||||||
orig="${1%%.$suffix}"
|
orig="${1%%.$suffix}"
|
||||||
echo $orig
|
|
||||||
if test -e "$orig.$suffix"
|
if test -e "$orig.$suffix"
|
||||||
then
|
then
|
||||||
test -e "$orig" && mv -v "$orig" /tmp
|
test -e "$orig" && mv -v "$orig" /tmp
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
# Useful when the history has been manipulated
|
# Useful when the history has been manipulated
|
||||||
loc="$(git lo --color=always "$@")"
|
loc="$(git lo --color=always "$@")"
|
||||||
upstream="$(git lo --color=always @{push} "$@")"
|
upstream="$(git lo --color=always @{push} "$@")"
|
||||||
a=$(echo $loc | wc -l)
|
countLoc=$(echo $loc | wc -l)
|
||||||
b=$(echo $upstream | wc -l)
|
countUp=$(echo $upstream | wc -l)
|
||||||
halfcols="$(expr $(tput cols) / 2)"
|
halfcols="$(expr $(tput cols) / 2)"
|
||||||
for i in $(seq 1 $(test $a -le $b && echo "$a" || echo "$b")); do
|
for i in $(seq 1 $(expr $countLoc \& $countLoc \< $countUp \| $countUp)); do
|
||||||
printf "%-${halfcols}s $(test $halfcols -lt 100 && echo '\\n')%s\n" "$(echo $loc | head -n $i | tail -1)" "$(echo $upstream | head -n $i | tail -1)"
|
printf "%-${halfcols}s $(test $halfcols -lt 100 && echo '\\n')%s\n" "$(echo $loc | head -n $i | tail -1)" "$(echo $upstream | head -n $i | tail -1)"
|
||||||
# use columns instead? - need to interleave!
|
# use columns instead? - need to interleave!
|
||||||
done | ${PAGER:-less}
|
done | ${PAGER:-less}
|
||||||
|
|
|
@ -5,6 +5,9 @@ case "$1" in ([0-9]*) code=$1; shift;; esac
|
||||||
|
|
||||||
task="${1:-test}"
|
task="${1:-test}"
|
||||||
test $# -gt 1 && prefix=":$2:"
|
test $# -gt 1 && prefix=":$2:"
|
||||||
gradle=$(test -x "./gradlew" && echo "./gradlew" || echo "gradle")
|
gradle=$(test -x "./gradlew"; expr gradle \& $? \| ./gradlew)
|
||||||
|
|
||||||
( exit $code ); while test $? -eq $code; do $gradle ${prefix}clean$(echo $task | sed -e 's/^./\U&/') ${prefix}$task "${@:3}"; done
|
( exit $code )
|
||||||
|
while test $? -eq $code
|
||||||
|
do $gradle ${prefix}clean$(echo $task | sed -e 's/^./\U&/') ${prefix}$task "${@:3}"
|
||||||
|
done
|
||||||
|
|
|
@ -5,15 +5,15 @@ if test -f "$subscript"
|
||||||
then shift && $subscript "$@"
|
then shift && $subscript "$@"
|
||||||
else
|
else
|
||||||
apikey=$(grep apikey $XDG_CONFIG_HOME/syncthing/config.xml | cut -d '>' -f2 | cut -d '<' -f1)
|
apikey=$(grep apikey $XDG_CONFIG_HOME/syncthing/config.xml | cut -d '>' -f2 | cut -d '<' -f1)
|
||||||
parseargs() {
|
|
||||||
echo hi
|
|
||||||
}
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
(browse|completion|file|ignores|need|status)
|
(browse|completion|file|ignores|need|status)
|
||||||
for arg in "${@:2}"
|
for arg in "${@:2}"
|
||||||
do case "$arg" in ([0-9]) depth=$arg;; (*) path="$arg";; esac
|
do case "$arg" in ([0-9]) depth=$arg;; (*) path="$arg";; esac
|
||||||
done
|
done
|
||||||
query="db/$1?folder=$(test -n "$path" && echo "${path%%/*}" || echo "data")&levels=${depth:-1}$(case "$path" in (*/*) echo "&prefix=${path#*/}";; esac)";;
|
query=$(echo "db/$1?folder=$(expr "${path%%/*}" \& "$path" \| data)
|
||||||
|
$(expr levels \& "$1" = "browse" \| page)=${depth:-1}
|
||||||
|
$(case "$path" in (*/*) echo "$(expr "prefix" \& "$1" = "browse" \| "$1")=${path#*/}";; esac)" |
|
||||||
|
tr -d ' ' | paste -s -d'&');;
|
||||||
(*) query="$1";;
|
(*) query="$1";;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
|
|
|
@ -21,6 +21,6 @@ if test "$#" -gt 0
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
find "$DATA/2-standards/notes/journal" -name "intentions.sync-conflict*" -exec jrnl intentions --import --file {} \; -delete
|
find "$DATA/2-standards/notes/journal" -name "intentions*sync-conflict*" -exec sh -c 'basename {} | cut -d. -f1 | xargs -i% jrnl % --import --file {}' \; -delete
|
||||||
find -name '*sync-conflict*' -exec st-diff $quick '{}' \;
|
find -name '*sync-conflict*' -exec st-diff $quick '{}' \;
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
# Set Workrave mode to quiet and wait the given amount of minutes (default: 10)
|
||||||
# Sets Workrave mode to quiet and waits the given amount of minutes (default: 10)
|
|
||||||
# If no amount is given or the -f flag is provided, it checks whether a fullscreen application is running and if no, exits
|
# If no amount is given or the -f flag is provided, it checks whether a fullscreen application is running and if no, exits
|
||||||
# On exit or Ctrl-C (SIGINT) it sets the Workrave mode back to normal
|
# On exit or Ctrl-C (SIGINT) set Workrave mode back to normal
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
case $1 in
|
case $1 in
|
||||||
|
|
|
@ -4,7 +4,7 @@ umask 0
|
||||||
case $ACTION in
|
case $ACTION in
|
||||||
(add) id=1;;
|
(add) id=1;;
|
||||||
(remove) id=0;;
|
(remove) id=0;;
|
||||||
(*) id=$(test -c /dev/ttyACM0 && echo 1 || echo 0);;
|
(*) id=$(! test -c /dev/ttyACM0; echo $?);;
|
||||||
esac
|
esac
|
||||||
echo "Keyboard layout update to $id($ACTION) at $(date)"
|
echo "Keyboard layout update to $id($ACTION) at $(date)"
|
||||||
export XAUTHORITY="/run/user/1000/Xauthority" DISPLAY=:0
|
export XAUTHORITY="/run/user/1000/Xauthority" DISPLAY=:0
|
||||||
|
|
Loading…
Reference in New Issue