From: Michael D. Lowis Date: Thu, 13 Apr 2017 23:46:58 +0000 (-0400) Subject: rework edit script to support absolute paths X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=6f4064844e92b3cf6c9db31a93088812e74c66b9;p=projs%2Ftide.git rework edit script to support absolute paths --- diff --git a/edit b/edit index 48fd6e0..2ce5ba5 100755 --- a/edit +++ b/edit @@ -12,8 +12,15 @@ die() { # the new working directory. edit_relative_ctags(){ origdir="$PWD" - origpath="$PWD/$1" + case "$1" in + /*) origpath="$1" ;; # absoulte path given + *) origpath="$PWD/$1" ;; # relative path given + esac path="${origpath##*/}" + + # try to cd to the directory containing the file and attempt to walk the + # tree backwars until we find a tags file. if one is found, open the file + # from that directory. cd "${origpath%/*}" || die "could not open file: '$1'" dir="$PWD" while [ "$dir" != "" ]; do @@ -24,6 +31,8 @@ edit_relative_ctags(){ dir="${dir%/*}" fi done + + # file is not part of a project. open it as-is cd "$origdir" && exec nohup xedit "$1" > /dev/null 2>&1 }