I have an ENV variable for a path that has a space in it, export NOTE_DIR="~/path/to folder/" when I try to expand it inside the --preview flag it gets split into two.
local file
file=$(find "${NOTE_DIR}" -name "*.md" | \
sed -e "s|${NOTE_DIR}/||" | \
fzf-tmux \
--multi \
--select-1 \
--exit-0 \
--preview="cat ${NOTE_DIR}/{}" \ # $NOTE_DIR doesn't get expanded properly here
--preview-window=right:70%:wrap)
[[ -n $file ]] && \
${EDITOR:-vim} "${NOTE_DIR}/${file}"
This is default behaviour with bash and zsh. In your example ls ${NOTE_DIR} will also fail.
Adding double quotes around the brace expansion will fix it.
Try this
local file
file=$(find "${NOTE_DIR}" -name "*.md" | \
sed -e "s|${NOTE_DIR}/||" | \
fzf-tmux \
--multi \
--select-1 \
--exit-0 \
--preview="cat \"${NOTE_DIR}\"/{}" \
--preview-window=right:70%:wrap)
[[ -n $file ]] && \
${EDITOR:-vim} "${NOTE_DIR}/${file}"
@deepredsky Thanks!
Thanks @deepredsky 馃憤
Most helpful comment
This is default behaviour with bash and zsh. In your example
ls ${NOTE_DIR}will also fail.Adding double quotes around the brace expansion will fix it.
Try this