Skip to content

Commit

Permalink
Powerline-Shell: use pipx, install globally, and bookworm compat
Browse files Browse the repository at this point in the history
work towards #2401
  • Loading branch information
theofficialgman committed Jul 29, 2023
1 parent 2d46e6c commit d9ae70a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
23 changes: 18 additions & 5 deletions apps/Powerline-Shell/install
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,24 @@

install_packages python3 python3-pip python3-dev fonts-powerline fonts-fantasque-sans || exit 1

sudo pip3 install powerline-shell || error "Failed to install powerline shell with pip3"
if package_available pipx ;then
install_packages pipx python3-venv || exit 1
elif package_available python3.8 ;then
install_packages python3.8 python3.8-venv || exit 1
sudo -H python3.8 -m pip install pipx || exit 1
else
error "pipx is not available so cannot install powerline-shell to python venv"
fi

#Remove new powerline ~/.bashrc function if already there
sed -i '/powerline-shell/d' ~/.bashrc
sudo PIPX_HOME=/usr/local/pipx PIPX_BIN_DIR=/usr/local/bin pipx install powerline-shell || error "Failed to install powerline shell with pipx"

#Add powerline to ~/.bashrc
echo 'if [ $TERM != linux ] && [[ ! $PROMPT_COMMAND =~ "powerline-shell" ]]; then PROMPT_COMMAND="PS1="\"""\$"(powerline-shell)"\""; $PROMPT_COMMAND" ; fi' >> ~/.bashrc
#Remove powerline-shell function from ~/.bashrc if already there
sed -i '/powerline-shell/d' ~/.bashrc
# Remove powerline-shell function from /etc/bash.bashrc if already there
sudo sed -i '/powerline-shell/d' /etc/bash.bashrc

#Add powerline to /etc/bash.bashrc
echo 'if [ $TERM != linux ] && [[ ! $PROMPT_COMMAND =~ "powerline-shell" ]]; then PROMPT_COMMAND="PS1="\"""\$"(powerline-shell)"\""; $PROMPT_COMMAND" ; fi' | sudo tee -a /etc/bash.bashrc > /dev/null || error "Could not modify /etc/bash.bashrc"
#Also add to users ~/.bashrc . Some terminals (eg: gnome-terminal) overwrite the PROMPT_COMMAND with their own contents after /etc/bash.bashrc so is necessary for them
#The following will only affect the current users install
echo 'if [ $TERM != linux ] && [[ ! $PROMPT_COMMAND =~ "powerline-shell" ]]; then PROMPT_COMMAND="PS1="\"""\$"(powerline-shell)"\""; $PROMPT_COMMAND" ; fi' | tee -a ~/.bashrc > /dev/null || error "Could not modify ~/.bashrc"
6 changes: 5 additions & 1 deletion apps/Powerline-Shell/uninstall
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/bin/bash

# note: do not check exit code from pipx since exit code is set to 1 if not already installed
sudo PIPX_HOME=/usr/local/pipx PIPX_BIN_DIR=/usr/local/bin pipx uninstall powerline-shell
purge_packages || exit 1
sudo pip3 uninstall -y powerline-shell

#Remove powerline-shell function from ~/.bashrc if already there
sed -i '/powerline-shell/d' ~/.bashrc
# Remove powerline-shell function from /etc/bash.bashrc if already there
sudo sed -i '/powerline-shell/d' /etc/bash.bashrc

0 comments on commit d9ae70a

Please sign in to comment.