Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
端末エミュレータ上で一言メモをとるためのシェルスクリプト
#!/bin/sh
# ログファイルへのパス
LOG_FILE=~/hitokoto.log
# 引数なしの場合はログの最終行を表示
if [ $# = 0 ]; then
tail -n 1 $LOG_FILE
exit
fi
# 指定した行数だけ履歴を表示
if [ "$1" = "-h" ]; then
tail -n $2 $LOG_FILE
exit
fi
# 検索(大文字/小文字は区別しない)
if [ "$1" = "-s" ]; then
cat $LOG_FILE | grep -in --color=auto $2
exit
fi
DATE=`date '+%F %T'`
echo "[$DATE] $*" >> $LOG_FILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment