Skip to content

[Shell] Environment Variable "DOTFILES" Auto Detection Can't Support Absolute Path #8

Description

@Johnson9009

Currently only if the shell initialization file (.zshrc) is a relative link, then the env "DOTFILES" can be set correctly by the logic of file shell/zsh/zshrc because of below code.

dotfiles/shell/zsh/zshrc

Lines 75 to 89 in 88e1a6d

# Setting the full path of our dotfiles directory automatically.
# This script can be executed through 3 different ways.
# - Executed directly by shell through symbolic link(e.g., ~/.zshrc -> zshrc)
# - sourced by other script through symbolic link(e.g., source ~/.zshrc)
# - sourced by other script directly(e.g., source zshrc)
# Below line of code can get the full path of this script no matter how this
# script is executed.
SHRC=${(%):-%x}
# Resolve the real path of this script, if it is a symbolic link.
while [[ -L ${SHRC} ]]; do
SHRC=`dirname ${SHRC}`/`readlink ${SHRC}`
done
OLD_DIR=`pwd`; cd `dirname ${SHRC}`/../..; unset SHRC
export DOTFILES=`pwd`
cd ${OLD_DIR}; unset OLD_DIR

Metadata

Metadata

Assignees

Labels

P1High

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions