(C) Martin Väth (martin at mvath.de)
This project is under the Creative Commons CC-BY-4.0 license. SPDX-License-Identifier: CC-BY-4.0
zshrc is a zsh initialization file (e.g. to be used as /etc/zshrc
or
~/.zshrc
) which activates a lot of zsh interactive features.
In particular, all of
- command-completion
- zsh-internal help system
- One or both of https://github.com/zsh-users/zsh-autosuggestions/ or https://github.com/hchbaw/auto-fu.zsh/
- One of https://github.com/zdharma/fast-syntax-highlighting/ or https://github.com/zsh-users/zsh-syntax-highlighting/
- https://github.com/vaeth/runtitle/
- https://github.com/vaeth/set_prompt/ (must be v3.0.0 or newer)
- https://github.com/vaeth/termcolors-mv/
are initialized if available.
(For auto-fu.zsh use at least version 0.0.1.13 [only in git, branch pu
].)
For gentoo, ebuilds for this and all above packages can be found in the mv overlay (available via layman).
Concerning the colors which zshrc
sets, only the following cases are tested
(and probably things will look ugly in other cases):
-
A terminal with a black background (and the 256 colors are mainly tested with xterm - with other terminals e.g. the highlighted colors may look differently and maybe bad). My testing xresources for xterm contain:
XTerm*cursorColor: green XTerm*background: black XTerm*foreground: white
-
The terminal is specially configured to use Ethan Schoonover's solarized colorscheme, see e.g. http://ethanschoonover.com/solarized
Both, light and dark schemes of solarized are tested. You have to tell zshrc that you want solarized by setting
SOLARIZED=true
(orlight
ordark
).
Note that the provided zshrc
file cares only about zsh specific features,
not about "standard" variables, aliases, or functions which you would
normally set in .profile
, .bash_profile
, or .bashrc
:
In particular, $PATH
etc. are expected to be complete when zshrc
is
sourced.
Optionally, zshrc
can source a separate file in which you can set things
like $PATH
, $CDPATH
, aliases, or functions for interactive usage in
bash syntax. (You might want to source that separate file also from
.bash_profile
or .bashrc
in an interactive bash.)
If you want to make use of that feature, you must have set
interactive=
/path/to/bashrc-file-for-interactive-mode
when sourcing zshrc
(or set it in the beginning of zshrc
).
In order to make it easier for you to modify details set in zshrc
,
you can define a function after_zshrc
: If this function is defined,
it is called at the very end of zshrc
(passing the arguments of the shell),
so you can undo/extend any change done in zshrc
if you wish to.
For example, by default zshrc disables a history file. If you call enable_history in the function after_zshrc, the history will be saved to $HOME/history and restored from there: after_zshrc() enable_history (use read_history to pick up changes saved in another terminal)
Also some other paths are configurable if you have set
DEFAULTS=(
/paths/to/dirs-with-local-configuration-files)
GITS=(
/paths/to/dirs-with-local-git-packages)
EPREFIX=(
/root-directories)
(the arrays can also be single strings; note that if you use Gentoo,
EPREFIX
must be a string)
when you source zshrc
. More precisely, if DEFAULTS
, GITS
, or EPREFIX
are defined, then the following files are taken from this location if
they exist:
-
$DEFAULTS/zsh-completion/*
-
$DEFAULTS/zsh/completion/*
This and all its subdirectories can contain local zsh completion files
-
$DEFAULTS/zsh-help
-
$DEFAULTS/zsh/help
-
$EPREFIX/usr/share/zsh/$ZSH_VERSION/help
-
$EPREFIX/usr/share/zsh/site-contrib/help
-
$EPREFIX/usr/share/zsh/site-functions/help
This substitutes
/usr/share/zsh/$ZSH_VERSION/help
or/usr/share/size-contrib/help
or/usr/share/size-functions/help
. The content should be generated with theUtil/helpfiles
script as described in the zsh manpage. -
$DEFAULTS/dir[_]colors/*
-
$GITS[/termcolors-mv[.git]][/etc]/dir[_]colors/*
-
$DEFAULTS/DIR_COLORS
If
dircolors-mv
(from termcolors-mv.git, see above or below) is in$path
, then zshrc usesdircolors-mv
: This selects the appropriate color scheme by taking the environment variable$TERM
and$SOLARIZED
into account (and zshrc-mv exports an appropriateDEFAULTS
fordircolors-mv
, trying first$DEFAULTS/...
and then$GITS/...
). termcolors-mv.git can be downloaded withgit clone https://github.com/vaeth/termcolors-mv.git
or (as a gentoo user) installed from the mv overlay.
If
dircolors-mv
is not in$PATH
,zshrc
uses as a fallback the first existing of$DEFAULTS/DIR_COLORS
~/.dircolors
/etc/DIRCOLORS
(ignoring the values of
$SOLARIZED
and$TERM
in this case). -
$DEFAULTS[/zsh][/zsh-autosuggestions]/zsh-autosuggestions.zsh
-
$GITS[/zsh-autosuggestions[.git]]/zsh-autosuggestions.zsh
-
$EPREFIX/usr/share/zsh/site-[contrib|functions][/zsh-autosuggestions]/zsh-autosuggestions.zsh
This substitutes the corresponding file in
/usr/share/zsh/site-contrib
or/usr/share/zsh/site-functions
. Fallback is to use$PATH
. Download e.g. withgit clone https://github.com/zsh-users/zsh-autosuggesitons.git
git checkout develop
(necessary at the time of writing this)Set
ZSHRC_AUTO_ACCEPT
to a nonempty value if the suggestions should be automatically accepted with returnor (as a gentoo user) install from the mv overlay.
-
$DEFAULTS[/zsh][auto-fu[.zsh]]/auto-fu[.zsh]
-
$GITS[/auto-fu[.zsh][.git]]/auto-fu[.zsh]
-
$EPREFIX/usr/share/zsh/site-[contrib|functions][/auto-fu[.zsh]]/auto-fu[.zsh]
This substitutes the corresponding file in
/usr/share/zsh/site-contrib
or/usr/share/zsh/site-functions
. Fallback is to use$PATH
. Download e.g. withgit clone https://github.com/hchbaw/auto-fu.zsh.git
git checkout pu
or (as a gentoo user) install from the mv overlay.
If zsh-autosuggestions and auto-fu.zsh are both installed, only the former is used by default. If you want to use the latter instead, set
ZSHRC_PREFER_AUTO_FU
to a nonempty value. If you want to use both, set insteadZSHRC_USE_AUTO_FU
to a nonempty value. To skip both, setZSH_SKIP_AUTO
to a nonempty value. -
$DEFAULTS[/zsh][/fast-syntax-highlighting]/fast-syntax-highlighting.plugin.zsh
-
$GITS[/fast-syntax-highlighting[.git]]/fast-syntax-highlighting.plugin.zsh
-
$EPREFIX/usr/share/zsh/site-[contrib|functions][/fast-syntax-highlighting]/fast-syntax-highlighting.plugin.zsh
This substitutes the corresponding file in
/usr/share/zsh/site-contrib
or/usr/share/zsh/site-functions
. Fallback is to use$PATH
. Download e.g. withgit clone https://github.com/zdharma/fast-syntax-highlighting.git
or (as a gentoo user) install from the mv overlay.
-
$DEFAULTS[/zsh][/zsh-syntax-highlighting]/zsh-syntax-highlighting.zsh
-
$GITS[/zsh-syntax-highlighting[.git]]/zsh-syntax-highlighting.zsh
-
$EPREFIX/usr/share/zsh/site-[contrib|functions][/zsh-syntax-highlighting]/zsh-syntax-highlighting.zsh
This substitutes the corresponding file in
/usr/share/zsh/site-contrib
or/usr/share/zsh/site-functions
. Fallback is to use$PATH
. Download e.g. withgit clone https://github.com/zsh-users/zsh-syntax-highlighting.git
or (as a gentoo user) install from the mv overlay.
If zsh-syntax-highlighting and fast-syntax-highlighting are both installed, the former is used, by default. If you want to use the latter instead, set
ZSHRC_PREFER_ZSH_SYNTAX_HIGHLIGHTING
to a nonempty value. To skip both, setZSH_SKIP_SYNTAX_HIGHLIGHTING
to a nonempty value.
The variables $DEFAULTS
, $GIT
, and $EPREFIX
are not honoured for support
for runtitle and set_prompt (earlier versions of zshrc-mv had some
mixture here). To get support for these packages (which is recommended)
download them with
git clone https://github.com/vaeth/runtitle.git
git clone https://github.com/vaeth/set_prompt.git
or (as a gentoo user) install them from the mv overlay
and make sure to have the corresponding directories in your $PATH
.