Skip to content

fix: escape whitespace in filename#23

Open
Yukaii wants to merge 2 commits into
kkga:mainfrom
Yukaii:bugfix/escape-whitespace-in-filename
Open

fix: escape whitespace in filename#23
Yukaii wants to merge 2 commits into
kkga:mainfrom
Yukaii:bugfix/escape-whitespace-in-filename

Conversation

@Yukaii

@Yukaii Yukaii commented Nov 17, 2024

Copy link
Copy Markdown

When opening a file containing whitespace, the file name needs to have an additional double backslash added.

TODOs

  • buffer
  • cat

For kks-buffer script, I've changed the script to

https://github.com/Yukaii/dotfiles/blob/ec80442b44c718bd5100163618e20c7441385ccb/bin/.bin/kks-buffers#L21-L24

#!/bin/sh
#
# pick buffers
#
# requires:
# - fzf (https://github.com/junegunn/fzf)
# - bat (change to your liking) (https://github.com/sharkdp/bat)

preview_cmd="bat --color=always --line-range=:500"
history_file="$HOME/.cache/kks-buffers-history"

[ -f "$history_file" ] || touch "$history_file"

kks get '%val{buflist}' |
	grep -F "$*" |
	fzf --height 100% --highlight-line --prompt 'buf> ' --preview "kks cat -b {} | $preview_cmd" \
		--header="[c-x] delete, [c-t] new scratch" \
		--bind="ctrl-x:execute-silent(kks send -b {} delete-buffer)+reload(kks get '%val{buflist}')" \
		--bind="ctrl-t:execute-silent(kks send edit -scratch {q})+reload(kks get '%val{buflist}')" \
		--history="$history_file" |
	while read -r name; do
    escaped_name=$(printf "'%s'" "$(echo "$name" | sed 's/ /\\ /g')")
    kks send buffer "$escaped_name"
	done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant