Repository navigation
Expand file tree
/
Copy pathfzf-zsh-plugin.diff
More file actions
207 lines (195 loc) · 6.09 KB
/
Copy pathfzf-zsh-plugin.diff
File metadata and controls
207 lines (195 loc) · 6.09 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
diff --git a/bin/apt-fzf-search b/bin/apt-fzf-search
index 612532f..70f2990 100755
--- a/bin/apt-fzf-search
+++ b/bin/apt-fzf-search
@@ -26,7 +26,7 @@ function has() {
}
if has apt-cache; then
- apt-cache search "$@" | \
+ apt-cache search "${*:-}" | \
sort | \
cut --delimiter ' ' --fields 1 | \
fzf --multi --cycle --reverse --preview 'apt-cache show {1}' | \
diff --git a/bin/d-attach b/bin/d-attach
index f166954..92a3be4 100755
--- a/bin/d-attach
+++ b/bin/d-attach
@@ -29,7 +29,10 @@ function da() {
local cid
cid=$(docker ps -a | sed 1d | fzf -1 -q "$1" | awk '{print $1}')
- [ -n "$cid" ] && docker start "$cid" && docker attach "$cid"
+ if [ -n "$cid" ]; then
+ printf 'docker start %q && docker attach %q\n' "$cid" "$cid"
+ docker start "$cid" && docker attach "$cid"
+ fi
}
if has docker; then
diff --git a/bin/d-image-rm b/bin/d-image-rm
index e694283..bbecf36 100755
--- a/bin/d-image-rm
+++ b/bin/d-image-rm
@@ -31,7 +31,7 @@ function drmi() {
# tag; allows removing a tag from an image with multiple tags
docker images | sed 1d | fzf -q "$1" --no-sort -m --tac |
awk '{ print ($2=="<none>")?$3:$1 ":" $2 }' |
- xargs -r docker rmi
+ xargs -rt docker rmi
}
if has docker; then
diff --git a/bin/d-rm b/bin/d-rm
index 7409e27..fe5839f 100755
--- a/bin/d-rm
+++ b/bin/d-rm
@@ -26,7 +26,7 @@ function has() {
}
function drm() {
- docker ps -a | sed 1d | fzf -q "$1" --no-sort -m --tac | awk '{ print $1 }' | xargs -r docker rm
+ docker ps -a | sed 1d | fzf -q "$1" --no-sort -m --tac | awk '{ print $1 }' | xargs -rt docker rm
}
if has docker; then
diff --git a/bin/d-stop-container b/bin/d-stop-container
index aed7cfb..45fa196 100755
--- a/bin/d-stop-container
+++ b/bin/d-stop-container
@@ -30,7 +30,10 @@ function d-stop-container() {
local cid
cid=$(docker ps | sed 1d | fzf -q "$1" | awk '{print $1}')
- [ -n "$cid" ] && docker stop "$cid"
+ if [ -n "$cid" ]; then
+ printf 'docker stop %q\n' "$cid"
+ docker stop "$cid"
+ fi
}
if has docker; then
diff --git a/bin/fif b/bin/fif
index 7c5142d..9047949 100755
--- a/bin/fif
+++ b/bin/fif
@@ -10,13 +10,14 @@ if [[ -n "$DEBUG" ]]; then
fi
fif() {
- if [ ! "$#" -gt 0 ]; then
- echo "Need a string to search for!";
- return 1;
- fi
+ # if [ ! "$#" -gt 0 ]; then
+ # echo "Need a string to search for!";
+ # return 1;
+ # fi
# if FZF_PREVIEW_WINDOW is undefined, quoting it breaks the script
# shellcheck disable=SC2086
- rg --files-with-matches --no-messages "$1" | fzf --preview-window "$FZF_PREVIEW_WINDOW" --preview "rg --ignore-case --pretty --context 10 '$1' {}"
+ # rg --files-with-matches --no-messages "$1" | fzf --preview-window "$FZF_PREVIEW_WINDOW" --preview "rg --ignore-case --pretty --context 10 '$1' {}"
+ rg --no-messages "${*:-}" | fzf --preview-window "$FZF_PREVIEW_WINDOW" --preview "rg --ignore-case --pretty --context 10 '$1' {}"
}
[[ -z "$FZF_PREVIEW_WINDOW" ]] && export FZF_PREVIEW_WINDOW=':hidden'
diff --git a/bin/fzf-find-edit b/bin/fzf-find-edit
index 027d676..b112dd1 100755
--- a/bin/fzf-find-edit
+++ b/bin/fzf-find-edit
@@ -24,6 +24,7 @@ if has bat; then
--preview 'bat --color=always --line-range :500 {}'
)
if [[ -n "$file" ]]; then
+ printf '%s %q\n' "$EDITOR" "$file"
$EDITOR "$file"
fi
}
@@ -35,6 +36,7 @@ else
--preview 'head -100 {}'
)
if [[ -n "$file" ]]; then
+ printf '%s %q\n' "$EDITOR" "$file"
$EDITOR "$file"
fi
}
diff --git a/bin/fzf-git-checkout b/bin/fzf-git-checkout
index 25bde81..f79ff07 100755
--- a/bin/fzf-git-checkout
+++ b/bin/fzf-git-checkout
@@ -48,8 +48,10 @@ fzf-git-checkout() {
# using --track and a remote branch name, it is the same as:
# git checkout -b branchName --track origin/branchName
if [[ "$branch" = 'remotes/'* ]]; then
+ printf 'git checkout --track %q\n' "$branch"
git checkout --track $branch
else
+ printf 'git checkout %q\n' "$branch"
git checkout $branch;
fi
}
diff --git a/bin/fzf-grep-edit b/bin/fzf-grep-edit
index 0672454..1a0d46d 100755
--- a/bin/fzf-grep-edit
+++ b/bin/fzf-grep-edit
@@ -22,36 +22,40 @@ fi
if has bat; then
fzf-grep-edit(){
- if [[ $# == 0 ]]; then
- echo 'Error: search term was not provided.'
- return
- fi
+ # if [[ $# == 0 ]]; then
+ # echo 'Error: search term was not provided.'
+ # return
+ # fi
match=$(
- rg --color=never --line-number "$1" |
+ rg --color=never --line-number "${*:-}" |
fzf --no-multi --delimiter : \
--preview "bat --color=always --line-range {2}: {1}"
)
file=$(echo "$match" | cut -d':' -f1)
if [[ -n $file ]]; then
+ line=$(echo "$match" | cut -d':' -f2)
+ printf '%s %q +%s\n' "$EDITOR" "$file" "$line"
# shellcheck disable=SC2046
- $EDITOR "$file" +$(echo "$match" | cut -d':' -f2)
+ $EDITOR "$file" +"$line"
fi
}
else
fzf-grep-edit(){
- if [[ $# == 0 ]]; then
- echo 'Error: search term was not provided.'
- return
- fi
+ # if [[ $# == 0 ]]; then
+ # echo 'Error: search term was not provided.'
+ # return
+ # fi
match=$(
- rg --color=never --line-number "$1" |
+ rg --color=never --line-number "${*:-}" |
fzf --no-multi --delimiter : \
--preview "head -100 {2}: {1}"
)
file=$(echo "$match" | cut -d':' -f1)
if [[ -n $file ]]; then
+ line=$(echo "$match" | cut -d':' -f2)
+ printf '%s %q +%s\n' "$EDITOR" "$file" "$line"
# shellcheck disable=SC2046
- $EDITOR "$file" +$(echo "$match" | cut -d':' -f2)
+ $EDITOR "$file" +"$line"
fi
}
fi
diff --git a/bin/fzf-vscode b/bin/fzf-vscode
index 24b8935..2cdb249 100755
--- a/bin/fzf-vscode
+++ b/bin/fzf-vscode
@@ -11,7 +11,7 @@
# 2. Interactively narrow down the list using fzf
# 3. Open the file in vscode
-set -euo pipefail
+set -eo pipefail
if [[ -n "$DEBUG" ]]; then
set -x
fi
@@ -77,5 +77,6 @@ done < <(
--preview-window 'up,60%,border-bottom,+{2}+3/3,~3'
)
if [ -n "${ARGLIST}" ]; then
+ echo "code ${NEW_WINDOW} ${ARGLIST}"
code ${NEW_WINDOW} ${ARGLIST}
fi