zsh: adjust profile/.zshenv for zsh and add .zshrc

This commit is contained in:
Fernando Schauenburg 2021-08-07 02:27:20 +02:00
parent a52bc02768
commit cf01371f00
3 changed files with 36 additions and 23 deletions

View file

@ -41,6 +41,7 @@ ${XDG_CONFIG_HOME}/tmux
${XDG_CONFIG_HOME}/nvim ${XDG_CONFIG_HOME}/nvim
${XDG_CONFIG_HOME}/nvim/autoload ${XDG_CONFIG_HOME}/nvim/autoload
${XDG_CONFIG_HOME}/shell ${XDG_CONFIG_HOME}/shell
${XDG_CONFIG_HOME}/zsh
${XDG_DATA_HOME}/bash ${XDG_DATA_HOME}/bash
${XDG_DATA_HOME}/bash-completion/completions ${XDG_DATA_HOME}/bash-completion/completions
${XDG_DATA_HOME}/less ${XDG_DATA_HOME}/less
@ -57,6 +58,7 @@ files/bashrc ${HOME}/.bashrc
files/bash_profile ${HOME}/.bash_profile files/bash_profile ${HOME}/.bash_profile
files/jupyter_custom.js ${HOME}/.jupyter/custom/custom.js files/jupyter_custom.js ${HOME}/.jupyter/custom/custom.js
files/jupyter_notebook.json ${HOME}/.jupyter/nbconfig/notebook.json files/jupyter_notebook.json ${HOME}/.jupyter/nbconfig/notebook.json
files/profile.sh ${HOME}/.zshenv
files/ssh_config ${HOME}/.ssh/config files/ssh_config ${HOME}/.ssh/config
files/alacritty.yml ${XDG_CONFIG_HOME}/alacritty/alacritty.yml files/alacritty.yml ${XDG_CONFIG_HOME}/alacritty/alacritty.yml
files/gitconfig ${XDG_CONFIG_HOME}/git/config files/gitconfig ${XDG_CONFIG_HOME}/git/config
@ -70,6 +72,7 @@ files/init.vim ${XDG_CONFIG_HOME}/nvim/init.vim
files/aliases.sh ${XDG_CONFIG_HOME}/shell/aliases.sh files/aliases.sh ${XDG_CONFIG_HOME}/shell/aliases.sh
files/profile.sh ${XDG_CONFIG_HOME}/shell/profile.sh files/profile.sh ${XDG_CONFIG_HOME}/shell/profile.sh
files/solarized.sh ${XDG_CONFIG_HOME}/shell/solarized.sh files/solarized.sh ${XDG_CONFIG_HOME}/shell/solarized.sh
files/zshrc ${XDG_CONFIG_HOME}/zsh/.zshrc
EOF EOF
) )

View file

@ -23,38 +23,40 @@ export LOCAL_CONFIG="$HOME/.local/etc"
export LOCAL_PREFIX="/usr/local" export LOCAL_PREFIX="/usr/local"
export PAGER=less export PAGER=less
export PYTHONSTARTUP="$XDG_CONFIG_HOME/python/startup.py" export PYTHONSTARTUP="$XDG_CONFIG_HOME/python/startup.py"
export ZDOTDIR="$XDG_CONFIG_HOME/zsh"
if command -v manpath >/dev/null 2>&1; then
MANPATH="$(unset MANPATH; manpath)"
export MANPATH
fi
# Prevent path_helper from messing with the PATH when starting tmux. # Prevent path_helper from messing with the PATH when starting tmux.
# See: https://superuser.com/a/583502 # See: https://superuser.com/a/583502
[ "$(uname -s)" == "Darwin" ] && { PATH=""; source /etc/profile; } [ "$(uname -s)" = "Darwin" ] && { PATH=""; source /etc/profile; }
_prepend_path() { # prepend $1 to var $2 avoiding duplicates using : as separator
if [ -d "$1" ] && [ -n "$2" ]; then
local _path="${!2}" # get path variable value
case ":$_path:" in
*":$1:"*) :;; # dir already in path, noop (:)
*) _path="$1${_path:+:}$_path";; # prepend (adding : if not empty)
esac
printf -v "$2" "%s" "$_path" # write back to path variable
fi
}
# Add custom bin dirs to PATH if they exist and are not already in PATH. # Add custom bin dirs to PATH if they exist and are not already in PATH.
while read -r dir; do
case ":${PATH:=$dir}:" in
*:"$dir":*) ;;
*) PATH="$dir:$PATH" ;;
esac
done <<EOL
$LOCAL_PREFIX/bin
$HOME/.local/bin
EOL
export PATH
# Prepend custom man directories to MANPATH if they exist, so that we get # Prepend custom man directories to MANPATH if they exist, so that we get
# correct man page entries when multiple versions of a command are # correct man page entries when multiple versions of a command are
# available. # available.
while read -r var dir; do _prepend_path "$dir" "$var"; done <<EOL [ command -v manpath >/dev/null 2>&1 ] && MANPATH="$(unset MANPATH; manpath)"
PATH $LOCAL_PREFIX/bin while read -r dir; do
MANPATH $LOCAL_PREFIX/share/man case ":${MANPATH:=$dir}:" in
PATH $HOME/.local/bin *:"$dir":*) ;;
MANPATH $HOME/.local/share/man *) MANPATH="$dir:$MANPATH" ;;
esac
done <<EOL
$LOCAL_PREFIX/share/man
$HOME/.local/share/man
EOL EOL
unset var dir _prepend_path export MANPATH
unset dir
# This check has to be done after PATH manipulation above so we can find brew. # This check has to be done after PATH manipulation above so we can find brew.
if command -v brew >/dev/null 2>&1; then if command -v brew >/dev/null 2>&1; then

8
files/zshrc Normal file
View file

@ -0,0 +1,8 @@
#!/bin/zsh
# Set up zsh for interactive use (options, prompt, aliases, etc.)
stty -ixon # disable ctrl-s and ctrl-q
[ -f "${XDG_CONFIG_HOME}/shell/aliases.sh" ] && source "${XDG_CONFIG_HOME}/shell/aliases.sh"
[ -f "${XDG_CONFIG_HOME}/shell/solarized.sh" ] && source "${XDG_CONFIG_HOME}/shell/solarized.sh"