bin: little script improvements

This commit is contained in:
xeruf 2021-05-02 19:35:50 +02:00
parent 95b6d34580
commit 40d3ba2b98
3 changed files with 5 additions and 3 deletions

View File

@ -177,7 +177,7 @@ alias jc='jcl -u'
alias jcj='jcl -o json-pretty -u'
alias grp='grep --line-number --ignore-case --binary-files=without-match --directories=skip'
alias grpr='grp --recursive'
alias grpr='grp --recursive --exclude-dir={.sync,.stfolder,.git}'
# Recover stray swap files from neovim
alias vrec="ls $XDG_DATA_HOME/nvim/swap | sed 's/\%/\//g' | sed 's|\(.*\)\..*|\1|' | head -1 | xargs -r nvim"

View File

@ -1,6 +1,7 @@
#!/bin/sh
# Use grep and sed to replace $1 with $2 recursively and print what is done
grep --null --recursive --files-with-matches --binary-files=without-match "$1" |
grep --null --recursive --files-with-matches \
--binary-files=without-match --exclude-dir={.sync,.stfolder,.git} "$1" |
xargs -0 sed -i "/${1}/{
s//${2}/g
w /dev/stdout

View File

@ -1,11 +1,12 @@
#!/bin/sh
umask 0
{
case $ACTION in
(add) id=1;;
(remove) id=0;;
(*) id=$(test -c /dev/ttyACM0 && echo 1 || echo 0);;
esac
echo "Keyboard layout update to $id($ACTION) at $(date)" >>/tmp/scripts.log
echo "Keyboard layout update to $id($ACTION) at $(date)"
export XAUTHORITY="/run/user/1000/Xauthority" DISPLAY=:0
xkbstate="$(dirname $(dirname $0))/xkblayout-state"