Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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: <note>\t\twrite <note> to '${NOTE_FILE}'\n"
- printf "\t\t\tshow '${NOTE_FILE}'\n"
- printf "\t<number>\tshow last <number> lines of '${NOTE_FILE}'\n"
- printf "\t-s <regex>\tsearch '${NOTE_FILE}' for <regex>\n"
- #append all arguments to file
- else
- echo ">> '$@'" >> "$NOTE_FILE"
- fi
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement