<UPDATE> prompted by a reaction in the chatterbox

If you get upset by things like seeing the company name "Microsoft" rendered in various creative / implicitly critical ways, please stop reading now; I don't want to inadvertantly help you even to a tiny degree with this code! Making even one of your days a tiny bit easier might distract you from the important recognition that you've got far worse problems than doskey macros to deal with (problems of an cognitive sort), and it would thus be uncompassionate of me. Shoo.

</UPDATE>

I was just looking at how impoverished* my Windo$e CMD.exe prompt seemed (I go months without using one, but building Perl under Win32(native) a little while ago made me get re-acquainted with it). I decided to pull together a few doskey macros that could be loaded into a CMD session at any point (by running a batch *.cmd file). Here they are.

* compared with my Cygwin shell

@ECHO OFF rem ark * We have to get perl into our path so this tries to make sur +e rem * that it will be. Tested *only* on Windows XP. Most users mi +ght rem * just as well remove this if they are sure Perl is always in + PATH. @PATH | findstr /R /I /O "perl[^\\]*\\bin" >NUL @if ERRORLEVEL 1 ( REM EMBER TO adjust this for the path to perl.EXE on your system. set PATH=c:\ADDITI~1\win32perl\bin;%PATH% ) rem desc * a better dir command that outputs what we expect such a com +mand rem * to do, w/o the leading and trailing junk. doskey udir=perl -le "$ad=pop(@ARGV);$ad=q[.] unless $ad;@zult=(grep{$ +_ and not /\A\s/}grep[chomp],`cmd /c dir $ad /N/Q/TW`);for((grep subs +tr($_,24,5) eq q[<DIR>],@zult),(grep substr($_,24,5) ne q[<DIR>],@zul +t)){s{\s\s[[:upper:]]+\\}{};print}" $* doskey uloc=perl -MFile::Find=find -MEnv=@PATH -wle "$ARGV[0]=qw[ $* ] +;die q[An argument is required! Aborting.] unless $ARGV[0];print qq/L +ooking for $ARGV[0]/;@lf=$ARGV[0];push @lf,qq|$ARGV[0].exe| unless $A +RGV[0]=~/\.exe$/i; find(sub{$ef=$_;return unless grep{$ef eq $_ or /\ +A\Q$ef\E\z/i}@lf;$ff=$File::Find::name;$ff=~y:/:\\:;print $ff and exi +t 0},@PATH); print q[None found.]" doskey pmquery=perl -le "do{$modn=$_;s!::!/!g;$_.=q[.pm];print qq[$mod +n is not installed.\n] and next if !(eval{require \"$_\";1} and !$@); +$modv=defined(${$modn.q[::VERSION]}) ?${$modn.q[::VERSION]}:q{[versio +n undefined]};$numtyp=(2>$modv=~tr/.//) ?'%%s':'%% 6d';printf qq[ %% +-*s $numtyp in %%s\n],(length>30 ? 5+length:15+length),$modn,$modv,$I +NC{$_}}for @ARGV;" $* doskey perlv=perl -le "printf qq[%%vd$/]=> $^V" doskey checkpath=perl -MEnv=@PATH -le "print for map {-d $_ ? lcfirst( +$_):qq[$_ ** DOES NOT EXIST **]}@PATH" doskey checkperlinc=perl -le "print for map {-d $_ ? lcfirst($_):qq[$_ + ** DOES NOT EXIST **]}@INC" doskey checktempdirs=perl -e "print for map {sprintf(q[%%-6s is %%s].q +q[\n], $_, ($ENV{$_} || 'not defined in env'))}qw(TEMP TMP TMPDIR)"

Note that as Windo$e CMD shell has no concept of "continuing a single command over multiple lines by escaping the line-endings (with "\"), these doskey definitions must be single lines, no matter how they end up looking on your screen (in a browser or editor). Cleaning them up is the reader's responsibility.

    Soren A / somian / perlspinr / Intrepid


In reply to Re: Private Utilities by Intrepid
in thread Private Utilities by Ovid

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.