# vim: ft=zsh # # Executes commands in every top-level or login shell # # ATTENTION: This differs from usual zsh behaviour! In addition to traditional # login shells, this is also sourced by any top-level ($SHLVL=1) # non-login shells. (In the latter case, from zshenv) # # This is useful because it only gets executed once for any given tree # of zsh-processes, saving resources on sub-shell invocation while still # providing a consistent environment in login and non-login shells. # # Then why also source it in non-interactive shells? # Because it prevents desync between scripts and interactive prompts. # Ever tried to debug a script and ended up with "But it works in the prompt!"? # # For code intended for login shells only, use zlogin instead. # # # Browser # if [[ "$OSTYPE" == darwin* ]]; then export BROWSER=open elif (( $+commands[termux-open] )); then export BROWSER=termux-open elif (( $+commands[xdg-open] )); then export BROWSER=xdg-open fi # # Editors # if (( $+commands[nvim] )); then export EDITOR=nvim export VISUAL=nvim else export EDITOR=vim export VISUAL=vim fi export PAGER='less' # # Language # if [[ -z "$LANG" ]]; then export LANG='en_US.UTF-8' fi # # Termux # if (( $+commands[termux-info] )); then export TMPDIR="$PREFIX/tmp" fi # # Terminfo # if [[ ! -f "${PREFIX:-/usr}/share/terminfo/${TERM:0:1}/$TERM" ]]; then if [[ "${TERM:0:7}" == "konsole" ]] || echo $TERM | grep -q 256color; then export TERM=xterm-256color else export TERM=xterm fi fi # # Paths # # Set the the list of directories that cd searches. # cdpath=( # $cdpath # ) # Set the list of directories that Zsh searches for programs. path=( $HOME/.local/bin $DOTFILES/bin $HOME/junest/bin /usr/local/{bin,sbin} $path ) # Set the list of directories that Python searches for modules. pythonpath=( $DOTFILES/lib/python "${(@s|:|)PYTHONPATH}" ) # Ensure path arrays do not contain duplicates. typeset -gU cdpath fpath mailpath path pythonpath # zsh only maps the array and text versions for PATH export PYTHONPATH="${(j|:|)pythonpath}" # # Less # # Set the default Less options. # Mouse-wheel scrolling has been disabled by -X (disable screen clearing). # Remove -X and -F (exit if the content fits on one screen) to enable it. export LESS='-F -g -i -M -R -S -w -X -z-4' # Set the Less input preprocessor. if (( $+commands[lesspipe.sh] )); then export LESSOPEN='| /usr/bin/env lesspipe.sh %s 2>&-' fi # # Temporary Files # if [[ ! -d "$TMPDIR" ]]; then export TMPDIR="/tmp/$UID" mkdir -p -m 700 "$TMPDIR" fi TMPPREFIX="${TMPDIR%/}/zsh" if [[ ! -d "$TMPPREFIX" ]]; then mkdir -p "$TMPPREFIX" fi # # SSH # if (( $+commands[systemctl] )); then eval "$(systemctl --user show-environment | grep '^SSH_AUTH_SOCK=')" fi if [ -n $SSH_AUTH_SOCK -a -f "$XDG_RUNTIME_DIR/ssh-agent.sock" ]; then SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.sock" fi export SSH_AUTH_SOCK # # Arch Build system # if [ -f /etc/arch-release ]; then export ASPROOT=$HOME/aur/ABS/.asp fi # # LaTeX # export TEXMFHOME=$DOTFILES/texmf # # Local overrides # [[ -e "$DOTFILES/zsh/zprofile.local" ]] && source "$DOTFILES/zsh/zprofile.local"