diff options
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/daffm.home/config/config.kak.toml | 20 | ||||
| -rw-r--r-- | modules/daffm.home/config/config.lastcd.toml | 11 | ||||
| -rw-r--r-- | modules/daffm.home/config/config.nvim.toml | 22 | ||||
| -rw-r--r-- | modules/daffm.home/config/config.picker.toml | 18 | ||||
| -rw-r--r-- | modules/daffm.home/config/config.toml | 115 | ||||
| -rw-r--r-- | modules/daffm.home/default.nix | 14 |
6 files changed, 200 insertions, 0 deletions
diff --git a/modules/daffm.home/config/config.kak.toml b/modules/daffm.home/config/config.kak.toml new file mode 100644 index 0000000..3fba99a --- /dev/null +++ b/modules/daffm.home/config/config.kak.toml @@ -0,0 +1,20 @@ +opener = """ +echo "$files" | while IFS= read file; do + kcr edit "$file" +done +""" +extend = "@" + +[keymap] +l = "open-and-quit" +"<cr>" = "open-and-quit" + +"~" = """eval + echo "<daffm>cd '${DAFFM_PATH_RELATIVE_TO:-$PWD}'" +""" + +[commands] +open-and-quit = [ + """eval [ -d "$cursor" ] || echo '<daffm>quit' """, + "open" +] diff --git a/modules/daffm.home/config/config.lastcd.toml b/modules/daffm.home/config/config.lastcd.toml new file mode 100644 index 0000000..d04e3e0 --- /dev/null +++ b/modules/daffm.home/config/config.lastcd.toml @@ -0,0 +1,11 @@ +extend = "@" + +[keymap] +q = [ + "quit", + """shell + [ -z "$DAFFM_LAST_DIR_PATH" ] || pwd > "$DAFFM_LAST_DIR_PATH"; + """ +] +cq = "quit" +Q = "quit" diff --git a/modules/daffm.home/config/config.nvim.toml b/modules/daffm.home/config/config.nvim.toml new file mode 100644 index 0000000..0e6ac1a --- /dev/null +++ b/modules/daffm.home/config/config.nvim.toml @@ -0,0 +1,22 @@ +opener = """ + if [ -z "$DAFFM_SELECTIONS_OUT" ]; then + echo "<cant open file>" + else + echo "$files" > "$DAFFM_SELECTIONS_OUT"; + fi +""" +extend = "@" + +[keymap] +l = "open-and-quit" +"<cr>" = "open-and-quit" + +"~" = """eval + echo "<daffm>cd '${DAFFM_PATH_RELATIVE_TO:-$PWD}'" +""" + +[commands] +open-and-quit = [ + """eval [ -z $DAFFM_SELECTIONS_OUT ] || [ -d "$cursor" ] || echo '<daffm>quit' """, + "open" +] diff --git a/modules/daffm.home/config/config.picker.toml b/modules/daffm.home/config/config.picker.toml new file mode 100644 index 0000000..d3a3751 --- /dev/null +++ b/modules/daffm.home/config/config.picker.toml @@ -0,0 +1,18 @@ +opener = """ + if [ -z "$DAFFM_SELECTIONS_OUT" ]; then + echo "<cant open file>" + else + echo "%F" > "$DAFFM_SELECTIONS_OUT"; + fi +""" +extend = "@" + +[keymap] +l = "open-and-quit" +"<cr>" = "open-and-quit" + +[commands] +open-and-quit = [ + """eval [ -z $DAFFM_SELECTIONS_OUT ] || [ -d "$cursor" ] || echo '<daffm>quit' """, + "open" +] diff --git a/modules/daffm.home/config/config.toml b/modules/daffm.home/config/config.toml new file mode 100644 index 0000000..9f3d26b --- /dev/null +++ b/modules/daffm.home/config/config.toml @@ -0,0 +1,115 @@ +opener = """ +echo "$files" | while IFS= read file; do + case "$(file --mime-type "$file" -bL)" in + image/*) setsid -f sxiv "$file" >/dev/null 2>&1 ;; + video/*|image/gif) setsid -f mpv "$file" >/dev/null 2>&1 ;; + application/pdf) setsid -f zathura "$file" >/dev/null 2>&1 ;; + *) + if isutf8 -q "$file"; then + $EDITOR "$file" + else + setsid -f xdg-open "$file" + fi + ;; + esac +done; +""" + +[keymap] +md = "cmdline-set !mkdir -p " +mf = "cmdline-set !touch " +rn = ["""!! clear; echo "$files" | vidir -v - """, "selection-clear"] +rd = "!! clear; vidir -v ." +dd = """! clear; echo "$files"; rm -rfIv %f""" +sdd = """! clear; echo "$files"; sudo rm -rfIv %f""" +cc = ["""!! clear; echo "Duplicated $cursor"; cp -r "$cursor" "${cursor}.dup" """, "selection-clear"] +cp = ["!!cp -irv %s -t %d", "selection-clear"] +mv = ["!!mv -iv %s -t %d", "selection-clear"] + +gdl = "cd ~/Downloads" +gdm = "cd ~/Downloads/music" +gdc = "cd ~/Documents" +gp = "cd ~/Pictures" +gsc = "cd ~/Pictures/screenshots" +gdp = "cd ~/dump" +gmnt = "cd /run/media/imsohexy" +gdv = "cd ~/dev/projects" +gcc = "cd ~/.config" +gcl = "cd ~/.local" + +# Clipboard +yy = """shell +relpath=$(realpath -s --relative-to="${DAFFM_PATH_RELATIVE_TO:-$PWD}" "$cursor") +echo -n "$relpath" | xclip -selection clipboard +""" +YY = """shell +echo -n "$cursor" | xclip -selection clipboard +""" +yc = """shell +xclip -selection clipboard -t $(file --mime-type % -bL) -i "$cursor" +""" +yf = """shell +echo "$files" | sed 's|^|file://|' | xclip -selection clipboard -t text/uri-list -i +""" + +# Mark directories +"m1" = """eval echo "<daffm>map <space>1 cd %d" """ +"m2" = """eval echo "<daffm>map <space>2 cd %d" """ +"m3" = """eval echo "<daffm>map <space>3 cd %d" """ +"m4" = """eval echo "<daffm>map <space>4 cd %d" """ + +# Alt openers +"<space>du" = "!!dua i ." +"\\xz" = """!! unzip "$cursor" """ +"\\x7" = """!! 7z x "$cursor" """ +"\\xt" = """!! tar xzf "$cursor" """ +"\\xr" = """!! unrar x "$cursor" """ +"\\wi" = """!! wine "$cursor" """ +"<space>p" = "preview" +"<space>fd" = [ + """shell + clear; + realpath -q "$(fd --type d --hidden | fzf)" > /tmp/.daffm-fzf-output; + """, + """eval + if [ -s "/tmp/.daffm-fzf-output" ]; then + echo "<daffm>cd $(cat /tmp/.daffm-fzf-output)" + fi + rm -f /tmp/.daffm-fzf-output + """ +] + +[commands] +preview = """shell! +file='%args' +if [ -z "$file" ]; then file="$cursor"; fi +clear; +case "$file" in + *.bmp|*.jpg|*.jpeg|*.png|*.xpm|*.webp|*.gif) chafa -f kitty "$file" ;; + *.wav|*.mp3|*.flac|*.m4a|*.wma|*.ac3|*.og[agx]|*.opus|*.flac) + mediainfo "$file" + ;; + *.avi|*.mp4|*.ogv|*.mkv|*.mpg|*.mpeg|*.m2v|*.mov|*.webm|*.mts|*.m4v) + mediainfo "$file" + ;; + *.pdf) pdftotext "$file" - | less ;; + *.docx) docx2txt "$file" - | less ;; + *.md|*.org) glow -s dark -p "$file" ;; + *.tgz|*.tar.gz) tar tzf "$file" ;; + *.tar.bz2|*.tbz2) tar tjf "$file" ;; + *.tar.bz2|*.tbz2) tar tjf "$file" ;; + *.tar.txz|*.txz) xz --list "$file" ;; + *.tar) tar tf "$file" ;; + *.zip|*.jar|*.war|*.ear|*.oxt) unzip -l "$file" ;; + *.rar) unrar l "$file" ;; + *.7z) 7z l "$file" ;; + *.o) nm "$file" | less ;; + *) + if isutf8 -q "$file"; then + bat --color always "$file" || cat "$file" + else + mediainfo "$file" + fi + ;; +esac +""" diff --git a/modules/daffm.home/default.nix b/modules/daffm.home/default.nix new file mode 100644 index 0000000..6261f70 --- /dev/null +++ b/modules/daffm.home/default.nix @@ -0,0 +1,14 @@ +{ pkgs, ... }: +let + # daffm-pkg = (builtins.getFlake "github:phenax/daffm/b61d4cdc759e08eb7990aa7f3a67eb737cd7b930").packages.x86_64-linux.default + daffm-pkg = pkgs.writeShellScriptBin "daffm" ''exec /home/imsohexy/dev/projects/daffm/result/bin/daffm "$@"''; +in +{ + home.packages = [ + daffm-pkg + ]; + + home.file = { + ".config/daffm".source = ./config; + }; +} |
