diff options
| author | Josh Rahm <rahm@google.com> | 2025-02-21 13:58:21 -0700 |
|---|---|---|
| committer | Josh Rahm <rahm@google.com> | 2025-02-21 13:58:21 -0700 |
| commit | fab0330914e5f36131e38610f877cc63bcf43d1c (patch) | |
| tree | 8fbb27ba7e83805aa3c0d409be5cdf7e38558bce /extras/HOME | |
| parent | d4e1ea3b552d4505c828415dbde8e3d8c146fde8 (diff) | |
| download | rde-fab0330914e5f36131e38610f877cc63bcf43d1c.tar.gz rde-fab0330914e5f36131e38610f877cc63bcf43d1c.tar.bz2 rde-fab0330914e5f36131e38610f877cc63bcf43d1c.zip | |
Add notes system.
Diffstat (limited to 'extras/HOME')
| -rwxr-xr-x | extras/HOME/.local/bin/notes-select.sh | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/extras/HOME/.local/bin/notes-select.sh b/extras/HOME/.local/bin/notes-select.sh new file mode 100755 index 0000000..d168c69 --- /dev/null +++ b/extras/HOME/.local/bin/notes-select.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +mkdir -p "$HOME/.notes" +options="$(cd "$HOME/.notes" && find -type f -not -path '*/.*' | sed 's#^./##')" +selection="$( + echo -e "$options" | $ROFI -i -p "Notes" \ + -kb-custom-1 "Alt+d" \ + -kb-custom-2 "Control+c" \ + -theme-str '* {theme-color: #f0f0a0;}' \ + )" + +ec="$?" +if [[ "$ec" -eq 10 ]] ; then + action="delete" +elif [[ "$ec" -eq 11 ]] ; then + action="copy" +else + action="edit" +fi + +if [ -z "${selection}" ] ; then + exit 1 +fi + +function do_edit { + local path="$(readlink -f "$1")" + alacritty --class floating-terminal -e vim "$path" + + if [[ "$path" == *"/shared/"* ]] ; then + cd "$HOME/.notes/shared" + + git add "$path" + git commit -m "Added $(echo "$path" | sed 's#'"$HOME"'#.notes/shared/#')" + fi +} + +fullnotepath="$HOME/.notes/${selection}" +echo "$action" +case "$action" in + "copy") + mkdir -p $(dirname "$fullnotepath") + + if [[ -e "$fullnotepath" ]] ; then + cat "$fullnotepath" | sed -z '$ s/\n$//' | xclip -selection clipboard + else + do_edit "$fullnotepath" + fi + ;; + "edit") + do_edit "$fullnotepath" + ;; + "delete") + echo "delete" + rm "${fullnotepath}" +esac |