Skip to content

Instantly share code, notes, and snippets.

@brainfucksec
Last active March 5, 2023 21:06
Show Gist options
  • Select an option

  • Save brainfucksec/56acb77fba3b6001e5592bbf6350e0d3 to your computer and use it in GitHub Desktop.

Select an option

Save brainfucksec/56acb77fba3b6001e5592bbf6350e0d3 to your computer and use it in GitHub Desktop.

Revisions

  1. brainfucksec revised this gist Apr 10, 2021. 1 changed file with 25 additions and 22 deletions.
    47 changes: 25 additions & 22 deletions note.sh
    Original file line number Diff line number Diff line change
    @@ -1,29 +1,32 @@
    #!/usr/bin/env bash

    ##########################################################################
    #####################################################################
    # note.sh
    # KISS Terminal note taker
    # Copyright (C) 2019 Brainfuck
    # Copyright (C) 2021 Brainfuck
    #
    #
    # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
    #
    # This work is free. You can redistribute it and/or modify it under the
    # terms of the Do What The Fuck You Want To Public License, Version 2,
    # as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
    ##########################################################################
    #####################################################################


    # Program information
    readonly prog_name="note"
    readonly version="0.3"
    readonly signature="Copyright (C) 2019 Brainfuck"
    readonly version="0.4"
    readonly signature="Copyright (C) 2021 Brainfuck"

    # Set program directory and files
    readonly note_dir="$HOME/documents/notes"
    readonly todo="$note_dir/todo.md"
    readonly quicknote="$note_dir/quicknote.md"
    readonly commands="$note_dir/commands.md"
    #
    # insert the directory where to save notes
    readonly note_dir="${HOME}/documents/notes"

    readonly todo="${note_dir}/todo.md"
    readonly quicknote="${note_dir}/quicknote.md"
    readonly commands="${note_dir}/commands.md"


    # Function for error handling, print an error message and exit with (1).
    @@ -37,8 +40,8 @@ die() {
    open_file() {
    local cwfile="$1"

    if [[ -f "$cwfile" ]]; then
    "$EDITOR" "$cwfile"
    if [[ -f "${cwfile}" ]]; then
    "${EDITOR}" "${cwfile}"
    exit 0
    else
    die
    @@ -49,16 +52,16 @@ open_file() {
    # help menù
    help_menu() {
    cat << EOF
    $prog_name $version
    ${prog_name} ${version}
    KISS Terminal note taker
    $signature
    ${signature}
    Usage: $prog_name <argument>
    Usage: ${prog_name} <argument>
    Arguments:
    -h, help Show this help menù and exit
    -t, todo Edit/add todo
    -q, quicknote Edit/add note (quick note)
    -m, quicknote Edit/add note (quick note)
    -c, commands Edit/add commands
    EOF
    }
    @@ -67,8 +70,8 @@ EOF
    # Main function
    main() {
    if [[ "$#" == 0 ]]; then
    echo "$prog_name: please insert an argument"
    echo "Try '$prog_name help' for more information."
    echo "${prog_name}: please insert an argument"
    echo "Try '${prog_name} help' for more information."
    exit 1
    fi

    @@ -79,17 +82,17 @@ main() {
    exit 0
    ;;
    -t | todo)
    open_file "$todo"
    open_file "${todo}"
    ;;
    -q | quicknote)
    open_file "$quicknote"
    open_file "${quicknote}"
    ;;
    -c | commands)
    open_file "$commands"
    open_file "${commands}"
    ;;
    -* | *)
    echo "$prog_name: invalid argument!"
    echo "Try '$prog_name help' for more information."
    echo "${prog_name}: invalid argument!"
    echo "Try '${prog_name} help' for more information."
    exit 1
    ;;
    esac
  2. brainfucksec revised this gist Aug 5, 2020. 1 changed file with 49 additions and 0 deletions.
    49 changes: 49 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,49 @@
    # note

    [KISS](https://en.wikipedia.org/wiki/KISS_principle) Terminal note taker.


    This script consists of only 4 components:

    * note.sh (The executable file)
    * todo.md (A TODO file)
    * quicknote.md (For the quick notes)
    * commands.md (Your list of commands/cheat sheets)


    ## Install

    Create the default directory and files:
    ```bash
    mkdir -p ~/documents/notes/
    touch ~/documents/notes/todo.md
    touch ~/documents/notes/quicknote.md
    touch ~/documents/notes/commands.md
    ```

    Copy executable in your 'bin' folder ($HOME/bin is preferable):
    ```bash
    cp notes.sh ~/bin/note
    chmod +x ~/bin/note
    ```

    ## Usage

    ### Edit/add TODO
    ```bash
    note -t | todo
    ```

    ### Edit/add quick note
    ```bash
    note -q | quicknote
    ```

    ### Edit/add commands
    ```bash
    note -c | commands
    ```



    _IN KISS WE TRUST_
  3. brainfucksec revised this gist Jun 17, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion note.sh
    Original file line number Diff line number Diff line change
    @@ -58,7 +58,7 @@ Usage: $prog_name <argument>
    Arguments:
    -h, help Show this help menù and exit
    -t, todo Edit/add todo
    -m, quicknote Edit/add note (quick note)
    -q, quicknote Edit/add note (quick note)
    -c, commands Edit/add commands
    EOF
    }
  4. brainfucksec revised this gist Nov 9, 2019. 1 changed file with 28 additions and 43 deletions.
    71 changes: 28 additions & 43 deletions note.sh
    Original file line number Diff line number Diff line change
    @@ -2,65 +2,46 @@

    ##########################################################################
    # note.sh
    #
    # KISS Terminal note taker
    #
    # Copyright (C) 2019 Brainfuck
    #
    #
    # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
    #
    # This work is free. You can redistribute it and/or modify it under the
    # terms of the Do What The Fuck You Want To Public License, Version 2,
    # as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
    #
    ##########################################################################


    # Program information
    readonly prog_name="note"
    readonly version="0.1"
    readonly version="0.3"
    readonly signature="Copyright (C) 2019 Brainfuck"

    # Settings
    # Set program directory and files
    readonly note_dir="$HOME/documents/notes"
    readonly todofile="$note_dir/todo.md"
    readonly notefile="$note_dir/quicknote.txt"


    # Check if note directory exists
    checkdir() {
    if [[ ! -d $note_dir ]]; then
    echo "Error: note directory not exists :("
    echo "Please read the instructions in the README file"
    exit 1
    fi
    }

    readonly todo="$note_dir/todo.md"
    readonly quicknote="$note_dir/quicknote.md"
    readonly commands="$note_dir/commands.md"

    # Edit/add todo (files will be opened with your $EDITOR)
    todo() {
    checkdir

    if [[ -f "$todofile" ]]; then
    "$EDITOR" "$todofile"
    exit 0
    else
    echo "Error: todo file not exists :("
    exit 1
    fi
    # Function for error handling, print an error message and exit with (1).
    die() {
    echo "Error: file not exists :(" >&2
    exit 1
    }


    # Edit/add note
    quicknote() {
    checkdir
    # Edit/add (files will be opened with your $EDITOR)
    open_file() {
    local cwfile="$1"

    if [[ -f "$notefile" ]]; then
    "$EDITOR" "$notefile"
    if [[ -f "$cwfile" ]]; then
    "$EDITOR" "$cwfile"
    exit 0
    else
    echo "Error: note file not exists :("
    exit 1
    die
    fi
    }

    @@ -70,13 +51,15 @@ help_menu() {
    cat << EOF
    $prog_name $version
    KISS Terminal note taker
    $signature
    Usage: $prog_name <argument>
    Arguments:
    -h, help Show this help menù and exit
    -t, todo Edit/add todo
    -m, mark Edit/add note (quick note)
    -h, help Show this help menù and exit
    -t, todo Edit/add todo
    -m, quicknote Edit/add note (quick note)
    -c, commands Edit/add commands
    EOF
    }

    @@ -96,10 +79,13 @@ main() {
    exit 0
    ;;
    -t | todo)
    todo
    open_file "$todo"
    ;;
    -q | quicknote)
    open_file "$quicknote"
    ;;
    -m | mark)
    quicknote
    -c | commands)
    open_file "$commands"
    ;;
    -* | *)
    echo "$prog_name: invalid argument!"
    @@ -110,5 +96,4 @@ main() {
    done
    }


    main "$@"
    main "$@"
  5. brainfucksec revised this gist May 2, 2019. No changes.
  6. brainfucksec revised this gist May 1, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion note.sh
    Original file line number Diff line number Diff line change
    @@ -111,4 +111,4 @@ main() {
    }


    main "$@"
    main "$@"
  7. brainfucksec revised this gist May 1, 2019. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion note.sh
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,6 @@
    #
    # Copyright (C) 2019 Brainfuck
    #
    #
    # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
    #
    # This work is free. You can redistribute it and/or modify it under the
  8. brainfucksec created this gist May 1, 2019.
    115 changes: 115 additions & 0 deletions note.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,115 @@
    #!/usr/bin/env bash

    ##########################################################################
    # note.sh
    #
    # KISS Terminal note taker
    #
    # Copyright (C) 2019 Brainfuck
    #
    #
    # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
    #
    # This work is free. You can redistribute it and/or modify it under the
    # terms of the Do What The Fuck You Want To Public License, Version 2,
    # as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
    #
    ##########################################################################


    # Program information
    readonly prog_name="note"
    readonly version="0.1"
    readonly signature="Copyright (C) 2019 Brainfuck"

    # Settings
    readonly note_dir="$HOME/documents/notes"
    readonly todofile="$note_dir/todo.md"
    readonly notefile="$note_dir/quicknote.txt"


    # Check if note directory exists
    checkdir() {
    if [[ ! -d $note_dir ]]; then
    echo "Error: note directory not exists :("
    echo "Please read the instructions in the README file"
    exit 1
    fi
    }


    # Edit/add todo (files will be opened with your $EDITOR)
    todo() {
    checkdir

    if [[ -f "$todofile" ]]; then
    "$EDITOR" "$todofile"
    exit 0
    else
    echo "Error: todo file not exists :("
    exit 1
    fi
    }


    # Edit/add note
    quicknote() {
    checkdir

    if [[ -f "$notefile" ]]; then
    "$EDITOR" "$notefile"
    exit 0
    else
    echo "Error: note file not exists :("
    exit 1
    fi
    }


    # help menù
    help_menu() {
    cat << EOF
    $prog_name $version
    KISS Terminal note taker
    Usage: $prog_name <argument>
    Arguments:
    -h, help Show this help menù and exit
    -t, todo Edit/add todo
    -m, mark Edit/add note (quick note)
    EOF
    }


    # Main function
    main() {
    if [[ "$#" == 0 ]]; then
    echo "$prog_name: please insert an argument"
    echo "Try '$prog_name help' for more information."
    exit 1
    fi

    while [[ "$#" -gt 0 ]]; do
    case "$1" in
    -h | help)
    help_menu
    exit 0
    ;;
    -t | todo)
    todo
    ;;
    -m | mark)
    quicknote
    ;;
    -* | *)
    echo "$prog_name: invalid argument!"
    echo "Try '$prog_name help' for more information."
    exit 1
    ;;
    esac
    done
    }


    main "$@"