-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.zsh
56 lines (46 loc) · 2.27 KB
/
options.zsh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
function __opt_or_fallback() {
# if option is set, make sure it's exported for vim
# if not, set it to $2
eval "(( \${+$1} )) && export $1=\"\$$1\" || export $1=\"$2\""
}
# KEYBINDINGS ------------------------------------------------------------------
# - explanation name default setting
# ------------------------------------------------------------------------------
# for Zsh, Vim & fzf
# - opens the finder in Zsh and Vim
# - opens the selection in a new split in Vim (automatic hsplit/vsplit)
# - writes the current fzf selection to the buffer in Zsh (if the commandline
# buffer is not empty, you can also simply press `return` to write the pick to
# the buffer)
__opt_or_fallback FZFDF_ACT_1 ctrl-o
# for fzf
# - relaunches the finder from the selection's directory in Zsh
# - opens the selected file in a new tab in Vim
__opt_or_fallback FZFDF_ACT_2 ctrl-u
# for fzf
# - prompts to run a command on the selection in Vim, `{}` will be replaced by
# the selection
__opt_or_fallback FZFDF_ACT_3 ctrl-b
# for fzf
# - prompts to create a new file in the selection's directory
# - in Vim you can append `v[sp[lit]]` or `s[p[lit]]` to the file name to open
# the new file in the respective split
__opt_or_fallback FZFDF_ACT_NEW ctrl-n
# for fzf
# - reloads the finder without ignoring files such as those that are gitignored
# (which is the default behavior)
__opt_or_fallback FZFDF_ACT_RELOAD ctrl-r
# OTHER ------------------------------------------------------------------------
# - explanation name default setting
# ------------------------------------------------------------------------------
# command that is used to list directory contents in the preview window
__opt_or_fallback FZFDF_LS "ls -la {}"
__opt_or_fallback FZFDF_TXT "bat --style=plain --color=always {}"
if [[ -n "$KITTY_PID" ]]; then
__opt_or_fallback FZFDF_IMG 'kitty icat --clear --transfer-mode=memory --stdin=no --place=\${FZF_PREVIEW_COLUMNS}x\${FZF_PREVIEW_LINES}@0x0 {}'
__opt_or_fallback FZFDF_ALL "printf '\x1b_Ga=d,d=A\x1b\\'"
else
__opt_or_fallback FZFDF_IMG "echo image: {}"
__opt_or_fallback FZFDF_ALL ""
fi
unset -f __opt_or_fallback