bin: remove obsolete note functions & improve diffing

This commit is contained in:
xerus2000 2021-04-07 17:27:02 +02:00
parent 9188a80fe7
commit d848d61fce
7 changed files with 14 additions and 30 deletions

View File

@ -159,15 +159,6 @@ alias jcj='jcl -o json-pretty -u'
alias grp='grep --line-number --ignore-case --binary-files=without-match --directories=skip'
alias grpr='grp --recursive'
# Use grep and sed to replace $1 with $2 recursively
rpl() {
grep --null --recursive --files-with-matches "$1" |
xargs -0 sed -i "/${1}/{
s//${2}/g
w /dev/stdout
}"
}
# 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,2 +0,0 @@
#!/bin/sh
note "box/$(date +%F)-$1"

View File

@ -1,4 +1,4 @@
#!/bin/sh
set -o pipefail
# interactive diff with pagination
diff --color=always --report-identical-files -U 2 "$@" | less --quit-if-one-screen
diff --color=always --report-identical-files -U 2 "$@" | diffr --colors refine-added:none:background:0x33,0x66,0x33:bold --colors added:none:background:0x33,0x44,0x33 --colors refine-removed:none:background:0x66,0x33,0x33:bold --colors removed:none:background:0x44,0x33,0x33 | less --RAW-CONTROL-CHARS --quit-on-intr

5
.local/bin/scripts/git-cdiff Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
# create a diff of diffs - https://stackoverflow.com/a/23527631
dif "${@:3}" <(git show $1) <(git show $2)
#git range-diff $1~..$1 $2~..$2 "${@:3}"

View File

@ -1,16 +0,0 @@
#!/bin/sh
p=$PWD
cd $HOME/daten/Dropbox/dokumente/notes
loc=$1
case $1 in
log|jrnl) shift; file=journal/${1:-jrnl}.txt;; #date +%F >>$file;;
idea) shift; file=ideas/${1:-README}.md;;
box) shift; file=box/$1.md;;
write) shift; file=writings/$1.md;;
msg) shift; file=archive/messages/$1.md;;
*) file=${1:-README}.md;;
esac
comment=$(test -f $file && echo Update || echo Create)
test "$2" && echo "$2" >>$file || $EDITOR + $file
git add $file && git commit -m "$(test "$(dirname $file)" != "." && echo "${loc%%/*}: ")$comment $(basename $file)" && git push
cd $p

8
.local/bin/scripts/rpl Executable file
View File

@ -0,0 +1,8 @@
#!/bin/sh
# Use grep and sed to replace $1 with $2 recursively and print what is done
grep --null --recursive --files-with-matches "$1" |
xargs -0 sed -i "/${1}/{
s//${2}/g
w /dev/stdout
}"

View File

@ -1,2 +0,0 @@
#!/bin/sh
note write "$@"