-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_once_install_powerline.sh.tmpl
executable file
·37 lines (33 loc) · 1.65 KB
/
run_once_install_powerline.sh.tmpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env bash
USE_PIPX=0
{{ if .myubuntu }}
sudo apt install powerline powerline-gitstatus python3-powerline
{{ else if .myfedora }}
sudo dnf install python3-pip powerline tmux-powerline vim-powerline
python3 -m pip install --user powerline-gitstatus
{{ else }}
USE_PIPX=1
# Install pipx if we don't have it already
command -v pipx > /dev/null || python3 -m pip install --user pipx
pipx install powerline-status
pipx inject powerline-status powerline-gitstatus
{{ end }}
if [[ "$USE_PIPX" == "0" ]]; then
POWERLINE_LOCATION=$(python3 -m pip show powerline-status 2>/dev/null | grep "Location:" | cut -f2 -d" ")
else
PIPX_LOCAL_VENVS=$(pipx environment --value PIPX_LOCAL_VENVS)
PIPX_PYTHON_VERSION=$(pipx list | grep -E "powerline-status.*Python" | awk '{print $NF}')
PIPX_PYTHON_VERSION_MAJOR_MINOR=$(echo $PIPX_PYTHON_VERSION | cut -d'.' -f1,2)
POWERLINE_LOCATION=${PIPX_LOCAL_VENVS}/powerline-status/lib/python${PIPX_PYTHON_VERSION_MAJOR_MINOR}/site-packages
fi
POWERLINE_BASH_BINDINGS_PATH=$POWERLINE_LOCATION/powerline/bindings/bash/
echo "export POWERLINE_LOCATION=$POWERLINE_LOCATION" > ~/.powerline_location
echo "export POWERLINE_BASH_BINDINGS_PATH=$POWERLINE_BASH_BINDINGS_PATH" >> ~/.powerline_location
{{ if not (or .myubuntu .myfedora) }}
# Test if PROMPT_COMMAND is readonly
PROMPT_COMMAND_READ_ONLY=$(readonly -p | egrep "declare -[[:lower:]]+ PROMPT_COMMAND=" 1> /dev/null; echo $?)
if [[ $PROMPT_COMMAND_READ_ONLY -eq 0 ]]; then
cp $POWERLINE_BASH_BINDINGS_PATH/powerline.sh $POWERLINE_BASH_BINDINGS_PATH/powerline-user.sh
sed -i 's/PROMPT_COMMAND/USER_PROMPT_COMMAND/g' $POWERLINE_BASH_BINDINGS_PATH/powerline-user.sh
fi
{{ end }}