diff options
| author | Akshay Nair <phenax5@gmail.com> | 2025-10-03 21:34:06 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2025-10-03 21:34:06 +0530 |
| commit | 931cf30e66238432fbf653adda7bd08f05a18e87 (patch) | |
| tree | 73e389661777aae8eff48b741e1f42545e525dfd | |
| parent | b1f56e140e6166c06a5b1f0a02aa4bc0953d6eb3 (diff) | |
| download | daffm-931cf30e66238432fbf653adda7bd08f05a18e87.tar.gz daffm-931cf30e66238432fbf653adda7bd08f05a18e87.zip | |
Add %S substitution for selections as newline separated
| -rw-r--r-- | lib/Daffm/Action/Cmdline.hs | 5 | ||||
| -rw-r--r-- | notes.org | 2 |
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 () @@ -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 |
