| Age | Commit message (Collapse) | Author | Files | Lines |
|
Despite how useful realpath is, apparently it's not POSIX and isn't
part of the BSD userland.
|
|
We still don't handle filenames that contain newlines, but we're
pressing against the limits of what portable POSIX shell can do. Besides
which, we're ultimately plumbing filenames into vis-menu which uses
newlines as a delimiter *anyway*, so there's not much we can do.
|
|
|
|
|
|
Rather than try to loop manually and build up a path, this new version
exec's itself for each new directory scanned. Functional changes
include:
- We `set -e` at the top of the script, so any surprising
permission-denied errors will automatically cause the script to exit
with a helpful error message.
- We now support the GNU "--" convention for splitting options from
filename arguments, just in case somebody happens across a directory
with a file named "-h" or "-p".
- If launched with a single filename parameter, we automatically return
it - if somebody writes ":e somepattern*" and it matches exactly one
file, we might as well open it directly.
- If we select a single filename parameter, we use `realpath` to build
an absolute path for it - much more reliable than trying to build up
a path while the user is navigating around.
- If launched with a single directory parameter, we change into that
directory and re-exec ourselves with ".." and all the files in that
directory as arguments. This means we don't have to handle selection
and recursion at the same time.
- Note that if we recurse into a directory, we pass the "-f" parameter
to suppress auto-selection - otherwise recursing into an empty
directory would immediately select the ".." entry and pop you back
out, which would be confusing.
- The new version doesn't bother trying to manipulate `$VIS_MENU_ARGS`
and sometimes add a prompt to it. Setting no prompt is the same as
setting the prompt to an empty string, so we can just use an empty
string as the default value.
One specific use-case that this change cleans up is giving ":e"
a pattern that matches multiple directories (for example, running
":e *e*" in the root of the vis repo). "ls -1" would list the contents
of each directory (without a prefix, so you couldn't select those files)
but would also print the directory names as headings followed by
a colon, so you couldn't usefully select the directory names either.
We get around this by only ever running "ls -1" without any arguments,
so it only scans the current directory.
|
|
|
|
This serves as a wrapper around dmenu(1) and slmenu(1), by default
the latter is preferred because it also works without an X server.
The program and its default arguments can be configured by means of
the $VIS_MENU and $VIS_MENU_ARGS environment variables.
Eventually we might decide to inlcude a stripped down version of
slmenu in the vis source tree.
|
|
|
|
It was hard to read with everything on the same indentation level.
|
|
|
|
If vis-open is placed in a user's PATH and executed then $0 will be
vis-open's absolute path:
$ vis-open -h
usage: /usr/local/bin/vis-open [-h] [-p prompt] [file-pattern]
This isn't very pretty, so use basename(1) on $0:
$ vis-open -h
usage: vis-open [-h] [-p prompt] [file-pattern]
|
|
|
|
For this to work make sure you have vis-open and slmenu or dmenu
somewhere in $PATH.
For now the file dialog is shown for :open, :split and :vsplit
when the argument is either . (a dot) or looks like a file pattern.
For example
:open *.[ch]
will show a listing of all C source and header files in the current
directory. Use a fuzzy search to make your choice.
|