nn() { local NOTE_FILE=$HOME/.notes #if file doesn't exist, create it [[ -f "$NOTE_FILE" ]] || touch "$NOTE_FILE" #no arguments, edit file if [[ -z "$1" ]]; then vim "+set number" "$NOTE_FILE" elif (( $1 )); then tail -"$1" "$NOTE_FILE" elif [[ "$1" == "-s" ]]; then /bin/grep -E --color=always -i -C 1 "$2" "${NOTE_FILE}" elif [[ "$1" == "-h" || $1 == "--help" ]]; then printf "nn [options|note]: Make quick notes\n" printf "Options: \t\twrite to '${NOTE_FILE}'\n" printf "\t\t\tshow '${NOTE_FILE}'\n" printf "\t\tshow last lines of '${NOTE_FILE}'\n" printf "\t-s \tsearch '${NOTE_FILE}' for \n" #append all arguments to file else echo ">> '$@'" >> "$NOTE_FILE" fi }