-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdot_fzf.zsh
More file actions
97 lines (84 loc) · 2.59 KB
/
Copy pathdot_fzf.zsh
File metadata and controls
97 lines (84 loc) · 2.59 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# Setup fzf
# ---------
if [[ ! "$PATH" == */home/tienshuoc/.fzf/bin* ]]; then
PATH="${PATH:+${PATH}:}/home/tienshuoc/.fzf/bin"
fi
export FZF_DEFAULT_COMMAND='fd --type f --hidden --exclude .cache --exclude .git'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
# Bazel + FZF Integration
_fzf_complete_bazel_test() {
_fzf_complete '-m' "$@" < <(command bazel query \
"kind('(test|test_suite) rule', //...)" 2>/dev/null)
}
_fzf_complete_bazel_build() {
_fzf_complete '-m' "$@" < <(command bazel query \
"kind('rule', //...) except kind('(test|test_suite) rule', //...)" 2>/dev/null)
}
_fzf_complete_bazel_run() {
_fzf_complete '-m' "$@" < <(command bazel query \
"kind('.*_binary rule', //...)" 2>/dev/null)
}
_fzf_complete_bazel() {
local tokens
tokens=($(printf "%s" "$LBUFFER" | xargs -n 1))
if [ ${#tokens[@]} -ge 3 ]; then
case "${tokens[2]}" in
test)
_fzf_complete_bazel_test "$@"
;;
build)
_fzf_complete_bazel_build "$@"
;;
run)
_fzf_complete_bazel_run "$@"
;;
*)
# Original completion for other commands
_fzf_complete '-m' "$@" < <(command bazel query --keep_going \
--noshow_progress \
"kind('(binary rule)|(generated file)', deps(//...))" 2>/dev/null)
;;
esac
else
# Original completion when no command specified
_fzf_complete '-m' "$@" < <(command bazel query --keep_going \
--noshow_progress \
"kind('(binary rule)|(generated file)', deps(//...))" 2>/dev/null)
fi
}
_fzf_complete_git_add() {
_fzf_complete "-m --preview 'git diff --color=always {}'" "$@" < <(
command git ls-files --modified --others --exclude-standard
)
}
_fzf_complete_git_restore() {
_fzf_complete "-m --preview 'git diff --color=always {}'" "$@" < <(
command git ls-files --modified
)
}
_fzf_complete_git_stash() {
_fzf_complete "-m --preview 'git diff --color=always {}'" "$@" < <(
command git ls-files --modified --others --exclude-standard
)
}
_fzf_complete_git() {
local tokens
tokens=($(printf "%s" "$LBUFFER" | xargs -n 1))
if [ ${#tokens[@]} -ge 3 ]; then
case "${tokens[2]}" in
add)
_fzf_complete_git_add "$@"
;;
restore)
_fzf_complete_git_restore "$@"
;;
stash)
_fzf_complete_git_stash "$@"
;;
esac
else
# Original completion when no command specified
fi
_fzf_complete "$@"
}
source <(fzf --zsh)