+25
README.md
+25
README.md
···
···
1
+
# My dotfiles
2
+
3
+
## Installation
4
+
5
+
```bash
6
+
git clone 'https://github.com/boltlessengineer/dotfiles.git'
7
+
8
+
cd dotfiles
9
+
10
+
# install neovim config
11
+
ln -s ./nvim ~/.config/nvim
12
+
13
+
# install fish config
14
+
ln -s ./fish ~/.config/fish
15
+
16
+
# install lf config
17
+
ln -s ./lf ~/.config/lf
18
+
```
19
+
20
+
### install fish
21
+
```bash
22
+
brew install fish
23
+
fish
24
+
fisher update
25
+
```
+25
bat/config
+25
bat/config
···
···
1
+
# This is `bat`s configuration file. Each line either contains a comment or
2
+
# a command-line option that you want to pass to `bat` by default. You can
3
+
# run `bat --help` to get a list of all possible configuration options.
4
+
5
+
# Specify desired highlighting theme (e.g. "TwoDark"). Run `bat --list-themes`
6
+
# for a list of all available themes
7
+
--theme="TwoDark"
8
+
9
+
# Enable this to use italic text on the terminal. This is not supported on all
10
+
# terminal emulators (like tmux, by default):
11
+
#--italic-text=always
12
+
13
+
# Uncomment the following line to disable automatic paging:
14
+
#--paging=never
15
+
16
+
# Uncomment the following line if you are using less version >= 551 and want to
17
+
# enable mouse scrolling support in `bat` when running inside tmux. This might
18
+
# disable text selection, unless you press shift.
19
+
#--pager="less --RAW-CONTROL-CHARS --quit-if-one-screen --mouse"
20
+
21
+
# Syntax mappings: map a certain filename pattern to a language.
22
+
# Example 1: use the C++ syntax for Arduino .ino files
23
+
# Example 2: Use ".gitignore"-style highlighting for ".ignore" files
24
+
--map-syntax "*.ino:C++"
25
+
#--map-syntax ".ignore:Git Ignore"
+7
fish/completions/fisher.fish
+7
fish/completions/fisher.fish
···
···
1
+
complete --command fisher --exclusive --long help --description "Print help"
2
+
complete --command fisher --exclusive --long version --description "Print version"
3
+
complete --command fisher --exclusive --condition __fish_use_subcommand --arguments install --description "Install plugins"
4
+
complete --command fisher --exclusive --condition __fish_use_subcommand --arguments update --description "Update installed plugins"
5
+
complete --command fisher --exclusive --condition __fish_use_subcommand --arguments remove --description "Remove installed plugins"
6
+
complete --command fisher --exclusive --condition __fish_use_subcommand --arguments list --description "List installed plugins matching regex"
7
+
complete --command fisher --exclusive --condition "__fish_seen_subcommand_from update remove" --arguments "(fisher list)"
+19
fish/completions/nvm.fish
+19
fish/completions/nvm.fish
···
···
1
+
complete --command nvm --exclusive --long version --description "Print version"
2
+
complete --command nvm --exclusive --long help --description "Print help"
3
+
4
+
complete --command nvm --exclusive --condition __fish_use_subcommand --arguments install --description "Download and activate the specified Node version"
5
+
complete --command nvm --exclusive --condition __fish_use_subcommand --arguments use --description "Activate a version in the current shell"
6
+
complete --command nvm --exclusive --condition __fish_use_subcommand --arguments list --description "List installed versions"
7
+
complete --command nvm --exclusive --condition __fish_use_subcommand --arguments list-remote --description "List versions available to install matching optional regex"
8
+
complete --command nvm --exclusive --condition __fish_use_subcommand --arguments current --description "Print the currently-active version"
9
+
complete --command nvm --exclusive --condition "__fish_seen_subcommand_from install" --arguments "(
10
+
test -e $nvm_data && string split ' ' <$nvm_data/.index
11
+
)"
12
+
complete --command nvm --exclusive --condition "__fish_seen_subcommand_from use" --arguments "(_nvm_list | string split ' ')"
13
+
complete --command nvm --exclusive --condition __fish_use_subcommand --arguments uninstall --description "Uninstall a version"
14
+
complete --command nvm --exclusive --condition "__fish_seen_subcommand_from uninstall" --arguments "(
15
+
_nvm_list | string split ' ' | string replace system ''
16
+
)"
17
+
complete --command nvm --exclusive --condition "__fish_seen_subcommand_from use uninstall" --arguments "(
18
+
set --query nvm_default_version && echo default
19
+
)"
+28
fish/conf.d/nvm.fish
+28
fish/conf.d/nvm.fish
···
···
1
+
function _nvm_install --on-event nvm_install
2
+
set --query XDG_DATA_HOME || set --local XDG_DATA_HOME ~/.local/share
3
+
set --universal nvm_data $XDG_DATA_HOME/nvm
4
+
set --query nvm_mirror || set --universal nvm_mirror https://nodejs.org/dist
5
+
6
+
test ! -d $nvm_data && command mkdir -p $nvm_data
7
+
echo "Downloading the Node distribution index..." 2>/dev/null
8
+
_nvm_index_update $nvm_mirror $nvm_data/.index
9
+
end
10
+
11
+
function _nvm_update --on-event nvm_update
12
+
set --query XDG_DATA_HOME || set --local XDG_DATA_HOME ~/.local/share
13
+
set --universal nvm_data $XDG_DATA_HOME/nvm
14
+
set --query nvm_mirror || set --universal nvm_mirror https://nodejs.org/dist
15
+
end
16
+
17
+
function _nvm_uninstall --on-event nvm_uninstall
18
+
command rm -rf $nvm_data
19
+
20
+
set --query nvm_current_version && _nvm_version_deactivate $nvm_current_version
21
+
22
+
set --names | string replace --filter --regex -- "^nvm" "set --erase nvm" | source
23
+
functions --erase (functions --all | string match --entire --regex -- "^_nvm_")
24
+
end
25
+
26
+
if status is-interactive && set --query nvm_default_version && ! set --query nvm_current_version
27
+
nvm use $nvm_default_version >/dev/null
28
+
end
+23
fish/config.fish
+23
fish/config.fish
···
···
1
+
if status is-interactive
2
+
# Commands to run in interactive sessions can go here
3
+
starship init fish | source
4
+
zoxide init fish | source
5
+
6
+
# Aliases
7
+
alias ls="exa"
8
+
alias lt="exa -T"
9
+
alias lT="exa -Tlh --no-user --no-time"
10
+
alias ll="exa -lh --no-user"
11
+
alias la="exa -lha --git --no-user"
12
+
13
+
# Global Variables
14
+
15
+
# Languages
16
+
## Go
17
+
set -x GOROOT "$(brew --prefix golang)/libexec"
18
+
set -x GOPATH $HOME/go
19
+
set -x PATH $PATH $GOROOT/bin $GOPATH/bin
20
+
21
+
## Flutter
22
+
set -x PATH $PATH "/opt/homebrew/Caskroom/flutter/2.10.4/flutter/bin"
23
+
end
+37
fish/fish_variables
+37
fish/fish_variables
···
···
1
+
# This file contains fish universal variable definitions.
2
+
# VERSION: 3.0
3
+
SETUVAR __fish_initialized:3400
4
+
SETUVAR _fisher_jorgebucaran_2F_fisher_files:/Users/boltless/\x2econfig/fish/functions/fisher\x2efish\x1e/Users/boltless/\x2econfig/fish/completions/fisher\x2efish
5
+
SETUVAR _fisher_jorgebucaran_2F_nvm_2E_fish_files:/Users/boltless/\x2econfig/fish/functions/_nvm_index_update\x2efish\x1e/Users/boltless/\x2econfig/fish/functions/_nvm_list\x2efish\x1e/Users/boltless/\x2econfig/fish/functions/_nvm_version_activate\x2efish\x1e/Users/boltless/\x2econfig/fish/functions/_nvm_version_deactivate\x2efish\x1e/Users/boltless/\x2econfig/fish/functions/nvm\x2efish\x1e/Users/boltless/\x2econfig/fish/conf\x2ed/nvm\x2efish\x1e/Users/boltless/\x2econfig/fish/completions/nvm\x2efish
6
+
SETUVAR _fisher_plugins:jorgebucaran/fisher\x1ejorgebucaran/nvm\x2efish
7
+
SETUVAR fish_color_autosuggestion:555\x1ebrblack
8
+
SETUVAR fish_color_cancel:\x2dr
9
+
SETUVAR fish_color_command:blue
10
+
SETUVAR fish_color_comment:red
11
+
SETUVAR fish_color_cwd:green
12
+
SETUVAR fish_color_cwd_root:red
13
+
SETUVAR fish_color_end:green
14
+
SETUVAR fish_color_error:brred
15
+
SETUVAR fish_color_escape:brcyan
16
+
SETUVAR fish_color_history_current:\x2d\x2dbold
17
+
SETUVAR fish_color_host:normal
18
+
SETUVAR fish_color_host_remote:yellow
19
+
SETUVAR fish_color_normal:normal
20
+
SETUVAR fish_color_operator:brcyan
21
+
SETUVAR fish_color_param:cyan
22
+
SETUVAR fish_color_quote:yellow
23
+
SETUVAR fish_color_redirection:cyan\x1e\x2d\x2dbold
24
+
SETUVAR fish_color_search_match:\x2d\x2dbackground\x3d111
25
+
SETUVAR fish_color_selection:white\x1e\x2d\x2dbold\x1e\x2d\x2dbackground\x3dbrblack
26
+
SETUVAR fish_color_status:red
27
+
SETUVAR fish_color_user:brgreen
28
+
SETUVAR fish_color_valid_path:\x2d\x2dunderline
29
+
SETUVAR fish_key_bindings:fish_default_key_bindings
30
+
SETUVAR fish_pager_color_completion:normal
31
+
SETUVAR fish_pager_color_description:B3A06D\x1eyellow\x1e\x2di
32
+
SETUVAR fish_pager_color_prefix:cyan\x1e\x2d\x2dbold\x1e\x2d\x2dunderline
33
+
SETUVAR fish_pager_color_progress:brwhite\x1e\x2d\x2dbackground\x3dcyan
34
+
SETUVAR fish_pager_color_selected_background:\x2dr
35
+
SETUVAR fish_user_paths:/opt/homebrew/bin
36
+
SETUVAR nvm_data:/Users/boltless/\x2elocal/share/nvm
37
+
SETUVAR nvm_mirror:https\x3a//nodejs\x2eorg/dist
+16
fish/functions/_nvm_index_update.fish
+16
fish/functions/_nvm_index_update.fish
···
···
1
+
function _nvm_index_update --argument-names mirror index
2
+
if not command curl --location --silent $mirror/index.tab >$index.temp
3
+
command rm -f $index.temp
4
+
echo "nvm: Can't update index, host unavailable: \"$mirror\"" >&2
5
+
return 1
6
+
end
7
+
8
+
command awk -v OFS=\t '
9
+
/v0.9.12/ { exit } # Unsupported
10
+
NR > 1 {
11
+
print $1 (NR == 2 ? " latest" : $10 != "-" ? " lts/" tolower($10) : "")
12
+
}
13
+
' $index.temp >$index
14
+
15
+
command rm -f $index.temp
16
+
end
+11
fish/functions/_nvm_list.fish
+11
fish/functions/_nvm_list.fish
···
···
1
+
function _nvm_list
2
+
set --local versions $nvm_data/*
3
+
set --query versions[1] &&
4
+
string match --entire --regex -- (string match --regex -- "v\d.+" $versions |
5
+
string escape --style=regex |
6
+
string join "|"
7
+
) <$nvm_data/.index
8
+
9
+
command --all node |
10
+
string match --quiet --invert --regex -- "^$nvm_data" && echo system
11
+
end
+4
fish/functions/_nvm_version_activate.fish
+4
fish/functions/_nvm_version_activate.fish
+5
fish/functions/_nvm_version_deactivate.fish
+5
fish/functions/_nvm_version_deactivate.fish
+212
fish/functions/fisher.fish
+212
fish/functions/fisher.fish
···
···
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.3.1
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 update <plugins...> Update installed plugins"
13
+
echo " fisher update Update all installed plugins"
14
+
echo " fisher list [<regex>] List installed plugins matching regex"
15
+
echo "Options:"
16
+
echo " -v or --version Print version"
17
+
echo " -h or --help Print this help message"
18
+
echo "Variables:"
19
+
echo " \$fisher_path Plugin installation path. Default: ~/.config/fish"
20
+
case ls list
21
+
string match --entire --regex -- "$argv[2]" $_fisher_plugins
22
+
case install update remove
23
+
isatty || read --local --null --array stdin && set --append argv $stdin
24
+
25
+
set --local install_plugins
26
+
set --local update_plugins
27
+
set --local remove_plugins
28
+
set --local arg_plugins $argv[2..-1]
29
+
set --local old_plugins $_fisher_plugins
30
+
set --local new_plugins
31
+
32
+
if ! set --query argv[2]
33
+
if test "$cmd" != update
34
+
echo "fisher: Not enough arguments for command: \"$cmd\"" >&2 && return 1
35
+
else if test ! -e $fish_plugins
36
+
echo "fisher: \"$fish_plugins\" file not found: \"$cmd\"" >&2 && return 1
37
+
end
38
+
set arg_plugins (string match --regex -- '^[^\s]+$' <$fish_plugins)
39
+
end
40
+
41
+
for plugin in $arg_plugins
42
+
test -e "$plugin" && set plugin (realpath $plugin)
43
+
contains -- "$plugin" $new_plugins || set --append new_plugins $plugin
44
+
end
45
+
46
+
if set --query argv[2]
47
+
for plugin in $new_plugins
48
+
if contains -- "$plugin" $old_plugins
49
+
test "$cmd" = remove &&
50
+
set --append remove_plugins $plugin ||
51
+
set --append update_plugins $plugin
52
+
else if test "$cmd" = install
53
+
set --append install_plugins $plugin
54
+
else
55
+
echo "fisher: Plugin not installed: \"$plugin\"" >&2 && return 1
56
+
end
57
+
end
58
+
else
59
+
for plugin in $new_plugins
60
+
contains -- "$plugin" $old_plugins &&
61
+
set --append update_plugins $plugin ||
62
+
set --append install_plugins $plugin
63
+
end
64
+
65
+
for plugin in $old_plugins
66
+
contains -- "$plugin" $new_plugins || set --append remove_plugins $plugin
67
+
end
68
+
end
69
+
70
+
set --local pid_list
71
+
set --local source_plugins
72
+
set --local fetch_plugins $update_plugins $install_plugins
73
+
echo (set_color --bold)fisher $cmd version $fisher_version(set_color normal)
74
+
75
+
for plugin in $fetch_plugins
76
+
set --local source (command mktemp -d)
77
+
set --append source_plugins $source
78
+
79
+
command mkdir -p $source/{completions,conf.d,functions}
80
+
81
+
fish --command "
82
+
if test -e $plugin
83
+
command cp -Rf $plugin/* $source
84
+
else
85
+
set temp (command mktemp -d)
86
+
set name (string split \@ $plugin) || set name[2] HEAD
87
+
set url https://api.github.com/repos/\$name[1]/tarball/\$name[2]
88
+
set header 'Accept: application/vnd.github.v3+json'
89
+
90
+
echo Fetching (set_color --underline)\$url(set_color normal)
91
+
92
+
if curl --silent -L -H \$header \$url | tar -xzC \$temp -f - 2>/dev/null
93
+
command cp -Rf \$temp/*/* $source
94
+
else
95
+
echo fisher: Invalid plugin name or host unavailable: \\\"$plugin\\\" >&2
96
+
command rm -rf $source
97
+
end
98
+
command rm -rf \$temp
99
+
end
100
+
101
+
set files $source/* && string match --quiet --regex -- .+\.fish\\\$ \$files
102
+
" &
103
+
104
+
set --append pid_list (jobs --last --pid)
105
+
end
106
+
107
+
wait $pid_list 2>/dev/null
108
+
109
+
for plugin in $fetch_plugins
110
+
if set --local source $source_plugins[(contains --index -- "$plugin" $fetch_plugins)] && test ! -e $source
111
+
if set --local index (contains --index -- "$plugin" $install_plugins)
112
+
set --erase install_plugins[$index]
113
+
else
114
+
set --erase update_plugins[(contains --index -- "$plugin" $update_plugins)]
115
+
end
116
+
end
117
+
end
118
+
119
+
for plugin in $update_plugins $remove_plugins
120
+
if set --local index (contains --index -- "$plugin" $_fisher_plugins)
121
+
set --local plugin_files_var _fisher_(string escape --style=var -- $plugin)_files
122
+
123
+
if contains -- "$plugin" $remove_plugins
124
+
for name in (string replace --filter --regex -- '.+/conf\.d/([^/]+)\.fish$' '$1' $$plugin_files_var)
125
+
emit {$name}_uninstall
126
+
end
127
+
printf "%s\n" Removing\ (set_color red --bold)$plugin(set_color normal) " "$$plugin_files_var
128
+
end
129
+
130
+
command rm -rf $$plugin_files_var
131
+
functions --erase (string replace --filter --regex -- '.+/functions/([^/]+)\.fish$' '$1' $$plugin_files_var)
132
+
133
+
for name in (string replace --filter --regex -- '.+/completions/([^/]+)\.fish$' '$1' $$plugin_files_var)
134
+
complete --erase --command $name
135
+
end
136
+
137
+
set --erase _fisher_plugins[$index]
138
+
set --erase $plugin_files_var
139
+
end
140
+
end
141
+
142
+
if set --query update_plugins[1] || set --query install_plugins[1]
143
+
command mkdir -p $fisher_path/{functions,conf.d,completions}
144
+
end
145
+
146
+
for plugin in $update_plugins $install_plugins
147
+
set --local source $source_plugins[(contains --index -- "$plugin" $fetch_plugins)]
148
+
set --local files $source/{functions,conf.d,completions}/*
149
+
150
+
if set --local index (contains --index -- $plugin $install_plugins)
151
+
set --local user_files $fisher_path/{functions,conf.d,completions}/*
152
+
set --local conflict_files
153
+
154
+
for file in (string replace -- $source/ $fisher_path/ $files)
155
+
contains -- $file $user_files && set --append conflict_files $file
156
+
end
157
+
158
+
if set --query conflict_files[1] && set --erase install_plugins[$index]
159
+
echo -s "fisher: Cannot install \"$plugin\": please remove or move conflicting files first:" \n" "$conflict_files >&2
160
+
continue
161
+
end
162
+
end
163
+
164
+
for file in (string replace -- $source/ "" $files)
165
+
command cp -Rf $source/$file $fisher_path/$file
166
+
end
167
+
168
+
set --local plugin_files_var _fisher_(string escape --style=var -- $plugin)_files
169
+
set --query files[1] && set --universal $plugin_files_var (string replace -- $source $fisher_path $files)
170
+
171
+
contains -- $plugin $_fisher_plugins || set --universal --append _fisher_plugins $plugin
172
+
contains -- $plugin $install_plugins && set --local event install || set --local event update
173
+
174
+
printf "%s\n" Installing\ (set_color --bold)$plugin(set_color normal) " "$$plugin_files_var
175
+
176
+
for file in (string match --regex -- '.+/[^/]+\.fish$' $$plugin_files_var)
177
+
source $file
178
+
if set --local name (string replace --regex -- '.+conf\.d/([^/]+)\.fish$' '$1' $file)
179
+
emit {$name}_$event
180
+
end
181
+
end
182
+
end
183
+
184
+
command rm -rf $source_plugins
185
+
186
+
set --query _fisher_plugins[1] || set --erase _fisher_plugins
187
+
set --query _fisher_plugins &&
188
+
printf "%s\n" $_fisher_plugins >$fish_plugins ||
189
+
command rm -f $fish_plugins
190
+
191
+
set --local total (count $install_plugins) (count $update_plugins) (count $remove_plugins)
192
+
test "$total" != "0 0 0" && echo (string join ", " (
193
+
test $total[1] = 0 || echo "Installed $total[1]") (
194
+
test $total[2] = 0 || echo "Updated $total[2]") (
195
+
test $total[3] = 0 || echo "Removed $total[3]")
196
+
) plugin/s
197
+
case \*
198
+
echo "fisher: Unknown command: \"$cmd\"" >&2 && return 1
199
+
end
200
+
end
201
+
202
+
## Migrations ##
203
+
function _fisher_fish_postexec --on-event fish_postexec
204
+
if functions --query _fisher_list
205
+
fisher update >/dev/null 2>/dev/null
206
+
set --query XDG_DATA_HOME || set --local XDG_DATA_HOME ~/.local/share
207
+
test -e $XDG_DATA_HOME/fisher && command rm -rf $XDG_DATA_HOME/fisher
208
+
functions --erase _fisher_list _fisher_plugin_parse
209
+
set --erase fisher_data
210
+
end
211
+
functions --erase _fisher_fish_postexec
212
+
end
+208
fish/functions/nvm.fish
+208
fish/functions/nvm.fish
···
···
1
+
function nvm --argument-names cmd v --description "Node version manager"
2
+
if test -z "$v" && contains -- "$cmd" install use
3
+
for file in .nvmrc .node-version
4
+
set file (_nvm_find_up $PWD $file) && read v <$file && break
5
+
end
6
+
if test -z "$v"
7
+
echo "nvm: Invalid version or missing \".nvmrc\" file" >&2
8
+
return 1
9
+
end
10
+
end
11
+
12
+
set --local their_version $v
13
+
14
+
switch "$cmd"
15
+
case -v --version
16
+
echo "nvm, version 2.2.7"
17
+
case "" -h --help
18
+
echo "Usage: nvm install <version> Download and activate the specified Node version"
19
+
echo " nvm install Install version from nearest .nvmrc file"
20
+
echo " nvm use <version> Activate a version in the current shell"
21
+
echo " nvm use Activate version from nearest .nvmrc file"
22
+
echo " nvm list List installed versions"
23
+
echo " nvm list-remote List versions available to install"
24
+
echo " nvm list-remote <regex> List versions matching a given regular expression"
25
+
echo " nvm current Print the currently-active version"
26
+
echo " nvm uninstall <version> Uninstall a version"
27
+
echo "Options:"
28
+
echo " -v or --version Print version"
29
+
echo " -h or --help Print this help message"
30
+
echo "Variables:"
31
+
echo " nvm_arch Override architecture, e.g. x64-musl"
32
+
echo " nvm_mirror Set the Node download mirror"
33
+
echo " nvm_default_version Set the default version for new shells"
34
+
case install
35
+
_nvm_index_update $nvm_mirror $nvm_data/.index || return
36
+
37
+
string match --entire --regex -- (_nvm_version_match $v) <$nvm_data/.index | read v alias
38
+
39
+
if ! set --query v[1]
40
+
echo "nvm: Invalid version number or alias: \"$their_version\"" >&2
41
+
return 1
42
+
end
43
+
44
+
if test ! -e $nvm_data/$v
45
+
set --local os (command uname -s | string lower)
46
+
set --local ext tar.gz
47
+
set --local arch (command uname -m)
48
+
49
+
switch $os
50
+
case aix
51
+
set arch ppc64
52
+
case sunos
53
+
case linux
54
+
case darwin
55
+
case {MSYS_NT,MINGW\*_NT}\*
56
+
set os win
57
+
set ext zip
58
+
case \*
59
+
echo "nvm: Unsupported operating system: \"$os\"" >&2
60
+
return 1
61
+
end
62
+
63
+
switch $arch
64
+
case i\*86
65
+
set arch x86
66
+
case x86_64
67
+
set arch x64
68
+
case arm64
69
+
string match --regex --quiet "v(?<major>\d+)" $v
70
+
if test "$os" = darwin -a $major -lt 16
71
+
set arch x64
72
+
end
73
+
case armv6 armv6l
74
+
set arch armv6l
75
+
case armv7 armv7l
76
+
set arch armv7l
77
+
case armv8 armv8l aarch64
78
+
set arch arm64
79
+
end
80
+
81
+
set --query nvm_arch && set arch $nvm_arch
82
+
83
+
set --local dir "node-$v-$os-$arch"
84
+
set --local url $nvm_mirror/$v/$dir.$ext
85
+
86
+
command mkdir -p $nvm_data/$v
87
+
88
+
echo -e "Installing Node \x1b[1m$v\x1b[22m $alias"
89
+
echo -e "Fetching \x1b[4m$url\x1b[24m\x1b[7m"
90
+
91
+
if ! command curl --progress-bar --location $url \
92
+
| command tar --extract --gzip --directory $nvm_data/$v 2>/dev/null
93
+
command rm -rf $nvm_data/$v
94
+
echo -e "\033[F\33[2K\x1b[0mnvm: Invalid mirror or host unavailable: \"$url\"" >&2
95
+
return 1
96
+
end
97
+
98
+
echo -en "\033[F\33[2K\x1b[0m"
99
+
100
+
if test "$os" = win
101
+
command mv $nvm_data/$v/$dir $nvm_data/$v/bin
102
+
else
103
+
command mv $nvm_data/$v/$dir/* $nvm_data/$v
104
+
command rm -rf $nvm_data/$v/$dir
105
+
end
106
+
end
107
+
108
+
if test $v != "$nvm_current_version"
109
+
set --query nvm_current_version && _nvm_version_deactivate $nvm_current_version
110
+
_nvm_version_activate $v
111
+
end
112
+
113
+
printf "Now using Node %s (npm %s) %s\n" (_nvm_node_info)
114
+
case use
115
+
test $v = default && set v $nvm_default_version
116
+
_nvm_list | string match --entire --regex -- (_nvm_version_match $v) | read v __
117
+
118
+
if ! set --query v[1]
119
+
echo "nvm: Can't use Node \"$their_version\", version must be installed first" >&2
120
+
return 1
121
+
end
122
+
123
+
if test $v != "$nvm_current_version"
124
+
set --query nvm_current_version && _nvm_version_deactivate $nvm_current_version
125
+
test $v != system && _nvm_version_activate $v
126
+
end
127
+
128
+
printf "Now using Node %s (npm %s) %s\n" (_nvm_node_info)
129
+
case uninstall
130
+
if test -z "$v"
131
+
echo "nvm: Not enough arguments for command: \"$cmd\"" >&2
132
+
return 1
133
+
end
134
+
135
+
test $v = default && test ! -z "$nvm_default_version" && set v $nvm_default_version
136
+
137
+
_nvm_list | string match --entire --regex -- (_nvm_version_match $v) | read v __
138
+
139
+
if ! set -q v[1]
140
+
echo "nvm: Node version not installed or invalid: \"$their_version\"" >&2
141
+
return 1
142
+
end
143
+
144
+
printf "Uninstalling Node %s %s\n" $v (string replace ~ \~ "$nvm_data/$v/bin/node")
145
+
146
+
_nvm_version_deactivate $v
147
+
148
+
command rm -rf $nvm_data/$v
149
+
case current
150
+
_nvm_current
151
+
case ls list
152
+
_nvm_list | _nvm_list_format (_nvm_current) $argv[2]
153
+
case lsr {ls,list}-remote
154
+
_nvm_index_update $nvm_mirror $nvm_data/.index || return
155
+
_nvm_list | command awk '
156
+
FILENAME == "-" && (is_local[$1] = FNR == NR) { next } {
157
+
print $0 (is_local[$1] ? " ✓" : "")
158
+
}
159
+
' - $nvm_data/.index | _nvm_list_format (_nvm_current) $argv[2]
160
+
case \*
161
+
echo "nvm: Unknown command or option: \"$cmd\" (see nvm -h)" >&2
162
+
return 1
163
+
end
164
+
end
165
+
166
+
function _nvm_find_up --argument-names path file
167
+
test -e "$path/$file" && echo $path/$file || begin
168
+
test "$path" != / || return
169
+
_nvm_find_up (command dirname $path) $file
170
+
end
171
+
end
172
+
173
+
function _nvm_version_match --argument-names v
174
+
string replace --regex -- '^v?(\d+|\d+\.\d+)$' 'v$1.' $v |
175
+
string replace --filter --regex -- '^v?(\d+)' 'v$1' |
176
+
string escape --style=regex ||
177
+
string lower '\b'$v'(?:/\w+)?$'
178
+
end
179
+
180
+
function _nvm_list_format --argument-names current regex
181
+
command awk -v current="$current" -v regex="$regex" '
182
+
$0 ~ regex {
183
+
aliases[versions[i++] = $1] = $2 " " $3
184
+
pad = (n = length($1)) > pad ? n : pad
185
+
}
186
+
END {
187
+
if (!i) exit 1
188
+
while (i--)
189
+
printf((current == versions[i] ? " ▶ " : " ") "%"pad"s %s\n",
190
+
versions[i], aliases[versions[i]])
191
+
}
192
+
'
193
+
end
194
+
195
+
function _nvm_current
196
+
command --search --quiet node || return
197
+
set --query nvm_current_version && echo $nvm_current_version || echo system
198
+
end
199
+
200
+
function _nvm_node_info
201
+
set --local npm_path (string replace bin/npm-cli.js "" (realpath (command --search npm)))
202
+
test -f $npm_path/package.json || set --local npm_version_default (command npm --version)
203
+
command node --eval "
204
+
console.log(process.version)
205
+
console.log('$npm_version_default' ? '$npm_version_default': require('$npm_path/package.json').version)
206
+
console.log(process.execPath.replace(require('os').homedir(), '~'))
207
+
"
208
+
end
+103
lf/lfrc
+103
lf/lfrc
···
···
1
+
# interpreter for shell commands
2
+
set shell sh
3
+
4
+
# set '-eu' options for shell commands
5
+
# These options are used to have safer shell commands. Option '-e' is used to
6
+
# exit on error and option '-u' is used to give error for unset variables.
7
+
# Option '-f' disables pathname expansion which can be useful when $f, $fs, and
8
+
# $fx variables contain names with '*' or '?' characters. However, this option
9
+
# is used selectively within individual commands as it can be limiting at
10
+
# times.
11
+
set shellopts '-eu'
12
+
13
+
# set internal field separator (IFS) to "\n" for shell commands
14
+
# This is useful to automatically split file names in $fs and $fx properly
15
+
# since default file separator used in these variables (i.e. 'filesep' option)
16
+
# is newline. You need to consider the values of these options and create your
17
+
# commands accordingly.
18
+
set ifs "\n"
19
+
20
+
# leave some space at the top and the bottom of the screen
21
+
set scrolloff 10
22
+
23
+
# == previewer ==
24
+
set previewer ~/.config/lf/previewer.sh
25
+
26
+
# use enter for shell commands
27
+
map <enter> shell
28
+
29
+
# execute current file (must be executable)
30
+
map x $$f
31
+
map X !$f
32
+
33
+
# dedicated keys for file opener actions
34
+
map o &mimeopen $f
35
+
map O $mimeopen --ask $f
36
+
37
+
# define a custom 'open' command
38
+
# This command is called when current file is not a directory. You may want to
39
+
# use either file extensions and/or mime types here. Below uses an editor for
40
+
# text files and a file opener for the rest.
41
+
cmd open ${{
42
+
test -L $f && f=$(readlink -f $f)
43
+
case $(file --mime-type $f -b) in
44
+
text/*) $EDITOR $fx;;
45
+
*) for f in $fx; do setsid $OPENER $f > /dev/null 2> /dev/null & done;;
46
+
esac
47
+
}}
48
+
49
+
# define a custom 'rename' command without prompt for overwrite
50
+
# cmd rename %[ -e $1 ] && printf "file exists" || mv $f $1
51
+
# map r push :rename<space>
52
+
53
+
# make sure trash folder exists
54
+
# %mkdir -p ~/.trash
55
+
56
+
# move current file or selected files to trash folder
57
+
# (also see 'man mv' for backup/overwrite options)
58
+
cmd trash %set -f; mv $fx ~/.trash
59
+
60
+
# define a custom 'delete' command
61
+
# cmd delete ${{
62
+
# set -f
63
+
# printf "$fx\n"
64
+
# printf "delete?[y/n]"
65
+
# read ans
66
+
# [ "$ans" = "y" ] && rm -rf $fx
67
+
# }}
68
+
69
+
# use '<delete>' key for either 'trash' or 'delete' command
70
+
# map <delete> trash
71
+
# map <delete> delete
72
+
73
+
# extract the current file with the right command
74
+
# (xkcd link: https://xkcd.com/1168/)
75
+
cmd extract ${{
76
+
set -f
77
+
case $f in
78
+
*.tar.bz|*.tar.bz2|*.tbz|*.tbz2) tar xjvf $f;;
79
+
*.tar.gz|*.tgz) tar xzvf $f;;
80
+
*.tar.xz|*.txz) tar xJvf $f;;
81
+
*.zip) unzip $f;;
82
+
*.rar) unrar x $f;;
83
+
*.7z) 7z x $f;;
84
+
esac
85
+
}}
86
+
87
+
# compress current file or selected files with tar and gunzip
88
+
cmd tar ${{
89
+
set -f
90
+
mkdir $1
91
+
cp -r $fx $1
92
+
tar czf $1.tar.gz $1
93
+
rm -rf $1
94
+
}}
95
+
96
+
# compress current file or selected files with zip
97
+
cmd zip ${{
98
+
set -f
99
+
mkdir $1
100
+
cp -r $fx $1
101
+
zip -r $1.zip $1
102
+
rm -rf $1
103
+
}}
+9
lf/previewer.sh
+9
lf/previewer.sh
···
···
1
+
#!/bin/sh
2
+
3
+
# check here : https://www.youtube.com/watch?v=50BMBT05Wk0
4
+
5
+
case ${1##*.} in
6
+
7z|zip) 7z l -p -- "$1" && exit 1;;
7
+
jpeg|jpg|png|gif) chafa --clear --animate=off --symbols space -s "$2x$3" "$1" && exit 1;;
8
+
*) bat --style=plain --color=always "$1" || cat "$1" && exit 1;;
9
+
esac