From b6f49344f3fac736a0e6b67390cf8e7604ac5bbd Mon Sep 17 00:00:00 2001 From: crater2150 Date: Thu, 2 Mar 2023 16:21:35 +0100 Subject: [PATCH] Override VCS_INFO_bydir_detect because of problems with NFS --- functions/VCS_INFO_bydir_detect | 41 +++++++++++++++++++++++++++++++++ zshrc | 3 ++- 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 functions/VCS_INFO_bydir_detect diff --git a/functions/VCS_INFO_bydir_detect b/functions/VCS_INFO_bydir_detect new file mode 100644 index 0000000..0d313b2 --- /dev/null +++ b/functions/VCS_INFO_bydir_detect @@ -0,0 +1,41 @@ +## vim:ft=zsh +## Written by Frank Terbeck +## Distributed under the same BSD-ish license as zsh itself. + +# Helper function for VCS_INFO_detect_* +# +# Usage: +# vcs_comm[detect_need_file]=FILENAMES VCS_INFO_bydir_detect DIRNAME +# where DIRNAME is a directory name and FILENAMES is a space-separated list +# of filenames. +# +# If any parent directory of the current working directory, other than the root +# directory, contains a subdirectory named DIRNAME that contains a file whose name +# is in FILENAMES, set vcs_comm[basedir] to the path of that parent directory and +# return true. Otherwise, return false. + +setopt localoptions NO_shwordsplit +local dirname=$1 +local basedir="." file + +basedir=$(realpath ${basedir}) +while [[ ${basedir} != '/' ]]; do + [[ -r ${basedir} ]] || return 1 + if [[ -n ${vcs_comm[detect_need_file]} ]] ; then + [[ -d ${basedir}/${dirname} ]] && { + for file in ${(s: :)${vcs_comm[detect_need_file]}}; do + [[ -e ${basedir}/${dirname}/${file} ]] && break 2 + done + } + else + [[ -d ${basedir}/${dirname} ]] && break + fi + + basedir=${basedir:h} +done + +[[ ${basedir} == "/" ]] && return 1 +vcs_comm[basedir]=${basedir} +# TODO: Would the following be correct? --- +# rrn=${vcs_comm[basedir]:t} +return 0 diff --git a/zshrc b/zshrc index f091513..b488dd1 100644 --- a/zshrc +++ b/zshrc @@ -12,13 +12,14 @@ setopt hist_ignore_space share_history #setopt hist_ignore_all_dups setopt no_auto_remove_slash auto_param_slash setopt completeinword -setopt chase_links +#setopt chase_links setopt short_loops setopt cdable_vars WORDCHARS=${WORDCHARS//\/} cdpath+=$HOME export ZDOTDIR=${ZDOTDIR:-$HOME/.zsh} +fpath=($ZDOTDIR/functions $fpath) function exists { command -v "$@" >/dev/null }