diff options
| author | venomade <venomade@venomade.com> | 2026-02-13 18:09:22 +0000 |
|---|---|---|
| committer | venomade <venomade@venomade.com> | 2026-02-13 18:09:22 +0000 |
| commit | 4b8cc0b9a9d92636b5c5b84595e6302900f5dfce (patch) | |
| tree | f0896b545f01e87c661af2dbf53f80337c06c05e /.local/bin | |
| parent | 0bd150185551b6d8835d022c15a5f6e832d51113 (diff) | |
ZK, NVIM and Misc
Add ZK config, template and script. Add various Neovim plugins, and some markdown specific settings. Add Neovim aliases. Fix 100% in alsa luastatus plugin.
Diffstat (limited to '.local/bin')
| -rwxr-xr-x | .local/bin/rofi-notes | 104 |
1 files changed, 6 insertions, 98 deletions
diff --git a/.local/bin/rofi-notes b/.local/bin/rofi-notes index 876bc66..840dea6 100755 --- a/.local/bin/rofi-notes +++ b/.local/bin/rofi-notes @@ -1,101 +1,9 @@ -#!/usr/bin/env lua +#!/usr/bin/env sh -local HOME = os.getenv("HOME") -local NOTES = HOME .. "/Documents/Notes" -local TERM = "foot -a=floating_foot" -local EDITOR = "nvim" +note_list=$(zk list -f "{{ title }}" -d $'\n' -q) -local MODE = arg[1] -- nil | "--delete" | "-d" +selected=$(printf "%s\n" "$note_list" | rofi -dmenu -i -p " ") -local function rofi(prompt, lines) - local cmd = string.format( - 'printf "%s" | rofi -dmenu -i -p "%s"', - table.concat(lines, "\n"), - prompt - ) - local handle = io.popen(cmd) - local selection = handle:read("*a") - handle:close() - selection = selection:gsub("%s+$", "") - if selection == "" then return nil end - return selection -end - -local function list_notes() - local display = {} - local lookup = {} - - local cmd = string.format('find "%s" -type f', NOTES) - local pipe = assert(io.popen(cmd, "r")) - - for fullPath in pipe:lines() do - local relPath = fullPath:gsub("^" .. NOTES .. "/", "") - local noteName = relPath:gsub("%.[^./]*$", "") - - table.insert(display, noteName) - lookup[noteName] = fullPath - end - - pipe:close() - return display, lookup -end - -local function normalize_path(input) - input = input:gsub("^/", "") - if not input:match("%.md$") then - input = input .. ".md" - end - return NOTES .. "/" .. input -end - -local function ensure_parent_dir(path) - local dir = path:match("(.+)/[^/]+$") - if dir then - os.execute(string.format('mkdir -p "%s"', dir)) - end -end - -local function open_in_nvim(path) - local cmd = string.format( - '%s -e %s "%s"', - TERM, - EDITOR, - path - ) - os.execute(cmd) -end - -local function delete_note(path, name) - local confirm = rofi("Delete " .. name .. "?", { "No", "Yes" }) - if confirm == "Yes" then - os.execute(string.format('rm -- "%s"', path)) - end -end - --- ---- main ---- - -local notes, paths = list_notes() - -if MODE == "--delete" or MODE == "-d" then - local choice = rofi(" ", notes) - if not choice then os.exit(0) end - - local path = paths[choice] - if path then - delete_note(path, choice) - end - - os.exit(0) -end - --- default: open / create -local choice = rofi(" ", notes) -if not choice then os.exit(0) end - -local path = paths[choice] -if not path then - path = normalize_path(choice) - ensure_parent_dir(path) -end - -open_in_nvim(path) +if [[ -n $selected ]]; then + foot -a=floating_foot -e sh -c "zk edit --match \"${selected}\"" +fi |
