From f62a712b3fc224097f930dbbc1c764ef35ee4f31 Mon Sep 17 00:00:00 2001 From: Wouter Gordts Date: Thu, 29 Sep 2022 18:03:07 +0200 Subject: [PATCH] xonsh cleanup --- bootstrap.sh | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/bootstrap.sh b/bootstrap.sh index 4a11e93..2fd480f 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -3,7 +3,7 @@ NAME="waldek" EMAIL="waldek@mailbox.org" DEFAULT_SHELL="xonsh" -DEPENDENCIES_APT="zsh git tig tmux vim-nox htop python3 python3-pip python3-venv npm" +DEPENDENCIES_APT="zsh git tig tmux vim-nox htop python3 python3-pip python3-venv" DEPENDENCIES_PIP="xonsh[full] xontrib-sh" SOURCES_DIR=~/sources/gitea_irisib @@ -15,6 +15,7 @@ GITEA_HTTPS="https://gitea.86thumbs.net" GITEA_SSH="ssh://gitea@86thumbs.net:3022" GITEA_CLONE=$GITEA_HTTPS +XONSH_VENV="~/.virtualenvs/base" LOG=/dev/null if [[ -z $(groups | grep sudo) ]]; then @@ -131,9 +132,9 @@ function symlink_config_files () { } function install_pip_dependencies () { - mkdir -p ~/virtual_envs - python3 -m venv ~/virtual_envs/base - source ~/virtual_envs/base/bin/activate + mkdir -p $XONSH_VENV + python3 -m venv $XONSH_VENV + source $XONSH_VENV/bin/activate for dep in $DEPENDENCIES_PIP; do pip3 install --upgrade "$dep" > $LOG && echo "installed $dep" done @@ -141,15 +142,13 @@ function install_pip_dependencies () { } function change_shell () { - local path=$(which xonsh) - echo $path - path=~/virtual_envs/base/bin/xonsh - if ! [[ -z $path ]]; then - if [[ -z "$(grep xonsh /etc/shells)" ]]; then - echo "$path" | sudo tee -a /etc/shells - fi - sudo chsh -s $path $USER && echo "set $1 as shell for $USER" + if [[ "$1" == "xonsh" ]]; then + path=$XONSH_VENV/bin/xonsh + elif [[ -z "$(grep $1 /etc/shells)" ]]; then + echo "$1 not a valid shell, falling back to $(which bash)" + path=$(which bash) fi + sudo chsh -s $path $USER && echo "set $1 as shell for $USER" echo "--- ${FUNCNAME[0]} done" }