Installing and Switching Shells

· 1 min read · 113 Words · -Views -Comments

While adding shell hooks to a web shell project, I hit a few quirks. Here’s a cheat sheet for installing various shells and switching between them, using Ubuntu as the example OS.

Bash

chsh -s $(which bash)
# Version
bash --version

Zsh

sudo apt install zsh
chsh -s $(which zsh)
# Version
zsh --version

Fish

sudo apt install fish
sudo chsh -s $(which fish)

Tcsh

sudo apt install tcsh
chsh -s $(which tcsh)

Notable Differences

  1. In Bash and Zsh, printf "PreExecMarker;$1"; doesn’t escape arguments, so placeholders like date +%Y can trigger errors. Fish and Tcsh automatically escape arguments and avoid the issue.

    https://static.1991421.cn/2023/2023-10-31-195452.jpeg

    Fix it by specifying the format explicitly:

    printf "PreExecMarker;%s" "date +%Y"
    

    https://static.1991421.cn/2023/2023-10-31-195625.jpeg

Authors
Developer, digital product enthusiast, tinkerer, sharer, open source lover