Skip to content

Instantly share code, notes, and snippets.

@blinry
Created August 7, 2018 18:25
Show Gist options
  • Save blinry/fc64b3a109dc7bd088470791d08768b1 to your computer and use it in GitHub Desktop.
Save blinry/fc64b3a109dc7bd088470791d08768b1 to your computer and use it in GitHub Desktop.
#!/bin/bash
cd $HOME/permanent/wiki
lastcommittime=$(git show --format="%ct" -s)
nowtime=$(date +%s)
if [ $(($nowtime - $lastcommittime)) -gt $((60*60*24)) ]; then
echo "Autocommit"
git add -A
git commit -m "Autocommit"
fi
cmd=$1
shift
case $cmd in
e|edit)
if [ "$*" ]; then
"$EDITOR" "$*"
else
"$EDITOR" Startseite
fi
;;
s|search)
$0 t $*
echo
$0 f $*
;;
b|backlinks)
$0 f \\[$*\\]
;;
t|title)
ls | grep --color=auto -i "$*"
;;
f|fulltext)
egrep --color=auto -in "$*" *
;;
o|orphans)
for word in *; do
if [ -z "`$0 b $word`" ]; then
echo $word
fi
done
;;
r|random)
$0 e "$(ls | sort -R | head -1)"
;;
*)
$0 e $cmd $*
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment