@andespindola/crow-term-linux-x64 0.0.0-bootstrap.1 → 0.1.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +55 -0
- package/NOTICE.md +25 -0
- package/README.md +5 -0
- package/THIRD_PARTY_LICENSES.txt +71128 -0
- package/assets/fonts/OFL.txt +96 -0
- package/assets/theme-license.txt +21 -0
- package/bin/crow-term +4 -0
- package/bin/shell/README.md +37 -0
- package/bin/shell/plugins.lock.json +63 -0
- package/bin/shell/setup.py +241 -0
- package/bin/shell/vendor/fisher/LICENSE.md +7 -0
- package/bin/shell/vendor/fisher/completions/fisher.fish +7 -0
- package/bin/shell/vendor/fisher/functions/fisher.fish +251 -0
- package/bin/shell/vendor/z/LICENSE +21 -0
- package/bin/shell/vendor/z/conf.d/z.fish +63 -0
- package/bin/shell/vendor/z/functions/__z.fish +178 -0
- package/bin/shell/vendor/z/functions/__z_add.fish +49 -0
- package/bin/shell/vendor/z/functions/__z_clean.fish +11 -0
- package/bin/shell/vendor/z/functions/__z_complete.fish +13 -0
- package/bin/shell/vendor/zsh-autosuggestions/LICENSE +23 -0
- package/bin/shell/vendor/zsh-autosuggestions/zsh-autosuggestions.zsh +867 -0
- package/bin/shell/vendor/zsh-syntax-highlighting/.revision-hash +1 -0
- package/bin/shell/vendor/zsh-syntax-highlighting/.version +1 -0
- package/bin/shell/vendor/zsh-syntax-highlighting/COPYING.md +23 -0
- package/bin/shell/vendor/zsh-syntax-highlighting/highlighters/brackets/brackets-highlighter.zsh +107 -0
- package/bin/shell/vendor/zsh-syntax-highlighting/highlighters/cursor/cursor-highlighter.zsh +47 -0
- package/bin/shell/vendor/zsh-syntax-highlighting/highlighters/line/line-highlighter.zsh +44 -0
- package/bin/shell/vendor/zsh-syntax-highlighting/highlighters/main/main-highlighter.zsh +1853 -0
- package/bin/shell/vendor/zsh-syntax-highlighting/highlighters/pattern/pattern-highlighter.zsh +60 -0
- package/bin/shell/vendor/zsh-syntax-highlighting/highlighters/regexp/regexp-highlighter.zsh +62 -0
- package/bin/shell/vendor/zsh-syntax-highlighting/highlighters/root/root-highlighter.zsh +44 -0
- package/bin/shell/vendor/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh +587 -0
- package/package.json +35 -1
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
function fisher --argument-names cmd --description "A plugin manager for Fish"
|
|
2
|
+
set --query fisher_path || set --local fisher_path $__fish_config_dir
|
|
3
|
+
set --local fisher_version 4.4.8
|
|
4
|
+
set --local fish_plugins $__fish_config_dir/fish_plugins
|
|
5
|
+
|
|
6
|
+
switch "$cmd"
|
|
7
|
+
case -v --version
|
|
8
|
+
echo "fisher, version $fisher_version"
|
|
9
|
+
case "" -h --help
|
|
10
|
+
echo "Usage: fisher install <plugins...> Install plugins"
|
|
11
|
+
echo " fisher remove <plugins...> Remove installed plugins"
|
|
12
|
+
echo " fisher uninstall <plugins...> Remove installed plugins (alias)"
|
|
13
|
+
echo " fisher update <plugins...> Update installed plugins"
|
|
14
|
+
echo " fisher update Update all installed plugins"
|
|
15
|
+
echo " fisher list [<regex>] List installed plugins matching regex"
|
|
16
|
+
echo "Options:"
|
|
17
|
+
echo " -v, --version Print version"
|
|
18
|
+
echo " -h, --help Print this help message"
|
|
19
|
+
echo "Variables:"
|
|
20
|
+
echo " \$fisher_path Plugin installation path. Default: $__fish_config_dir" | string replace --regex -- $HOME \~
|
|
21
|
+
case ls list
|
|
22
|
+
string match --entire --regex -- "$argv[2]" $_fisher_plugins
|
|
23
|
+
case install update remove uninstall
|
|
24
|
+
isatty || read --local --null --array stdin && set --append argv $stdin
|
|
25
|
+
|
|
26
|
+
test "$cmd" = uninstall && set cmd remove
|
|
27
|
+
|
|
28
|
+
set --local install_plugins
|
|
29
|
+
set --local update_plugins
|
|
30
|
+
set --local remove_plugins
|
|
31
|
+
set --local arg_plugins $argv[2..-1]
|
|
32
|
+
set --local old_plugins $_fisher_plugins
|
|
33
|
+
set --local new_plugins
|
|
34
|
+
|
|
35
|
+
test -e $fish_plugins && set --local file_plugins (string match --regex -- '^[^\s]+$' <$fish_plugins | string replace -- \~ ~)
|
|
36
|
+
|
|
37
|
+
if ! set --query argv[2]
|
|
38
|
+
if test "$cmd" != update
|
|
39
|
+
echo "fisher: Not enough arguments for command: \"$cmd\"" >&2 && return 1
|
|
40
|
+
else if ! set --query file_plugins
|
|
41
|
+
echo "fisher: \"$fish_plugins\" file not found: \"$cmd\"" >&2 && return 1
|
|
42
|
+
end
|
|
43
|
+
set arg_plugins $file_plugins
|
|
44
|
+
else if test "$cmd" = install && ! set --query old_plugins[1]
|
|
45
|
+
set --append arg_plugins $file_plugins
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
for plugin in $arg_plugins
|
|
49
|
+
set plugin (test -e "$plugin" && realpath $plugin || string lower -- $plugin)
|
|
50
|
+
contains -- "$plugin" $new_plugins || set --append new_plugins $plugin
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
if set --query argv[2]
|
|
54
|
+
for plugin in $new_plugins
|
|
55
|
+
if contains -- "$plugin" $old_plugins
|
|
56
|
+
test "$cmd" = remove &&
|
|
57
|
+
set --append remove_plugins $plugin ||
|
|
58
|
+
set --append update_plugins $plugin
|
|
59
|
+
else if test "$cmd" = install
|
|
60
|
+
set --append install_plugins $plugin
|
|
61
|
+
else
|
|
62
|
+
echo "fisher: Plugin not installed: \"$plugin\"" >&2 && return 1
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
else
|
|
66
|
+
for plugin in $new_plugins
|
|
67
|
+
contains -- "$plugin" $old_plugins &&
|
|
68
|
+
set --append update_plugins $plugin ||
|
|
69
|
+
set --append install_plugins $plugin
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
for plugin in $old_plugins
|
|
73
|
+
contains -- "$plugin" $new_plugins || set --append remove_plugins $plugin
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
set --local pid_list
|
|
78
|
+
set --local source_plugins
|
|
79
|
+
set --local fetch_plugins $update_plugins $install_plugins
|
|
80
|
+
set --local fish_path (status fish-path)
|
|
81
|
+
|
|
82
|
+
echo (set_color --bold)fisher $cmd version $fisher_version(set_color normal)
|
|
83
|
+
|
|
84
|
+
for plugin in $fetch_plugins
|
|
85
|
+
set --local source (command mktemp -d)
|
|
86
|
+
set --append source_plugins $source
|
|
87
|
+
|
|
88
|
+
command mkdir -p $source/{completions,conf.d,themes,functions}
|
|
89
|
+
|
|
90
|
+
$fish_path --command "
|
|
91
|
+
if test -e $plugin
|
|
92
|
+
command cp -Rf $plugin/* $source
|
|
93
|
+
else
|
|
94
|
+
set resp (command mktemp)
|
|
95
|
+
set temp (command mktemp -d)
|
|
96
|
+
set repo (string split -- \@ $plugin) || set repo[2] HEAD
|
|
97
|
+
|
|
98
|
+
if set path (string replace --regex -- '^(https://)?gitlab.com/' '' \$repo[1])
|
|
99
|
+
set name (string split -- / \$path)[-1]
|
|
100
|
+
set url https://gitlab.com/\$path/-/archive/\$repo[2]/\$name-\$repo[2].tar.gz
|
|
101
|
+
else
|
|
102
|
+
set url https://api.github.com/repos/\$repo[1]/tarball/\$repo[2]
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
echo Fetching (set_color --underline)\$url(set_color normal)
|
|
106
|
+
|
|
107
|
+
set http (command curl -q --silent -L -o \$resp -w %{http_code} \$url)
|
|
108
|
+
|
|
109
|
+
if test \"\$http\" = 200 && command tar -xzC \$temp -f \$resp 2>/dev/null
|
|
110
|
+
command cp -Rf \$temp/*/* $source
|
|
111
|
+
else if test \"\$http\" = 403
|
|
112
|
+
echo fisher: GitHub API rate limit exceeded \(HTTP 403\) >&2
|
|
113
|
+
command rm -rf $source
|
|
114
|
+
else
|
|
115
|
+
echo fisher: Invalid plugin name or host unavailable: \\\"$plugin\\\" >&2
|
|
116
|
+
command rm -rf $source
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
command rm -rf \$temp
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
set files $source/* && string match --quiet --regex -- .+\.fish\\\$ \$files
|
|
123
|
+
" &
|
|
124
|
+
|
|
125
|
+
set --append pid_list (jobs --last --pid)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
wait $pid_list 2>/dev/null
|
|
129
|
+
|
|
130
|
+
for plugin in $fetch_plugins
|
|
131
|
+
if set --local source $source_plugins[(contains --index -- "$plugin" $fetch_plugins)] && test ! -e $source
|
|
132
|
+
if set --local index (contains --index -- "$plugin" $install_plugins)
|
|
133
|
+
set --erase install_plugins[$index]
|
|
134
|
+
else
|
|
135
|
+
set --erase update_plugins[(contains --index -- "$plugin" $update_plugins)]
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
for plugin in $update_plugins $remove_plugins
|
|
141
|
+
if set --local index (contains --index -- "$plugin" $_fisher_plugins)
|
|
142
|
+
set --local plugin_files_var _fisher_(string escape --style=var -- $plugin)_files
|
|
143
|
+
|
|
144
|
+
if contains -- "$plugin" $remove_plugins
|
|
145
|
+
for name in (string replace --filter --regex -- '.+/conf\.d/([^/]+)\.fish$' '$1' $$plugin_files_var)
|
|
146
|
+
emit {$name}_uninstall
|
|
147
|
+
end
|
|
148
|
+
printf "%s\n" Removing\ (set_color red --bold)$plugin(set_color normal) " "$$plugin_files_var | string replace -- \~ ~
|
|
149
|
+
set --erase _fisher_plugins[$index]
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
command rm -rf (string replace -- \~ ~ $$plugin_files_var)
|
|
153
|
+
|
|
154
|
+
functions --erase (string replace --filter --regex -- '.+/functions/([^/]+)\.fish$' '$1' $$plugin_files_var)
|
|
155
|
+
|
|
156
|
+
for name in (string replace --filter --regex -- '.+/completions/([^/]+)\.fish$' '$1' $$plugin_files_var)
|
|
157
|
+
complete --erase --command $name
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
set --erase $plugin_files_var
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
if set --query update_plugins[1] || set --query install_plugins[1]
|
|
165
|
+
command mkdir -p $fisher_path/{functions,themes,conf.d,completions}
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
for plugin in $update_plugins $install_plugins
|
|
169
|
+
set --local source $source_plugins[(contains --index -- "$plugin" $fetch_plugins)]
|
|
170
|
+
set --local files $source/{functions,themes,conf.d,completions}/*
|
|
171
|
+
|
|
172
|
+
if set --local index (contains --index -- $plugin $install_plugins)
|
|
173
|
+
set --local user_files $fisher_path/{functions,themes,conf.d,completions}/*
|
|
174
|
+
set --local conflict_files
|
|
175
|
+
|
|
176
|
+
for file in (string replace -- $source/ $fisher_path/ $files)
|
|
177
|
+
contains -- $file $user_files && set --append conflict_files $file
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
if set --query conflict_files[1] && set --erase install_plugins[$index]
|
|
181
|
+
echo -s "fisher: Cannot install \"$plugin\": please remove or move conflicting files first:" \n" "$conflict_files >&2
|
|
182
|
+
continue
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
for file in (string replace -- $source/ "" $files)
|
|
187
|
+
command cp -RLf $source/$file $fisher_path/$file
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
set --local plugin_files_var _fisher_(string escape --style=var -- $plugin)_files
|
|
191
|
+
|
|
192
|
+
set --query files[1] && set --universal $plugin_files_var (string replace -- $source $fisher_path $files | string replace -- ~ \~)
|
|
193
|
+
|
|
194
|
+
contains -- $plugin $_fisher_plugins || set --universal --append _fisher_plugins $plugin
|
|
195
|
+
contains -- $plugin $install_plugins && set --local event install || set --local event update
|
|
196
|
+
|
|
197
|
+
printf "%s\n" Installing\ (set_color --bold)$plugin(set_color normal) " "$$plugin_files_var | string replace -- \~ ~
|
|
198
|
+
|
|
199
|
+
for file in (string match --regex -- '.+/[^/]+\.fish$' $$plugin_files_var | string replace -- \~ ~)
|
|
200
|
+
source $file
|
|
201
|
+
if set --local name (string replace --regex -- '.+conf\.d/([^/]+)\.fish$' '$1' $file)
|
|
202
|
+
emit {$name}_$event
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
command rm -rf $source_plugins
|
|
208
|
+
|
|
209
|
+
if set --query _fisher_plugins[1]
|
|
210
|
+
set --local commit_plugins
|
|
211
|
+
|
|
212
|
+
for plugin in $file_plugins
|
|
213
|
+
contains -- (string lower -- $plugin) (string lower -- $_fisher_plugins) && set --append commit_plugins $plugin
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
for plugin in $_fisher_plugins
|
|
217
|
+
contains -- (string lower -- $plugin) (string lower -- $commit_plugins) || set --append commit_plugins $plugin
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
string replace --regex -- $HOME \~ $commit_plugins >$fish_plugins
|
|
221
|
+
else
|
|
222
|
+
set --erase _fisher_plugins
|
|
223
|
+
command rm -f $fish_plugins
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
set --local total (count $install_plugins) (count $update_plugins) (count $remove_plugins)
|
|
227
|
+
|
|
228
|
+
test "$total" != "0 0 0" && echo (string join ", " (
|
|
229
|
+
test $total[1] = 0 || echo "Installed $total[1]") (
|
|
230
|
+
test $total[2] = 0 || echo "Updated $total[2]") (
|
|
231
|
+
test $total[3] = 0 || echo "Removed $total[3]")
|
|
232
|
+
) plugin/s
|
|
233
|
+
case \*
|
|
234
|
+
echo "fisher: Unknown command: \"$cmd\"" >&2 && return 1
|
|
235
|
+
end
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
if ! set --query _fisher_upgraded_to_4_4
|
|
239
|
+
set --universal _fisher_upgraded_to_4_4
|
|
240
|
+
if functions --query _fisher_list
|
|
241
|
+
set --query XDG_DATA_HOME[1] || set --local XDG_DATA_HOME ~/.local/share
|
|
242
|
+
command rm -rf $XDG_DATA_HOME/fisher
|
|
243
|
+
functions --erase _fisher_{list,plugin_parse}
|
|
244
|
+
fisher update >/dev/null 2>/dev/null
|
|
245
|
+
else
|
|
246
|
+
for var in (set --names | string match --entire --regex '^_fisher_.+_files$')
|
|
247
|
+
set $var (string replace -- ~ \~ $$var)
|
|
248
|
+
end
|
|
249
|
+
functions --erase _fisher_fish_postexec
|
|
250
|
+
end
|
|
251
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (C) 2016 Jethro Kuan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
if test -z "$Z_DATA"
|
|
2
|
+
if test -z "$XDG_DATA_HOME"
|
|
3
|
+
set -U Z_DATA_DIR "$HOME/.local/share/z"
|
|
4
|
+
else
|
|
5
|
+
set -U Z_DATA_DIR "$XDG_DATA_HOME/z"
|
|
6
|
+
end
|
|
7
|
+
set -U Z_DATA "$Z_DATA_DIR/data"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
if test ! -e "$Z_DATA"
|
|
11
|
+
if test ! -e "$Z_DATA_DIR"
|
|
12
|
+
mkdir -p -m 700 "$Z_DATA_DIR"
|
|
13
|
+
end
|
|
14
|
+
touch "$Z_DATA"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
if test -z "$Z_CMD"
|
|
18
|
+
set -U Z_CMD z
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
set -U ZO_CMD "$Z_CMD"o
|
|
22
|
+
|
|
23
|
+
if test ! -z $Z_CMD
|
|
24
|
+
function $Z_CMD -d "jump around"
|
|
25
|
+
__z $argv
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
if test ! -z $ZO_CMD
|
|
30
|
+
function $ZO_CMD -d "open target dir"
|
|
31
|
+
__z -d $argv
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
if not set -q Z_EXCLUDE
|
|
36
|
+
set -U Z_EXCLUDE "^$HOME\$"
|
|
37
|
+
else if contains $HOME $Z_EXCLUDE
|
|
38
|
+
# Workaround: migrate old default values to a regex (see #90).
|
|
39
|
+
set Z_EXCLUDE (string replace -r -- "^$HOME\$" '^'$HOME'$$' $Z_EXCLUDE)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Setup completions once first
|
|
43
|
+
__z_complete
|
|
44
|
+
|
|
45
|
+
function __z_on_variable_pwd --on-variable PWD
|
|
46
|
+
__z_add
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
function __z_uninstall --on-event z_uninstall
|
|
50
|
+
functions -e __z_on_variable_pwd
|
|
51
|
+
functions -e $Z_CMD
|
|
52
|
+
functions -e $ZO_CMD
|
|
53
|
+
|
|
54
|
+
if test ! -z "$Z_DATA"
|
|
55
|
+
printf "To completely erase z's data, remove:\n" >/dev/stderr
|
|
56
|
+
printf "%s\n" "$Z_DATA" >/dev/stderr
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
set -e Z_CMD
|
|
60
|
+
set -e ZO_CMD
|
|
61
|
+
set -e Z_DATA
|
|
62
|
+
set -e Z_EXCLUDE
|
|
63
|
+
end
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
function __z -d "Jump to a recent directory."
|
|
2
|
+
function __print_help -d "Print z help."
|
|
3
|
+
printf "Usage: $Z_CMD [-celrth] string1 string2...\n\n"
|
|
4
|
+
printf " -c --clean Removes directories that no longer exist from $Z_DATA\n"
|
|
5
|
+
printf " -d --dir Opens matching directory using system file manager.\n"
|
|
6
|
+
printf " -e --echo Prints best match, no cd\n"
|
|
7
|
+
printf " -l --list List matches and scores, no cd\n"
|
|
8
|
+
printf " -p --purge Delete all entries from $Z_DATA\n"
|
|
9
|
+
printf " -r --rank Search by rank\n"
|
|
10
|
+
printf " -t --recent Search by recency\n"
|
|
11
|
+
printf " -x --delete Removes the current directory from $Z_DATA\n"
|
|
12
|
+
printf " -h --help Print this help\n\n"
|
|
13
|
+
end
|
|
14
|
+
function __z_legacy_escape_regex
|
|
15
|
+
# taken from escape_string_pcre2 in fish
|
|
16
|
+
# used to provide compatibility with fish 2
|
|
17
|
+
for c in (string split -- '' $argv)
|
|
18
|
+
if contains $c (string split '' '.^$*+()?[{}\\|-]')
|
|
19
|
+
printf \\
|
|
20
|
+
end
|
|
21
|
+
printf '%s' $c
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
set -l options h/help c/clean e/echo l/list p/purge r/rank t/recent d/directory x/delete
|
|
26
|
+
|
|
27
|
+
argparse $options -- $argv
|
|
28
|
+
|
|
29
|
+
if set -q _flag_help
|
|
30
|
+
__print_help
|
|
31
|
+
return 0
|
|
32
|
+
else if set -q _flag_clean
|
|
33
|
+
__z_clean
|
|
34
|
+
printf "%s cleaned!\n" $Z_DATA
|
|
35
|
+
return 0
|
|
36
|
+
else if set -q _flag_purge
|
|
37
|
+
echo >$Z_DATA
|
|
38
|
+
printf "%s purged!\n" $Z_DATA
|
|
39
|
+
return 0
|
|
40
|
+
else if set -q _flag_delete
|
|
41
|
+
sed -i -e "\:^$PWD|.*:d" $Z_DATA
|
|
42
|
+
return 0
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
set -l typ
|
|
46
|
+
|
|
47
|
+
if set -q _flag_rank
|
|
48
|
+
set typ rank
|
|
49
|
+
else if set -q _flag_recent
|
|
50
|
+
set typ recent
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
set -l z_script '
|
|
54
|
+
function frecent(rank, time) {
|
|
55
|
+
dx = t-time
|
|
56
|
+
if( dx < 3600 ) return rank*4
|
|
57
|
+
if( dx < 86400 ) return rank*2
|
|
58
|
+
if( dx < 604800 ) return rank/2
|
|
59
|
+
return rank/4
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function output(matches, best_match, common) {
|
|
63
|
+
# list or return the desired directory
|
|
64
|
+
if( list ) {
|
|
65
|
+
cmd = "sort -nr"
|
|
66
|
+
for( x in matches ) {
|
|
67
|
+
if( matches[x] ) {
|
|
68
|
+
printf "%-10s %s\n", matches[x], x | cmd
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
} else {
|
|
72
|
+
if( common ) best_match = common
|
|
73
|
+
print best_match
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function common(matches) {
|
|
78
|
+
# find the common root of a list of matches, if it exists
|
|
79
|
+
for( x in matches ) {
|
|
80
|
+
if( matches[x] && (!short || length(x) < length(short)) ) {
|
|
81
|
+
short = x
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if( short == "/" ) return
|
|
85
|
+
for( x in matches ) if( matches[x] && index(x, short) != 1 ) {
|
|
86
|
+
return
|
|
87
|
+
}
|
|
88
|
+
return short
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
BEGIN {
|
|
92
|
+
hi_rank = ihi_rank = -9999999999
|
|
93
|
+
}
|
|
94
|
+
{
|
|
95
|
+
if( typ == "rank" ) {
|
|
96
|
+
rank = $2
|
|
97
|
+
} else if( typ == "recent" ) {
|
|
98
|
+
rank = $3 - t
|
|
99
|
+
} else rank = frecent($2, $3)
|
|
100
|
+
if( $1 ~ q ) {
|
|
101
|
+
matches[$1] = rank
|
|
102
|
+
} else if( tolower($1) ~ tolower(q) ) imatches[$1] = rank
|
|
103
|
+
if( matches[$1] && matches[$1] > hi_rank ) {
|
|
104
|
+
best_match = $1
|
|
105
|
+
hi_rank = matches[$1]
|
|
106
|
+
} else if( imatches[$1] && imatches[$1] > ihi_rank ) {
|
|
107
|
+
ibest_match = $1
|
|
108
|
+
ihi_rank = imatches[$1]
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
END {
|
|
113
|
+
# prefer case sensitive
|
|
114
|
+
if( best_match ) {
|
|
115
|
+
output(matches, best_match, common(matches))
|
|
116
|
+
} else if( ibest_match ) {
|
|
117
|
+
output(imatches, ibest_match, common(imatches))
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
'
|
|
121
|
+
|
|
122
|
+
set -l qs
|
|
123
|
+
for arg in $argv
|
|
124
|
+
set -l escaped $arg
|
|
125
|
+
if string escape --style=regex '' >/dev/null 2>&1 # use builtin escape if available
|
|
126
|
+
set escaped (string escape --style=regex -- $escaped)
|
|
127
|
+
else
|
|
128
|
+
set escaped (__z_legacy_escape_regex $escaped)
|
|
129
|
+
end
|
|
130
|
+
# Need to escape twice, see https://www.math.utah.edu/docs/info/gawk_5.html#SEC32
|
|
131
|
+
set escaped (string replace --all -- \\ \\\\ $escaped)
|
|
132
|
+
set qs $qs $escaped
|
|
133
|
+
end
|
|
134
|
+
set -l q (string join -- '.*' $qs)
|
|
135
|
+
|
|
136
|
+
if set -q _flag_list
|
|
137
|
+
# Handle list separately as it can print common path information to stderr
|
|
138
|
+
# which cannot be captured from a subcommand.
|
|
139
|
+
command awk -v t=(date +%s) -v list="list" -v typ="$typ" -v q="$q" -F "|" $z_script "$Z_DATA"
|
|
140
|
+
return
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
if set -q q[1]
|
|
144
|
+
set target (command awk -v t=(date +%s) -v typ="$typ" -v q="$q" -F "|" $z_script "$Z_DATA")
|
|
145
|
+
else
|
|
146
|
+
set target $HOME
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
if test "$status" -gt 0
|
|
150
|
+
return
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
if test -z "$target"
|
|
154
|
+
printf "'%s' did not match any results\n" "$argv"
|
|
155
|
+
return 1
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
if set -q _flag_echo
|
|
159
|
+
printf "%s\n" "$target"
|
|
160
|
+
else if set -q _flag_directory
|
|
161
|
+
if test -n "$ZO_METHOD"
|
|
162
|
+
type -q "$ZO_METHOD"; and "$ZO_METHOD" "$target"; and return $status
|
|
163
|
+
echo "Cannot open with ZO_METHOD set to $ZO_METHOD"; and return 1
|
|
164
|
+
else if test "$OS" = Windows_NT
|
|
165
|
+
# Be careful, in msys2, explorer always return 1
|
|
166
|
+
type -q explorer; and explorer "$target"
|
|
167
|
+
return 0
|
|
168
|
+
echo "Cannot open file explorer"
|
|
169
|
+
return 1
|
|
170
|
+
else
|
|
171
|
+
type -q xdg-open; and xdg-open "$target"; and return $status
|
|
172
|
+
type -q open; and open "$target"; and return $status
|
|
173
|
+
echo "Not sure how to open file manager"; and return 1
|
|
174
|
+
end
|
|
175
|
+
else
|
|
176
|
+
cd "$target"
|
|
177
|
+
end
|
|
178
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
function __z_add -d "Add PATH to .z file"
|
|
2
|
+
test -n "$fish_private_mode"; and return 0
|
|
3
|
+
|
|
4
|
+
for i in $Z_EXCLUDE
|
|
5
|
+
if string match -r $i $PWD >/dev/null
|
|
6
|
+
return 0 #Path excluded
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
set -l tmpfile (mktemp $Z_DATA.XXXXXX)
|
|
11
|
+
|
|
12
|
+
if test -f $tmpfile
|
|
13
|
+
set -l path (string replace --all \\ \\\\ $PWD)
|
|
14
|
+
command awk -v path=$path -v now=(date +%s) -F "|" '
|
|
15
|
+
BEGIN {
|
|
16
|
+
rank[path] = 1
|
|
17
|
+
time[path] = now
|
|
18
|
+
}
|
|
19
|
+
$2 >= 1 {
|
|
20
|
+
if( $1 == path ) {
|
|
21
|
+
rank[$1] = $2 + 1
|
|
22
|
+
time[$1] = now
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
rank[$1] = $2
|
|
26
|
+
time[$1] = $3
|
|
27
|
+
}
|
|
28
|
+
count += $2
|
|
29
|
+
}
|
|
30
|
+
END {
|
|
31
|
+
if( count > 1000 ) {
|
|
32
|
+
for( i in rank ) print i "|" 0.9*rank[i] "|" time[i] # aging
|
|
33
|
+
}
|
|
34
|
+
else for( i in rank ) print i "|" rank[i] "|" time[i]
|
|
35
|
+
}
|
|
36
|
+
' $Z_DATA 2>/dev/null >$tmpfile
|
|
37
|
+
|
|
38
|
+
if test ! -z "$Z_OWNER"
|
|
39
|
+
chown $Z_OWNER:(id -ng $Z_OWNER) $tmpfile
|
|
40
|
+
end
|
|
41
|
+
#
|
|
42
|
+
# Don't use redirection here as it can lead to a race condition where $Z_DATA is clobbered.
|
|
43
|
+
# Note: There is a still a possible race condition where an old version of $Z_DATA is
|
|
44
|
+
# read by one instance of Fish before another instance of Fish writes its copy.
|
|
45
|
+
#
|
|
46
|
+
command mv $tmpfile $Z_DATA
|
|
47
|
+
or command rm $tmpfile
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
function __z_clean -d "Clean up .z file to remove paths no longer valid"
|
|
2
|
+
set -l tmpfile (mktemp $Z_DATA.XXXXXX)
|
|
3
|
+
|
|
4
|
+
if test -f $tmpfile
|
|
5
|
+
while read line
|
|
6
|
+
set -l path (string split '|' $line)[1]
|
|
7
|
+
test -d $path; and echo $line
|
|
8
|
+
end <$Z_DATA >$tmpfile
|
|
9
|
+
command mv -f $tmpfile $Z_DATA
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
function __z_complete -d "add completions"
|
|
2
|
+
complete -c $Z_CMD -a "(__z -l | string replace -r '^\\S*\\s*' '')" -f -k
|
|
3
|
+
complete -c $ZO_CMD -a "(__z -l | string replace -r '^\\S*\\s*' '')" -f -k
|
|
4
|
+
|
|
5
|
+
complete -c $Z_CMD -s c -l clean -d "Cleans out $Z_DATA"
|
|
6
|
+
complete -c $Z_CMD -s e -l echo -d "Prints best match, no cd"
|
|
7
|
+
complete -c $Z_CMD -s l -l list -d "List matches, no cd"
|
|
8
|
+
complete -c $Z_CMD -s p -l purge -d "Purges $Z_DATA"
|
|
9
|
+
complete -c $Z_CMD -s r -l rank -d "Searches by rank, cd"
|
|
10
|
+
complete -c $Z_CMD -s t -l recent -d "Searches by recency, cd"
|
|
11
|
+
complete -c $Z_CMD -s h -l help -d "Print help"
|
|
12
|
+
complete -c $Z_CMD -s x -l delete -d "Removes the current directory from $Z_DATA"
|
|
13
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Copyright (c) 2013 Thiago de Arruda
|
|
2
|
+
Copyright (c) 2016-2021 Eric Freese
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person
|
|
5
|
+
obtaining a copy of this software and associated documentation
|
|
6
|
+
files (the "Software"), to deal in the Software without
|
|
7
|
+
restriction, including without limitation the rights to use,
|
|
8
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the
|
|
10
|
+
Software is furnished to do so, subject to the following
|
|
11
|
+
conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
18
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
20
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
21
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
22
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
23
|
+
OTHER DEALINGS IN THE SOFTWARE.
|