André Jacobs' Z shell configuration.
Once you have tried Zsh you will never go back to bash.
To see what is possible with Zsh take a look at oh my zsh
I wanted to have my own minimalist custom configuration for Zsh and not be overloaded with bigger packages like oh my zsh.
- Two-line command prompt with the first line used for displaying info.
- Shows the current directory and a 24 hour clock at the time the prompt is displayed.
- Displays the current
git
branch and a status indicator:- ★ shows that you have commits to be made.
- ⬆ shows that you have changes to be pushed upstream.
- ⬇ shows that there are changes to be pulled from upstream.
- ⬇⬆ your branch is diverging from upstream and will need to be resolved.
- Displays the exit code from the last executed command if an error occurred.
- Username and hostname are only displayed when you are in an SSH session.
The following steps can be done if you have already installed Zsh. See the next section if you need help to install Zsh.
-
Launch Zsh:
zsh
-
Clone this repository or download a copy:
git clone --recursive https://github.com/andrejacobs/ajzsh.git ajzsh
-
Run the installation script:
cd ajzsh ./install.sh
-
Relaunch your terminal.
- Confirm current version of Zsh:
zsh --version
- Expected result:
zsh 5.2
or more recent. - Install Zsh using either
brew install zsh
with homebrew on macOS orsudo apt-get install zsh
on Ubuntu. - Get the path to the binary using
which zsh
- Using homebrew on macOS will give you
/usr/local/bin/zsh
- Using homebrew on macOS will give you
- Add the path to the file /etc/shells
- Change your default shell to be Zsh
- On macOS:
sudo dscl . -create /Users/$USER UserShell /usr/local/bin/zsh
- On Linux:
sudo chsh -s "$(command -v zsh)" "${USER}"
- On macOS:
- Relaunch your terminal and verify that
echo $SHELL
points to the correct path to the Zsh binary.
This is based on the work of ze-best-zsh-config
Other inspirations were:
This have only been tested on macOS Sierra. I will be using this on Ubuntu shortly and I am sure to run into many joys of fixing bugs :-)
If you get the following (as I get on macOS 10.11)
zsh compinit: insecure directories, run compaudit for list.
Ignore insecure directories and continue [y] or abort compinit [n]?
Choose n and run compaudit to get the list of directories
$ compaudit
There are insecure directories:
/usr/local/share/zsh/site-functions
/usr/local/share/zsh
Change permissions
$ cd /usr/local/share/
$ sudo chmod -R 755 zsh
$ sudo chown -R root:staff zsh
Relaunch terminal
- Add some aliasses for git
- Add some macOS specifics (like aliases for working with finder)
- Fix the completion bug (because of 2line prompt [i.e. type l and tab])
- Check file permissions are correct