-
Notifications
You must be signed in to change notification settings - Fork 0
withsome - with some file name run a command on matching nearby files
License
ronaldxs/withsome
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
NAME withsome - with some file name run a command on matching nearby files Version 0.19 SYNOPSIS withsome [*DIRECTORY*] *COMMAND* *FILE* [*FILE*] ... withsome [*DIRECTORY*] *COMMAND* *Perl::Module* [*FILE*] ... withsome [*DIRECTORY*] *FILE* [*FILE*] ... *-* *COMMAND* [*OPTION*] ... DESCRIPTION Find all files with a provided name or glob under one or more directories and allow a user to run a command against any matching instances of the name, or glob, through interactive menus and prompts. A little similar to zsh recursive wildcards or a combination of find, xargs (and maybe select) but designed to be friendlier, safer, and provide better user interaction than either and works with bash. If a menu of matching files needs to presented for file selection the files will be sorted to present paths with the fewest elements first and then sort paths of identical length in elements alphabetically. See examples below. EXAMPLES Example 1: case of one file matching on explicit root withsome ~/pugs view eval.pl view /home/ron/pugs/examples/eval.pl - Empty reply accepts, anything else aborts (help for explanation)? (pressing enter runs view on /home/someone/pugs/examples/eval.pl) Example 2: case of a few files matching on explicit root withsome ~/pugs vi Pugs.pm 1) /home/ron/pugs/lib/Inline/Pugs.pm 2) /home/ron/pugs/lib/Perl6/Pugs.pm 3) /home/ron/pugs/blib/lib/Inline/Pugs.pm 4) /home/ron/pugs/blib/lib/Perl6/Pugs.pm 5) /home/ron/pugs/inc/Module/Install/Pugs.pm A) * All of the above Indicate your selection(s) from the above or 0 for none (default 1): 1 4 ( giving 1 and 4 as inputs and pressing enter runs vi on: /home/ron/pugs/lib/Inline/Pugs.pm /home/ron/pugs/blib/lib/Perl6/Pugs.pm ) Example 3: case of one file matching and pre-configured root withsome wc eval.pl wc /home/ron/pugs/examples/eval.pl - Empty reply accepts, anything else aborts (help for explanation)? 83 269 2016 /home/ron/pugs/examples/eval.pl Example omitted for brevity: analogous case of a few matching files and pre-configured root Example 4: search for Perl(ish) module withsome ~/pugs vi Inline::Pugs 1) ../t/testdata/pugs/lib/Inline/Pugs.pm 2) ../t/testdata/pugs/blib/lib/Inline/Pugs.pm A) * All of the above Indicate your selection(s) from the above or 0 for none (default 1): Example 5: case of a few files matching on explicit root with hyphen (-) prefix option(s) withsome ~/pugs Pugs.pm - wc -l 1) /home/ron/pugs/lib/Inline/Pugs.pm 2) /home/ron/pugs/lib/Perl6/Pugs.pm 3) /home/ron/pugs/blib/lib/Inline/Pugs.pm 4) /home/ron/pugs/blib/lib/Perl6/Pugs.pm 5) /home/ron/pugs/inc/Module/Install/Pugs.pm A) * All of the above Indicate your selection(s) from the above or 0 for none (default 1): 1 4 125 /home/ron/pugs/lib/Inline/Pugs.pm 100 /home/ron/pugs/blib/lib/Perl6/Pugs.pm 225 total Configuration The withsome utility has configuration options that can be controlled through environment variables as listed below. The variables can also be set in a .withsome-rc file in your home directory. Note that if you have the dialog/cdialog package installed, the command "withsome --config" will allow you to configure the environment options in the .withsome-rc file through interactive dialogs and menus. WS_FIND_ROOT Root of search path for file names and globs. May also be colon separated list of such search path roots. WS_IGNORE Colon separated list of prune directory or other file system names to be used as prune arguments to find. WS_FOLLOW Configures following or pruning through directories that represent links or mount points. The default is to follow neither. The value settings of link/links, mount points, and all respectively instruct withsome to follow links, mount points or both in its finds/searches. WS_SAFE_CMD Colon separated list of commands that can be run without prior prompting when exactly one match is found. Commands like ls and wc make good candidates. WS_FORBIDDEN_CMD Colon separated list of commands that should never be run from withsome. The rm command might be a good candidate here. Note that basename matching is used here so that precluding rm will also preclude /bin/rm/ and /usr/bin/rm. CAVEATS This is alpha software - use at your own risk. REQUIREMENTS A reasonably recent (>2.X) version of bash and nearly any perl. The perl requirement might be lifted at some point. INSTALLATION See INSTALL file. COPYRIGHT and Licensing. See LICENSE file.
About
withsome - with some file name run a command on matching nearby files
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published