40 lines
783 B
Fish
Executable file
40 lines
783 B
Fish
Executable file
#!/usr/bin/env fish
|
|
|
|
has_command fzf || begin
|
|
echo "fzf not installed"
|
|
exit 1
|
|
end
|
|
|
|
mkdir -p $ENV_PATH
|
|
|
|
function filter_existing_directory
|
|
while read -l l
|
|
test -d $DOTFILES_PATH/$l && echo $l
|
|
end
|
|
end
|
|
|
|
function reject_empty_lines
|
|
while read -l l
|
|
test $l = "" || echo $l
|
|
end
|
|
end
|
|
|
|
function link
|
|
while read -l l
|
|
set safe_fn (string replace -a / - $l)
|
|
echo "Linking $ENV_PATH/$safe_fn to $DOTFILES_PATH/$l"
|
|
rm -f $ENV_PATH/$safe_fn
|
|
ln -s $DOTFILES_PATH/$l $ENV_PATH/$safe_fn
|
|
end
|
|
end
|
|
|
|
cat $DOTFILES_PATH/common/envs |
|
|
filter_existing_directory |
|
|
fzf --multi \
|
|
--prompt "Select applicable environments (multi-select w/ TAB): " \
|
|
--preview-window="up:50%:noborder" \
|
|
--preview="ls -la --color=always $DOTFILES_PATH/{}" |
|
|
string trim |
|
|
reject_empty_lines |
|
|
link
|