Archive for the ‘zsh’ Category
Add zsh to Fedora
One of my students requested an option to the bash
shell. It was interesting to hear that he wanted me to instal the zsh
in my Fedora image. There’s only one book that I’m aware of that’s been published on the Z Shell, and it is From Bash to Z Shell.
This post shows how to add the zsh
to my Fedora image because I already release a new one for the term without the zsh
shell. You use the yum
utility as the root
user to install the zsh
library:
yum install -y zsh |
It should produce an output stream like the following, which required accessing the alternate mirror site:
Loaded plugins: langpacks, refresh-packagekit mysql-connectors-community | 2.5 kB 00:00 mysql-tools-community | 2.5 kB 00:00 mysql56-community | 2.5 kB 00:00 pgdg93 | 3.6 kB 00:00 updates/20/x86_64/metalink | 14 kB 00:00 updates | 4.9 kB 00:00 (1/3): mysql-connectors-community/20/x86_64/primary_db | 8.8 kB 00:00 (2/3): pgdg93/20/x86_64/primary_db | 83 kB 00:01 (3/3): updates/20/x86_64/primary_db | 13 MB 00:13 updates/20/x86_64/pkgtags FAILED http://mirror.utexas.edu/fedora/linux/updates/20/x86_64/repodata/1ea83dc402a2bcba53f9b0011ecfa0d579b5a316e4c7f01ec5f1166dcdca138f-pkgtags.sqlite.gz: [Errno 14] HTTP Error 404 - Not Found Trying other mirror. (1/2): updates/20/x86_64/updateinfo | 1.9 MB 00:07 (2/2): updates/20/x86_64/pkgtags | 1.4 MB 00:01 Resolving Dependencies --> Running transaction check ---> Package zsh.x86_64 0:5.0.7-6.fc20 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: zsh x86_64 5.0.7-6.fc20 updates 2.5 M Transaction Summary ================================================================================ Install 1 Package Total download size: 2.5 M Installed size: 5.9 M Downloading packages: zsh-5.0.7-6.fc20.x86_64.rpm | 2.5 MB 00:03 Running transaction check Running transaction test Transaction test succeeded Running transaction (shutdown inhibited) Installing : zsh-5.0.7-6.fc20.x86_64 1/1 Verifying : zsh-5.0.7-6.fc20.x86_64 1/1 Installed: zsh.x86_64 0:5.0.7-6.fc20 Complete! |
Once you’ve installed the zsh
, you can configure like you would the bash
shell. You make edits to individual .zshrc
files and generic changes to the /etc/zshrc
file. You can find the documentation to edit the zsh
in the User’s Guide to the Z-Shell.
The following is a modified .zshrc
file. The changes enable the up-arrow in Oracle’s sqlplus
and provides you with a color prompt, like this:
# Source global definitions if [ -f /etc/zshrc ]; then . /etc/zshrc fi # Uncomment the following line if you don't like systemctl's auto-paging feature: # export SYSTEMD_PAGER= # Set the JAVA_HOME path. export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.75-2.5.4.2.fc20.x86_64 # Set the CLASSPATH path. export CLASSPATH=/usr/share/java/mysql-connector-java.jar:. # User specific aliases and functions . /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh # Wrap sqlplus with rlwrap to edit prior lines with the # up, down, left and right keys. sqlplus() { if [ "$RLWRAP" = "0" ]; then sqlplus "$@" else rlwrap sqlplus "$@" fi } # Set the bindkey. bindkey -v bindkey "^R" history-incremental-search-backward export EDITOR="vim" # history stuff HISTFILE=~/.zsh-histfile HISTSIZE=2000 # Set vi as a command line editor. set -o vi autoload -U colors && colors PS1="[%{$fg[red]%}%n%{$reset_color%}@%{$fg[blue]%}%m %{$fg[yellow]%}%~%{$reset_color%}% ]$ " |
The zsh
prompt looks like the following:
[student@localhost ~]$
If you’re configured with a bash
shell, you can change your shell to a zsh
with the following command:
chsh -s /bin/zsh |
As always, I hope this helps those looking for this type of information.