addpath file and put it in setup-fish

This commit is contained in:
Hedy Li 2021-08-17 16:59:54 +08:00
parent 27ce78fd93
commit c692a1ba7c
Signed by: hedy
GPG Key ID: B51B5A8D1B176372
3 changed files with 41 additions and 9 deletions

6
.addpath Normal file
View File

@ -0,0 +1,6 @@
bin
local/bin
.local/bin
.doomemacs/bin
go/bin
/usr/local/go/bin

View File

@ -1,21 +1,34 @@
#!/usr/bin/env bash
setpaths() {
fish -c 'set -Ux fish_user_paths $fish_user_paths '"$(parse_addpath)"
}
if ! command -v fish &> /dev/null; then
echo "I'm sorry but I can't help you install fish"
echo "Please install fish before running this script lol"
exit 1
fi
echo -n "Setting up fish_user_paths..."
cat <<END | fish
set -Ux fish_user_paths /home/hedy/bin /home/hedy/local/bin /home/hedy/.local/bin /home/hedy/go/bin $fish_user_paths
END
echo "Setting up fish_user_paths..."
setpaths ~/.addpath
echo "done"
if [ -f ~/.addpath_local ]; then
echo "Adding paths in ~/.addpath_local..."
setpaths ~/.addpath_local
echo "done"
fi
echo Maybe add ~/local/share/man to manpath but I forgot how as of writing
echo
echo "Installing oh my fish"
curl -L https://get.oh-my.fish | fish
echo "Installing oh my fish packages"
omf install
# TODO have a better check for omf existence (command -v doesnt work)
# Although omf does this same check lol
if [ ! -d ~/.local/share/omf ]; then
echo "Installing oh my fish"
curl -L https://get.oh-my.fish | fish
# TODO: check for omf packages too
echo "Installing oh my fish packages"
omf install
echo done
fi

13
bin/parse_addpath Executable file
View File

@ -0,0 +1,13 @@
#!/usr/bin/env bash
# read addpath file and return each path
file="${1:-$HOME/.addpath}"
while read line; do
# If the path doesn't begin with / then assume it is relative to $HOME
# Who cares if this is bashism
if [[ ! "$line" == /* ]]; then
line=$HOME/$line
fi
echo -n "$line "
done < "$file"