-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfzf.zsh
More file actions
68 lines (51 loc) · 1.76 KB
/
fzf.zsh
File metadata and controls
68 lines (51 loc) · 1.76 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
# fzf configuration
export FZF_DEFAULT_COMMAND='fd --type f --strip-cwd-prefix'
export FZF_DEFAULT_OPTS="\
--border=none
--color=hl:#f94e4e,hl+:#ffff00,gutter:-1
--info=inline-right
--layout=reverse
"
# Quoting the docs: --select-1 automatically selects the item if there's only
# one so that you don't have to press enter key. Likewise, --exit-0
# automatically exits when the list is empty.
local fzf_singleton_opts="--select-1 --exit-0"
# Key bindings for command-line
source "$(brew --prefix)/opt/fzf/shell/key-bindings.zsh"
# Ctrl-T mode — paste selected items onto command line
export FZF_CTRL_T_COMMAND="fd"
export FZF_CTRL_T_OPTS="
$fzf_singleton_opts
--filepath-word
--preview='bat -n --color=always {}'
--bind='ctrl-/:change-preview-window(down|hidden|)'
"
# Ctrl-R mode — history search
export FZF_CTRL_R_OPTS="\
--height=~30%
--layout=default
--preview='echo {}'
--preview-window='right,50%,border-left,wrap,<60(down,10%,border-top,wrap)'
--bind='ctrl-/:toggle-preview'
--bind='ctrl-y:execute-silent(echo -n {2..} | pbcopy)+abort'
--header='⌃R relevance/chronological • ⌃Y to clipboard • ⌃/ preview'
--header-first
"
# Alt-C mode — cd into selected folder; probably prefer zoxide or just cd with
# autocompletion.
#
# Bit of a behemoth, but this finds folders, ordered by depth then name
export FZF_ALT_C_COMMAND='fd --type d --strip-cwd-prefix | awk -F'\''/'\'' '\''{ print NF, $0 }'\'' | sort -n | cut -d" " -f2-'
export FZF_ALT_C_OPTS="\
$fzf_singleton_opts
--filepath-word
--preview 'tree -C {}'
--no-sort
"
# Fuzzy completion
# I disable this as I prefer the Aloxaf/fzf-tab plugin
# source "$(brew --prefix)/opt/fzf/shell/completion.zsh"
# My fzf extras
autoload -Uz fkill fbr
alias sb=fbr
alias sbm=gswm