Skip to content

Instantly share code, notes, and snippets.

@napthink
Last active November 6, 2016 11:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save napthink/8562ac1a068264353719d9719add672d to your computer and use it in GitHub Desktop.
Save napthink/8562ac1a068264353719d9719add672d to your computer and use it in GitHub Desktop.
端末エミュレータ上で一言メモをとるためのシェルスクリプト
#!/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