mirror of
https://github.com/keanuplayz/dotfiles.git
synced 2024-08-15 02:33:12 +00:00
rewrite zshrc to use realpath
instead of readlink -f
This commit is contained in:
parent
b7a2066f41
commit
69343ebdd7
1 changed files with 8 additions and 20 deletions
28
zshrc
28
zshrc
|
@ -1,28 +1,16 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
find_dotfiles_dir() {
|
find_dotfiles_dir() {
|
||||||
local readlink
|
export DOTFILES_DIR
|
||||||
# readlink=$(which greadlink || which readlink)
|
|
||||||
local script_path"=${(%):-%x}"
|
|
||||||
|
|
||||||
if [[ -n "$script_path" && -x "$readlink" ]]; then
|
for prefix in "$HOME/." "/usr/share/" "/usr/local/share/"; do
|
||||||
script_path=$($readlink -f "$script_path")
|
DOTFILES_DIR="${prefix}dotfiles"
|
||||||
DOTFILES_DIR=$(dirname "$script_path")
|
[[ -d "$DOTFILES_DIR" ]] && return
|
||||||
else
|
done
|
||||||
for prefix in "$HOME/" "$HOME/." "/usr/share/" "/usr/local/share/"; do
|
|
||||||
local dotfiles_dir="${prefix}dotfiles"
|
|
||||||
if [[ -d "$dotfiles_dir" ]]; then
|
|
||||||
DOTFILES_DIR="$dotfiles_dir"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -d $DOTFILES_DIR ]]; then
|
local script_path
|
||||||
export DOTFILES_DIR
|
script_path=$(realpath "${(%):-%x}")
|
||||||
else
|
DOTFILES_DIR=$(dirname "$script_path")
|
||||||
echo "dotfiles directory not found"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
find_dotfiles_dir
|
find_dotfiles_dir
|
||||||
|
|
Loading…
Reference in a new issue