From 0202f6b5e25cfd00f74e1336532e91b381050b28 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Mon, 8 Oct 2018 23:03:48 -0400 Subject: [PATCH] update tfetch to fix commands, also added flag for specifying line number --- tfetch | 20 +++++++++----------- tide.c | 2 +- topen | 3 +++ 3 files changed, 13 insertions(+), 12 deletions(-) create mode 100755 topen diff --git a/tfetch b/tfetch index cf78951..48b4176 100755 --- a/tfetch +++ b/tfetch @@ -57,11 +57,9 @@ def unset(var) end def exec(cmd) - require 'pp' - pp expand(cmd) - #if not system(expand(cmd)) then - # raise "command failed" - #end + if not system(expand(cmd)) then + raise "command failed" + end end def launch(cmd) @@ -86,14 +84,14 @@ rule do matches "data", "\\.[ch]$" is_dir "Code" exec "[[ $$(find Code -type f -name '*$data') ]]" - launch "find Code -type f -name '*$data' | xargs -r $EDITOR" + launch "find . -type f -name '*$data' -exec '$EDITOR' '{}' \;" end # Match URLS and open them with the browser rule do is_set "BROWSER" matches "data", "^(https?|ftp)://.*" - launch "$BROWSER $0" + launch "'$BROWSER' '$0'" end # Open files with addresses in the editor @@ -101,7 +99,7 @@ rule do is_set "EDITOR" matches "data", "^([^:]+):([0-9]+)" is_file "$1" - launch "tctl $0" + launch "tctl '$0'" end # If it's an existing text file, open it with editor @@ -109,7 +107,7 @@ rule do is_set "EDITOR" is_file "$data" exec "file --mime '$file' | grep -q 'text/'" - launch "$EDITOR $file" + launch "'$EDITOR' '$file'" end # Look it up in ctags database @@ -117,13 +115,13 @@ rule do is_set "EDITOR" is_file "tags" exec "grep -q '^$data\\s\\+' tags" - launch "picktag fetch tags $data | xargs -r tide" + launch "topen \"$$(picktag fetch tags '$data')\"" end # If it's an existing directory, open it with system default rule do is_dir "$data" - launch "open $data" + launch "open '$data'" end exit 1 #if we made it here then no rules matched diff --git a/tide.c b/tide.c index b6721ec..32b58af 100644 --- a/tide.c +++ b/tide.c @@ -498,7 +498,7 @@ int main(int argc, char** argv) { char* path = realpath(*argv, NULL); if (!path) path = *argv; /* if file doesnt exist, use the original name */ view_init(win_view(EDIT), path); - view_setln(win_view(EDIT), line_num); + if (line_num) view_setln(win_view(EDIT), line_num); win_title(path); win_prop_set("TIDE_FILE", "file", path); } else { diff --git a/topen b/topen new file mode 100755 index 0000000..f7f82a1 --- /dev/null +++ b/topen @@ -0,0 +1,3 @@ +#!/bin/sh +file="$1" +[ -f "$1" ] && tide "$1" \ No newline at end of file -- 2.52.0