Skip to content

Instantly share code, notes, and snippets.

@wences-dc-uba-ar
Last active August 20, 2025 10:55
Show Gist options
  • Save wences-dc-uba-ar/b1ca9f0caefe7163b46ed7e9e3cdbc5f to your computer and use it in GitHub Desktop.
Save wences-dc-uba-ar/b1ca9f0caefe7163b46ed7e9e3cdbc5f to your computer and use it in GitHub Desktop.
fish+powerline
#!/bin/env bash
set -o errexit -o pipefail -o noclobber -o nounset
# set -x
sudo apt install fish powerline
sudo chsh --shell $(which fish)
FISH_CONFIG_FILE=~/.config/fish/config.fish
if [ ! -f "$FISH_CONFIG_FILE" ]; then
echo "Fish config file not found: $FISH_CONFIG_FILE"
exit 1
fi
POWERLINE_FISH_BINDING_DIR='/usr/share/powerline/bindings/fish'
if [ ! -d "$POWERLINE_FISH_BINDING_DIR" ]; then
echo "Powerline Fish bindings directory not found: $POWERLINE_FISH_BINDING_DIR"
exit 1
fi
if grep -q "powerline-setup" "$FISH_CONFIG_FILE"; then
echo "Powerline already setup"
exit 0
fi
REFERENCE_LINE='# Commands to run in interactive sessions can go here'
# assert that the file has the reference line
if ! grep -q "$REFERENCE_LINE" "$FISH_CONFIG_FILE"; then
echo "Reference line not found in $FISH_CONFIG_FILE"
exit 1
fi
POWERLINE_CONFIG_LINES="\n\tset fish_function_path \$fish_function_path $POWERLINE_FISH_BINDING_DIR\n\tsource $POWERLINE_FISH_BINDING_DIR/powerline-setup.fish\n\tpowerline-setup"
sed -i "s|$REFERENCE_LINE|$REFERENCE_LINE$POWERLINE_CONFIG_LINES|" $FISH_CONFIG_FILE
echo "Powerline setup added"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment