# HSTR configuration - add this to ~/.zshrc if type "hstr" >/dev/null; then alias hh=hstr # hh to be alias for hstr setopt histignorespace # skip cmds w/ leading space from history export HSTR_CONFIG=hicolor # get more colors hstr_no_tiocsti() { zle -I { HSTR_OUT="$( { &1 1>&3 3>&- )"; } 3>&1; BUFFER="${HSTR_OUT}" CURSOR=${#BUFFER} zle redisplay } zle -N hstr_no_tiocsti bindkey '\C-r' hstr_no_tiocsti export HSTR_TIOCSTI=n else bindkey '\C-r' history-incremental-search-backward fi # better ls if command -v "eza" >/dev/null 2>&1; then alias ll="eza -bghHlS" else alias ll="exa -bghHlS" fi # bat (debian) if command -v "batcat" >/dev/null 2>&1; then alias bat="batcat" fi # lf lfwrapper() { command lf "$@" # cleanup awk '$1 == "archivemount" { print $2 }' /etc/mtab | while read -r mntdir; do sanitized_input="$(printf "${mntdir}")" # /etc/mtab uses octal representation of spaces (possible other symbols too), printf would convert octal representation, so that it can be used in the umount & rmdir commands. umount "${sanitized_input}" rmdir "${sanitized_input}" done } lfcd() { dir="$(lfwrapper -print-last-dir "$@")" while ! cd "${dir}" 2>/dev/null; do dir="$(dirname -- "${dir}")" done } alias lf=lfcd # ranger ranger_cd() { temp_file="$(mktemp -t "ranger_cd.XXXXXXXXXX")" ranger --choosedir="${temp_file}" -- "${@:-${PWD}}" if chosen_dir="$(cat -- "${temp_file}")" && [ -n "${chosen_dir}" ] && [ "${chosen_dir}" != "${PWD}" ]; then cd -- "${chosen_dir}" fi rm -f -- "${temp_file}" } alias ranger=ranger_cd # mc if [ -f "/usr/libexec/mc/mc.sh" ]; then source "/usr/libexec/mc/mc.sh" fi # nix package manager if [ -e "${HOME}/.nix-profile/etc/profile.d/nix.sh" ]; then source "${HOME}/.nix-profile/etc/profile.d/nix.sh" fi # added by Nix installer # nix shell if command -v nix-your-shell >/dev/null 2>&1; then nix-your-shell zsh | source /dev/stdin fi # node.js export NVM_DIR="${HOME}/.nvm" [ -s "${NVM_DIR}/nvm.sh" ] && source "${NVM_DIR}/nvm.sh" # This loads nvm [ -s "${NVM_DIR}/bash_completion" ] && source "${NVM_DIR}/bash_completion" # This loads nvm bash_completion # rvm [ -s "${HOME}/.rvm/scripts/rvm" ] && source "${HOME}/.rvm/scripts/rvm" # pyenv export PYENV_ROOT="${HOME}/.pyenv" if [[ -d "${PYENV_ROOT}/bin" ]]; then path=("${PYENV_ROOT}/bin" "${path[@]}") export PATH eval "$(pyenv init - zsh)" eval "$(pyenv virtualenv-init -)" fi # inside tmux, we don't know if Sway got restarted if [[ -v TMUX ]]; then swaymsg() { export SWAYSOCK="${XDG_RUNTIME_DIR}/sway-ipc.${UID}.$(pgrep -x sway).sock" command swaymsg "$@" } fi