From 69343ebdd754410eea48ee7062ea1c7a660e6e90 Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Fri, 23 Feb 2018 19:15:26 +0200 Subject: [PATCH] rewrite zshrc to use `realpath` instead of `readlink -f` --- zshrc | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/zshrc b/zshrc index c5038e5..0177962 100755 --- a/zshrc +++ b/zshrc @@ -1,28 +1,16 @@ #!/usr/bin/env bash find_dotfiles_dir() { - local readlink - # readlink=$(which greadlink || which readlink) - local script_path"=${(%):-%x}" + export DOTFILES_DIR - 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 + for prefix in "$HOME/." "/usr/share/" "/usr/local/share/"; do + DOTFILES_DIR="${prefix}dotfiles" + [[ -d "$DOTFILES_DIR" ]] && return + done - if [[ -d $DOTFILES_DIR ]]; then - export DOTFILES_DIR - else - echo "dotfiles directory not found" - fi + local script_path + script_path=$(realpath "${(%):-%x}") + DOTFILES_DIR=$(dirname "$script_path") } find_dotfiles_dir