vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit 6ee2f7900e73666503c8d4bd9cd49a5467e357b9 parent 750526a24727adcc0ba333d3d748f7817f276047 Author: Marc André Tanner <mat@brain-dump.org> Date: Mon, 23 Nov 2015 12:45:23 +0100 vis: use file open dialog for all directories Diffstat:
| M | vis-cmds.c | | | 8 | ++++++-- |
| M | vis-open | | | 1 | + |
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/vis-cmds.c b/vis-cmds.c @@ -344,8 +344,12 @@ static bool cmd_set(Vis *vis, Filerange *range, enum CmdOpt cmdopt, const char * } static bool is_file_pattern(const char *pattern) { - return pattern && (strcmp(pattern, ".") == 0 || strchr(pattern, '*') || - strchr(pattern, '[') || strchr(pattern, '{')); + if (!pattern) + return false; + struct stat meta; + if (stat(pattern, &meta) == 0 && S_ISDIR(meta.st_mode)) + return true; + return strchr(pattern, '*') || strchr(pattern, '[') || strchr(pattern, '{'); } static const char *file_open_dialog(Vis *vis, const char *pattern) { diff --git a/vis-open b/vis-open @@ -32,6 +32,7 @@ if ! type "$VIS_MENU" >/dev/null 2>&1; then fi DIR="" +[ ! -z "$PATTERN" -a "$PATTERN" != "." -a -d "$PATTERN" ] && DIR="$PATTERN" while true; do SEL=$({ echo ..; ls -1 $PATTERN; } | $VIS_MENU $VIS_MENU_ARGS)