Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: escape whitespace in filename #23

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Yukaii
Copy link

@Yukaii Yukaii commented Nov 17, 2024

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