From: Michael D. Lowis Date: Mon, 27 Mar 2017 13:35:18 +0000 (-0400) Subject: Updated edit script to open files relative to the dir containing the project's ctags... X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=1f429babb518c631ddcbb7c9fbbe137fb0cca1b3;p=projs%2Ftide.git Updated edit script to open files relative to the dir containing the project's ctags file --- diff --git a/TODO.md b/TODO.md index 46917f6..bc696be 100644 --- a/TODO.md +++ b/TODO.md @@ -2,30 +2,29 @@ Up Next: -* update edit to cd to dir containing tags file if it exists +* clipboard does not persist after exit +* Run commands in the background and don't block the main thread. * Make Fn keys execute nth command in the tags buffer * check for file changes on save * check for file changes when window regains focus * Right click in tags region should search edit region * 100% coverage with unit and unit-integration tests -* selecting text should set PRIMARY x11 selection * Add a SaveAs tag that takes an argument for the filename to save as * Add a GoTo tag for ctags lookup and line number jump (or right click magic?) * Add keyboard shortcut to highlight the thing under the cursor * right click to fetch file or line +* selecting text should set PRIMARY x11 selection Straight-up Bugs: * ctrl+space selects too large of a word in some cases (function names followed by paren) -* tab inserts dont coalesce like one would expect * off by one error on scrolling up with wrapped lines * Ctrl+u with a selection clears to bol *before* selected text -* clipboard does not persist after exit +* tab inserts dont coalesce like one would expect The Future: -* Run commands in the background and don't block the main thread. * shortcut to repeat previous operation * add command line flags to toggle options (Tabs, Indent, etc..) * add command env vars to set options (Tabs, Indent, etc..) diff --git a/edit b/edit index b4b53dd..5fadad7 100755 --- a/edit +++ b/edit @@ -1,5 +1,29 @@ #!/bin/sh +# search for a ctags file recursively up the directory tree from the file to be +# opened. If one is found, change the working directory of the new process to +# the containing folder and launch xedit with the path of the file relative to +# the new working directory. +edit_relative_ctags(){ + file="$(realpath -m "$1")" + path="$(basename "$file")" + dir="$(dirname "$file")" + while [ "$dir" != "/" ]; do + if [ -f "$dir/tags" ]; then + cd "$dir" + (nohup xedit "$path" > /dev/null 2>&1) & + #echo "cd to $dir" >2 + #cd "$dir" + #echo "$path" + return 0 + else + path="$(basename "$dir")/$path" + dir="$(dirname "$dir")" + fi + done + (nohup xedit "$1" > /dev/null 2>&1) & +} + # Add the editing tools directory to your PATH var so its contents may be used # while editing. export PATH="$HOME/.config/edit/tools:$PATH" @@ -25,6 +49,6 @@ elif [ 0 -eq $# ]; then (nohup xedit > /dev/null 2>&1) & else for f in "$@"; do - (nohup xedit "$f" > /dev/null 2>&1) & + edit_relative_ctags "$f" & done fi