Dotfiles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

211 lines
4.3 KiB

# 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
# Detect missing profiles and try to fall back
#
_zp_terminfo_paths=("$HOME/.terminfo" "/etc/terminfo" "/lib/terminfo" "/usr/share/terminfo")
_zp_terminfo_found=
_zp_terminfo_name="${TERM:0:1}/$TERM"
for _zp_terminfo_path in "${_zp_terminfo_paths[@]}"; do
if [[ -f "$_zp_terminfo_path/$_zp_terminfo_name" ]]; then
_zp_terminfo_found="$_zp_terminfo_path"
break
fi
done
if [ -z "$_zp_terminfo_found" ]; then
if [[ "${TERM:0:7}" == "konsole" ]] || echo "$TERM" | grep -q 256color; then
_zp_terminfo_color=-256color
else
_zp_terminfo_color=
fi
if [[ "${TERM:0:4}" == "tmux" ]]; then
_zp_terminfo_base=screen
else
_zp_terminfo_base=xterm
fi
export TERM=$_zp_terminfo_base$_zp_terminfo_color
if [[ -o INTERACTIVE || -o SHIN_STDIN ]]; then
echo "NOTE: Falling back to TERM=$TERM (terminfo/$_zp_terminfo_name not found)" >&2
fi
fi
#
# KDE
#
export KDE_DEVEL_HOME=$HOME/Development/KDE
if [ -d "$KDE_DEVEL_HOME" ]; then
if [ -d "$KDE_DEVEL_HOME/kdesrc-build" ]; then
KDE_SRC_BUILD="$KDE_DEVEL_HOME/kdesrc-build"
fi
else
unset KDE_DEVEL_HOME
fi
#
# Vitasdk
#
export VITASDK="/usr/local/vitasdk"
if [ -d "$VITASDK/bin" ]; then
VITASDK_BIN="$VITASDK/bin"
fi
#
# GOPATH
#
export GOPATH=$HOME/.local/go
#
# 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
$KDE_SRC_BUILD
$VITASDK_BIN
/usr/local/{bin,sbin}
/snap/bin
$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"