diff options
| author | Pavel Egorov <[email protected]> | 2026-01-10 04:10:43 +0300 |
|---|---|---|
| committer | Pavel Egorov <[email protected]> | 2026-01-10 04:12:31 +0300 |
| commit | 1ecc23f36620e625430e37bc12874d9a5e07c711 (patch) | |
| tree | d3cb937d05f373f74e8a4c866db9d06c2277530f /.config/fish | |
| parent | 7444ed1b1d64825aa4e7eeed12c97e8bb9dfdef2 (diff) | |
| download | dotfiles-1ecc23f36620e625430e37bc12874d9a5e07c711.tar.gz dotfiles-1ecc23f36620e625430e37bc12874d9a5e07c711.zip | |
[fish] add install_scripts function
Diffstat (limited to '.config/fish')
| -rw-r--r-- | .config/fish/functions/install_scripts.fish | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/.config/fish/functions/install_scripts.fish b/.config/fish/functions/install_scripts.fish new file mode 100644 index 0000000..541b5bd --- /dev/null +++ b/.config/fish/functions/install_scripts.fish | |||
| @@ -0,0 +1,31 @@ | |||
| 1 | #!/usr/bin/env fish | ||
| 2 | |||
| 3 | function prepare_directories | ||
| 4 | if not test -d "$LOCAL_BIN" | ||
| 5 | mkdir "$LOCAL_BIN" | ||
| 6 | end | ||
| 7 | |||
| 8 | if not test -d "$LOCAL_SCRIPTS" | ||
| 9 | echo "$LOCAL_SCRIPTS not found" | ||
| 10 | return 1 | ||
| 11 | end | ||
| 12 | end | ||
| 13 | |||
| 14 | function install_scripts | ||
| 15 | prepare_directories | ||
| 16 | |||
| 17 | for script in "$LOCAL_SCRIPTS"/* | ||
| 18 | if string match -q "#!*" (head -n1 "$script") | ||
| 19 | string match -rq '^(?<filename>.*)(?<ext>\.[^.]*)$' (basename "$script") | ||
| 20 | set symlink "$LOCAL_BIN/$filename" | ||
| 21 | |||
| 22 | if test -L "$symlink" | ||
| 23 | echo "$filename" already exists | ||
| 24 | continue | ||
| 25 | end | ||
| 26 | |||
| 27 | ln -s "$script" "$symlink" | ||
| 28 | echo "$filename symlinked" | ||
| 29 | end | ||
| 30 | end | ||
| 31 | end | ||
