[bugfix] sourcing script will break variables

This commit is contained in:
Klesh Wong 2020-11-23 15:54:48 +08:00
parent 181ff8c759
commit a63bfa014d
8 changed files with 46 additions and 24 deletions

View File

@ -5,7 +5,7 @@ DIR=$(dirname "$(readlink -f "$0")")
. "$DIR/../env.sh" . "$DIR/../env.sh"
if ! has_cmd python if ! has_cmd python
. "$PDIR/devel/python.sh" "$PDIR/devel/python.sh"
fi fi
log 'Setting up ranger' log 'Setting up ranger'

View File

@ -9,32 +9,35 @@ log 'Setting up vim'
# check dependencies # check dependencies
if [ "$VIM_MODE" = "enhanced" ]; then if [ "$VIM_MODE" = "enhanced" ]; then
if ! has_cmd node; then if ! has_cmd node; then
. "$PDIR/devel/nodejs.sh" "$PDIR/devel/nodejs.sh"
fi fi
if ! has_cmd python; then if ! has_cmd python; then
. "$PDIR/devel/python.sh" "$PDIR/devel/python.sh"
fi fi
fi fi
# install nvim # install nvim
case "$PM" in if ! has_cmd "$VIM"; then
case "$PM" in
apt) apt)
sudo add-apt-repository ppa:neovim-ppa/stable -y sudo add-apt-repository ppa:neovim-ppa/stable -y
sudo apt update sudo apt update
sudo apt install -y neovim sudo apt install -y neovim
if [ "$VIM_MODE" = "enhanced" ]; then if enhance_vim; then
sudo pip3 install pyvim neovim sudo pip3 install pyvim neovim
fi fi
;; ;;
pacman) pacman)
sudo pacman -S --noconfirm --needed neovim sudo pacman -S --noconfirm --needed neovim
if [ "$VIM_MODE" = "enhanced" ]; then if enhance_vim; then
sudo pip install pyvim neovim sudo pip install pyvim neovim
fi fi
;; ;;
esac esac
fi
# symlink configuration # symlink configuration
sudo ln -sf "$(command -v nvim)" /usr/bin/v
lnsf "$DIR/vim/init.vim" "$XDG_CONFIG_HOME/nvim/init.vim" lnsf "$DIR/vim/init.vim" "$XDG_CONFIG_HOME/nvim/init.vim"
lnsf "$DIR/vim/coc-settings.json" "$XDG_CONFIG_HOME/nvim/coc-settings.json" lnsf "$DIR/vim/coc-settings.json" "$XDG_CONFIG_HOME/nvim/coc-settings.json"
lnsf "$DIR/vim/coc-settings.json" "$HOME/.vim/coc-settings.json" lnsf "$DIR/vim/coc-settings.json" "$HOME/.vim/coc-settings.json"

View File

@ -15,9 +15,12 @@ case "$PM" in
esac esac
# live server for html previewing # live server for html previewing
. "$PDIR/devel/nodejs.sh" "$PDIR/devel/nodejs.sh"
sudo $NPM_BIN install -g live-server if in_china; then
sudo cnpm install -g live-server
else
sudo npm install -g live-server
fi
# convert to html with embeded <style>: cmark-gfm input.md --to html --unsafe > /path/to/output.html # convert to html with embeded <style>: cmark-gfm input.md --to html --unsafe > /path/to/output.html
# entr watch input.md and rerun convert command # entr watch input.md and rerun convert command
# live-server to observe html file and reload browser # live-server to observe html file and reload browser

View File

@ -11,7 +11,7 @@ case "$PM" in
sudo snap remove --purge docker sudo snap remove --purge docker
sudo apt install -y docker.io sudo apt install -y docker.io
if ! has_cmd python; then if ! has_cmd python; then
. "$PDIR/python/install.sh" "$PDIR/python/install.sh"
fi fi
sudo pip3 install docker-compose sudo pip3 install docker-compose
;; ;;

View File

@ -22,6 +22,9 @@ lspkgs() {
| jq '.[] | "\(.version) \(if .lts then "(lts)" else "" end)"' -r | jq '.[] | "\(.version) \(if .lts then "(lts)" else "" end)"' -r
} }
cocsetup() {
}
uninstall() { uninstall() {
if [ -f "$FILES_PATH" ]; then if [ -f "$FILES_PATH" ]; then
tac "$FILES_PATH" | grep -v '/$' | xargs sudo rm -f tac "$FILES_PATH" | grep -v '/$' | xargs sudo rm -f
@ -63,6 +66,9 @@ install() {
if in_china; then if in_china; then
sudo npm install -g cnpm --registry=https://registry.npm.taobao.org sudo npm install -g cnpm --registry=https://registry.npm.taobao.org
fi fi
if enhance_vim; then
v -c "CocInstall -sync coc-json coc-vetur coc-tsserver coc-eslint|qall"
fi
} }

View File

@ -39,3 +39,9 @@ if has_cmd fish; then
source $HOME/.cargo/env source $HOME/.cargo/env
" | sed 's/^ *//' > "$XDG_CONFIG_HOME/fish/conf.d/cargo.fish" " | sed 's/^ *//' > "$XDG_CONFIG_HOME/fish/conf.d/cargo.fish"
fi fi
# coc.nvim
if enhance_vim; then
rustup component add rls rust-analysis rust-src
v -c "CocInstall -sync coc-rls|qall"
fi

4
env.sh
View File

@ -80,6 +80,10 @@ has_fish() {
has_cmd "$1" has_cmd "$1"
} }
enhance_vim() {
[ "$VIM_MODE" = "enhanced" ] && has_cmd nvim
}
sudo mkdir -p $PREFIX sudo mkdir -p $PREFIX

View File

@ -5,7 +5,7 @@ DIR=$(dirname "$(readlink -f "$0")")
. "$DIR/../env.sh" . "$DIR/../env.sh"
if ! has_cmd python; then if ! has_cmd python; then
. "$PDIR/python/install.sh" "$PDIR/python/install.sh"
fi fi
log 'Setting up picom' log 'Setting up picom'