Software > Scripting Languages >
(on Wikipedia)
https://www.zsh.org/
A shell.
Though not usually available for a Linux distribution, it's exceptionally powerful enough that I insist upon it.
Default for macOS.
-
aka Z shell
Note that you will find a lot of example and working code on GitHub:
--
-
- As of 2019-11-17 it seems to have been reworked/abandoned.. with old content gone missing. Go exploring through archives if you're highly interested.
--
- 2019-11-17 - 5.3.1-4+b3 on Debian 10.1.0-amd64-xfce-CD-1
- 2016-03-28 - 5.0.2 on Slackware 14.1
- 2016-03-26 - 5.0.2 on Lubuntu 14.04.4 LTS
- 2009-07-18 - 4.3.9 on Unity Linux 0.99-alpha1
- 2009-04-21 - 4.3.9 on PCLinuxOS 2007
-
2009-04-21 - 4.2.6 on PCLinuxOS 2007
- This was an ancient version which they had in their repository.. it was released 2005-12-05. That's complete BS.
- 2006-04-22 - (version not recorded) on (distribution not recorded)
-
I had used this for a very long time on multiple distributions.
2016-03-28 - 5.0.2 ∞
zsh 5.0.2 (i486-slackware-linux-gnu)
I installed this with slpkg:
\slpkg -s sbo zsh
2016-03-26 - 5.0.2 ∞
zsh 5.0.2 (x86_64-pc-linux-gnu)
I installed this with Lubuntu's package manager.
(no particular notes were written)
2009-07-18 - 4.3.9 ∞
TODO: - https://wiki.archlinux.org/title/Zsh [ 1 ]
Everything worked fine out of the box, except for the home
/end
bindings. I had to change them:
# home bindkey '^[[1~' beginning-of-line # end bindkey '^[[4~' end-of-line
It also turned out that most of the other customizations I did really were not needed, so I commented them out.
2009-04-21 - 4.3.9 ∞
Tested 2009-04-21 through to 2009-07-18
-
2009-04-21: Holy crap, Sourceforge is still stuck at 4.2.7, released between 2005-12-05 (4.2.6) and 2006-02-28 (4.3.1).
- A news entry for 4.2.7 didn't get released at https://zsh.sourceforge.io/News/ [ 2 ]
- I had to check https://www.zsh.org/pub/ for it.
- https://zsh.sourceforge.io/News/ [ 3 ] doesn't include this. =/
-
omg, a first-run welcome and walkthrough! Re-run it with:
zsh Scripts/newuser
--
HISTFILE=~/.zsh/histfile
-
Configuring tab completion:
autoload -Uz compinstall
compinstall
-
I'm allowing the shell to choose my keybindings. This might be a bad idea.
setopt autocd setopt appendhistory setopt nomatch unsetopt beep setopt notify
The result was this ~/.zshrc
# Lines configured by zsh-newuser-install HISTFILE=~/.zsh/histfile HISTSIZE=1000 SAVEHIST=1000 setopt appendhistory autocd nomatch notify unsetopt beep # End of lines configured by zsh-newuser-install # The following lines were added by compinstall zstyle :compinstall filename '/home/user/.zshrc' autoload -Uz compinit compinit # End of lines added by compinstall
cd ~/ mkdir ~/.zsh echo "# /etc/zshenv is the 1st file zsh reads; it's read for every shell, even if started with -f (setopt NO_RCS)" >> ~/.zsh/1-every.sh echo "# ~/.zshenv is the same, except that it's _not_ read if zsh is started with -f" >> ~/.zsh/1-every.sh ln -s ~/.zsh/1-every.sh ~/.zshenv echo "# /etc/zprofile and ~/.zprofile - read after zshenv, if the shell is a login shell" >> ~/.zsh/2-login.sh ln -s ~/.zsh/2-login.sh ~/.zprofile mv ~/.zshrc ~/.zsh/3-interactive.sh echo "# " >> ~/.zsh/3-interactive.sh echo "# /etc/zshrc and ~/.zshrc - read after zprofile, if the shell is an interactive shell" >> ~/.zsh/3-interactive.sh ln -s ~/.zsh/3-interactive.sh ~/.zshrc echo "# /etc/zlogin and ~/.zlogin - read after zshrc, if the shell is a login shell" >> ~/.zsh/4-login.sh ln -s ~/.zsh/4-login.sh ~/.zlogin echo "# /etc/zlogout and ~/.zlogout - Note, that for Shutdown files, the order is different to Startup files: first the per-user file is read, then the global one." >> ~/.zsh/shutdown.sh ln -s ~/.zsh/shutdown.sh ~/.zlogout echo "# I don't know what this is.." >> ~/.zsh/zcompdump.sh mv ~/.zcompdump ~/.zsh/zcompdump.sh ln -s ~/.zsh/zcompdump.sh ~/.zcompdump zsh
-
Aliases are not sane. no colour
ls
.- took the stuff from my .bashrc
-
Allow the user to paste into the console, and allow the # to comment things. DUH.
setopt INTERACTIVE_COMMENTS
-
zshwiki.org/home/zle/bindkeys?s=typeset key bindings (hotkeys)
- https://web.archive.org/web/20200810013845/https://zshwiki.org/home/keybindings/
- Learn a key with
control-v
and then the sequence. - TODO:
control-left
/control-right
-- Maybe override with.Xresources
# key bindings typeset -g -A key # backspace # TODO - `alt-backspace` and `control-backspace` are both the same! # So maybe somehow rig a function up to the backspace key to see if alt/ctrl were held down? bindkey '^?' backward-delete-char # delete bindkey '^[[3~' delete-char # left bindkey '^[[D' backward-char # right bindkey '^[[C' forward-char # home bindkey '^[[1~' beginning-of-line # end bindkey '^[[4~' end-of-line # up bindkey '^[[A' up-line-or-history # down bindkey '^[[B' down-line-or-history # pageup (matching history) bindkey '^[[5~' up-line-or-search # pagedown (matching history) bindkey '^[[6~' down-line-or-search # control-left bindkey '^[[1;5D' backward-word # control-right bindkey '^[[1;5C' forward-word
-
The default prompt is garbage.
A basic prompt, in my ~/.zshrc
put:
autoload -U promptinit && promptinit prompt suse
A nicer prompt:
Bash had:
PS1="\w\[\e[34;1m\] > \[\e[0m\]"
zsh has:
PS1=%~$'%{\e[34;1m%} > %{\e[0m%}'
also, you can be more cool like this:
autoload -U colors && colors PS1="%{$fg[red]%}%n%{$reset_color%}@%{$fg[blue]%}%m %{$fg[yellow]%}%~ %{$reset_color%}%% "
I have NO FREAKING CLUE how to do attribute changing. Nobody else does either.
- If playing around with stuff, restart zsh with:
exec zsh
-
Fix the title, add this to
~/.zshrc
:
# Update the title of an xterm chpwd() { [[ -t 1 ]] || return case $TERM in sun-cmd) print -Pn "\e]l%~\e\\" ;; *xterm*|rxvt|(dt|k|E)term) print -Pn "\e]2;%~\a" ;; esac } # And force the title to update on startup chpwd
Changing my default shell:
su chsh -s /usr/local/bin/zsh user
Then log out (restart X) for it to be effective.
Notes ∞
- zsh-lovers - tips, tricks and examples for the Z shell
-
sjl's oh-my-zsh - a framework for managing zsh configuration
- TODO - Check out
ZSH_THEME_GIT_PROMPT_UNTRACKED
- I've been using this for years.
- TODO - make a page
- TODO - Check out
- using coproc to send a job into the background and still work with it.
- quality bitching
- an ancient guide
- Curtains up: introducing the Z shell
-
character index
-
- Not 64 bit
- As of 2016-01-29 not updated since 2010.
- .. just use Windows Subsystem for Linux or even Virtualization instead.
You probably don't want .zshrc
to produce output, either, since there are occasions when this can be a problem, such as when using rsh from another host.
See this https://zsh.sourceforge.io/FAQ/zshfaq03.html#321 [ 4 ] to see what I should put in .zshrc
to save my history.
Tab completion ∞
pressing tab
on a blank line should cycle through executables in the current directory
cd <tab>
should cycle through directories in the current directory-
compctl -g '*.(ps|eps)' ghostview
-- this will limit theghostview
command totab
-complete certain file extensions.
Prompt notes ∞
# Left prompt PS1='B(%h) %m%#%b' # Right prompt RPS1='(%20<...<%~)'
Last updated 2022-11-23 at 17:36:17
Footnotes
- was https://wiki.archlinux.org/index.php/Zsh [ ↩ ]
- was http://zsh.sourceforge.net/News/ [ ↩ ]
- was http://zsh.sourceforge.net/News/ [ ↩ ]
- was http://zsh.sourceforge.net/FAQ/zshfaq03.html#321 [ ↩ ]
ported old review notes
finished porting