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
30
zshrc
30
zshrc
|
@ -1,28 +1,16 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
find_dotfiles_dir() {
|
||||
local readlink
|
||||
# readlink=$(which greadlink || which readlink)
|
||||
local script_path"=${(%):-%x}"
|
||||
|
||||
if [[ -n "$script_path" && -x "$readlink" ]]; then
|
||||
script_path=$($readlink -f "$script_path")
|
||||
DOTFILES_DIR=$(dirname "$script_path")
|
||||
else
|
||||
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
|
||||
export DOTFILES_DIR
|
||||
else
|
||||
echo "dotfiles directory not found"
|
||||
fi
|
||||
|
||||
for prefix in "$HOME/." "/usr/share/" "/usr/local/share/"; do
|
||||
DOTFILES_DIR="${prefix}dotfiles"
|
||||
[[ -d "$DOTFILES_DIR" ]] && return
|
||||
done
|
||||
|
||||
local script_path
|
||||
script_path=$(realpath "${(%):-%x}")
|
||||
DOTFILES_DIR=$(dirname "$script_path")
|
||||
}
|
||||
|
||||
find_dotfiles_dir
|
||||
|
|
Loading…
Reference in a new issue