aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2025-10-03 21:34:06 +0530
committerAkshay Nair <phenax5@gmail.com>2025-10-03 21:34:06 +0530
commit931cf30e66238432fbf653adda7bd08f05a18e87 (patch)
tree73e389661777aae8eff48b741e1f42545e525dfd
parentb1f56e140e6166c06a5b1f0a02aa4bc0953d6eb3 (diff)
downloaddaffm-931cf30e66238432fbf653adda7bd08f05a18e87.tar.gz
daffm-931cf30e66238432fbf653adda7bd08f05a18e87.zip
Add %S substitution for selections as newline separated
-rw-r--r--lib/Daffm/Action/Cmdline.hs5
-rw-r--r--notes.org2
2 files changed, 4 insertions, 3 deletions
diff --git a/lib/Daffm/Action/Cmdline.hs b/lib/Daffm/Action/Cmdline.hs
index 64977aa..e7376c3 100644
--- a/lib/Daffm/Action/Cmdline.hs
+++ b/lib/Daffm/Action/Cmdline.hs
@@ -63,12 +63,13 @@ cmdSubstitutions cmd = do
(AppState {stateFiles, stateCwd, stateFileSelections}) <- get
let file = maybe "" (filePath . snd) . L.listSelectedElement $ stateFiles
let escape = (\s -> "'" <> s <> "'") . Text.replace "'" "\\'"
- let selections = Text.unwords . map (escape . Text.pack) $ Set.elems stateFileSelections
+ let selections = map Text.pack $ Set.elems stateFileSelections
-- TODO: Escaping %
let subst =
Text.replace "%" (Text.pack file)
. Text.replace "%d" (Text.pack stateCwd)
- . Text.replace "%s" selections
+ . Text.replace "%s" (Text.unwords $ map escape selections)
+ . Text.replace "%S" (Text.dropWhileEnd (== '\n') $ Text.unlines selections)
pure . subst $ cmd
applyCmdlineEdit :: (Zipper.TextZipper String -> Zipper.TextZipper String) -> AppEvent ()
diff --git a/notes.org b/notes.org
index 3755c22..660be4b 100644
--- a/notes.org
+++ b/notes.org
@@ -9,9 +9,9 @@
- [X] select multiple files
- [X] Command substitution %s:selections
- [ ] Error handling
-- [ ] Cli arg parsing
- [ ] Command parsing
- [ ] pipe command: Pipe selections/current to stdin of command
+- [ ] Cli arg parsing
** Later
- [ ] handle on open (for external integrations)
- [ ] Cmdline history