option(s)
withsome - with some file name run a command on matching nearby files
withsome [DIRECTORY] COMMAND FILE [FILE] ...
withsome [DIRECTORY] FILE [FILE] ... - COMMAND [OPTION] ...
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.
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)
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 )
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
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
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.
Root of search path for file names and globs. May also be colon separated list of such search path roots.
Colon separated list of prune directory or other file system names to be used as prune arguments to find.
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.
Colon separated list of commands that can be run without prior prompting. Commands like ls and wc make good candidates.
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.
This is alpha software - use at your own risk.
A reasonably recent (>2.X) version of bash and nearly any perl. The perl requirement might be lifted at some point.
To install this script just place the entire content of the bin directory, including the withsome-util subdirectory and its files, on your path. Either modify your path with something like:
export PATH=$PATH:~/withsome/bin
or copy the content with a command like
cp -r /home/my_account_home/withsome/bin/* /usr/local/something_on_my_path/
That's it!
Don't forget to run the included tests BEFORE installing. Just cd to the t/ directory and run ./t.sh. The last two tests have many requirements, including sudo, as well as pre-requisites so don't worry if those two don't run.
Copyright (C) 2007 Ronald Schmidt
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.