Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set $XDG_CONFIG_HOME and $VCSH_BASE based on existing .config/vcsh #255

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions vcsh
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,29 @@ source_all() {

# Read configuration and set defaults if anything's not set
[ -n "$VCSH_DEBUG" ] && set -vx

# Set $XDG_CONFIG_HOME and $VCSH_BASE based on existing .config/vcsh
# (To create a new $VCSH_BASE: mkdir -p $VCSH_BASE/.config/vcsh)
if [ ! -n "$XDG_CONFIG_HOME" ] && [ ! -n "$VCSH_BASE" ]; then
# Search for .config/vcsh in actual directory path
VCSH_BASE="$(pwd)"
while :; do
if [ -d "$VCSH_BASE/.config/vcsh" ]; then
break
elif [ "$VCSH_BASE" = "/" ]; then
VCSH_BASE=""
break
else
VCSH_BASE="$(dirname "$VCSH_BASE")"
fi
done
if [ "$VCSH_BASE" ]; then
# Check Permission denied problems
find "$VCSH_BASE/.config/" >/dev/null || fatal "problem reading files in $VCSH_BASE/.config/"
XDG_CONFIG_HOME="$VCSH_BASE/.config"
fi
fi

: ${XDG_CONFIG_HOME:="$HOME/.config"}

# Read configuration files if there are any
Expand Down