aboutsummaryrefslogtreecommitdiff
path: root/vis-open
AgeCommit message (Collapse)AuthorFilesLines
2016-05-28[vis-open] Don't use realpath(1).Tim Allen1-1/+2
Despite how useful realpath is, apparently it's not POSIX and isn't part of the BSD userland.
2016-05-28[vis-open] Handle filenames with spaces and tabs.Tim Allen1-0/+5
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.
2016-05-28[vis-open] Actually use '--' where it's useful.Tim Allen1-1/+1
2016-05-28[vis-open] Fix '--' to actually work.Tim Allen1-0/+1
2016-05-28Rewrite vis-open to be more robust.Tim Allen1-16/+35
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.
2016-05-22vis: always start vis-menu with -b flagMarc André Tanner1-1/+1
2016-05-16vis: introduce vis-menu helper scriptMarc André Tanner1-12/+2
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.
2016-04-15vis: improve handling of ~ and environment variables when opening filesMarc André Tanner1-1/+1
2016-01-09vis-open: Fix indentationMichael Reed1-3/+3
It was hard to read with everything on the same indentation level.
2016-01-09vis-open: Print error message to stderrMichael Reed1-1/+1
2016-01-09vis-open: Use basename of $0 in usage messageMichael Reed1-1/+1
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]
2015-11-23vis: use file open dialog for all directoriesMarc André Tanner1-0/+1
2015-07-10vis: add a file open dialogMarc André Tanner1-0/+47
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.