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 /lib | |
| parent | b1f56e140e6166c06a5b1f0a02aa4bc0953d6eb3 (diff) | |
| download | daffm-931cf30e66238432fbf653adda7bd08f05a18e87.tar.gz daffm-931cf30e66238432fbf653adda7bd08f05a18e87.zip | |
Add %S substitution for selections as newline separated
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/Daffm/Action/Cmdline.hs | 5 |
1 files changed, 3 insertions, 2 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 () |
