aboutsummaryrefslogtreecommitdiff
path: root/lib/Daffm/Action/Cmdline.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Daffm/Action/Cmdline.hs')
-rw-r--r--lib/Daffm/Action/Cmdline.hs5
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 ()