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)
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
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
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
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
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 {