Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • December 09, 2016, 01:38:16 AM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: N.A.N.Y 2013 Submission - CommandPromptHere for FARR  (Read 11645 times)

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
N.A.N.Y 2013 Submission - CommandPromptHere for FARR
« on: December 07, 2012, 05:45:55 AM »
A FARR plugin to provide "Command Prompt Here"-like behavior for FARR file / folder results.



Screenshot

cph-no-submenu.pngN.A.N.Y 2013 Submission - CommandPromptHere for FARR

cph-with-statusbar-icon-menu.pngN.A.N.Y 2013 Submission - CommandPromptHere for FARR



Description

Command prompt access from FARR results -- for files, the containing directory is used as the working directory.

A variety of "command prompts" are supported (though see README.txt for configuration info):

  • cmd.exe
  • ConEmu
  • Cygwin Bash
  • Cygwin Zsh
  • MSYS Bash
  • msysGit Bash
  • NYAOS3
  • PowerShell
  • TCC (or TCC/LE)



Installation / Uninstallation / Requirements

It's a FARR plugin so installation and uninstallation are as usual.  Tested under Windows 7 64-bit with FARR 2.206.01.  Brief testing done on Windows XP Pro SP3.  May work for other versions of Windows.



Upgrading

If upgrading from an earlier version (0.0.0.2 or below), it may be easiest to start over.  The settings are likely compatible, but the arrangement of files in the plugin's directory differ.  I recommend copying the old plugin directory somewhere safe first before trying a newer version.



Downloads

Plugin

md5:526e1c4312173d8bc37cf992464d774c
sha1:6d1b55ab42a136e3a7179db2c217c9234066118a



README.txt
CommandPromptHere

Purpose:

  Convenient access to a command prompt with the current directory set
  to match a FARR result:

    - for a folder result, the current directory corresponds to the
      folder

    - for a file result, the current directory corresponds to the
      containing folder

Requirements:

  Tested with:

    - Windows 7 - may work for other versions of Windows (some XP
      testing has been done too)

    - FindAndRunRobot 2.206.01 - some portion may not work with
      earlier versions of FARR

Basic Usage:

  1. Bring up a context-sensitive menu for a file or folder in FARR's
     result view.

  2. Choose "Command Prompt Here".

  A command prompt window with an appropriate working directory should
  appear.

Other Command Prompts:

  It's possible to configure the plugin to work with other "command
  prompts" (see the Notes section for details).

  Once configured appropriately:

  1. Bring up a context-sensitive menu for a file or folder in FARR's
     result view.

  2. With appropriate configuration, at least one of the following
     should appear.  Choose one.

       - ConEmu Prompt Here
       - Cygwin Bash Prompt Here
       - Cygwin Zsh Prompt Here
       - MSYS Bash Prompt Here
       - msysGit Bash Prompt Here
       - NYAOS3 Prompt Here
       - PowerShell Prompt Here
       - TCC Prompt Here

  A command prompt window of the corresponding program with an
  appropriate working directory should appear.

Statusbar Icon Menu:

  The plugin provides a statusbar icon in FARR's main window.  Clicking
  this should bring up a menu that may contain some of the following
  items:

    Command Prompt at...
    Set Preferred to...
    Configure
    Help

  "Command Prompt at..." allows one to open a command prompt at
  a directory which the plugin previously worked with.  (This menu
  item may not appear if there are no such directories.)

  "Set Preferred to..." allows one to choose the specific command
  prompt type (e.g. ConEmu) to use for "Command Prompt at...".
  (This menu item may not appear if there is only one command prompt
  available for use.)

  "Configure" displays a list of FARR results, each of which may be
  invoked to configure some functionality of the plugin.

  "Help" displays this file.

Notes:

  1. To bring up a context-sensitive menu for a FARR result, do one of
     the following:

      - Right-click on the result

      - After selecting the result, type one of the following:

          - Control+R
          - Shift+F10
          - Menu / Application key

  2. To enable support for a particular command prompt:

     Method 1: Via a FARR Result

       - Locate the executable using FARR (e.g. c:\cygwin\bin\bash.exe),

       - Bring up the context-sensitive menu via the result
         corresponding to the executable and choose the appropriate
         menu item beginning with "Set as" (e.g. Set as Cygwin Bash).

     Method 2: Via the Plugin's Statusbar Icon

       There should be a statusbar icon for the plugin on the statusbar
       of FARR's main window.

       - Click the plugin's statusbar icon.

       A menu should appear.

       - Choose "Configure".

       A list of FARR results should appear.  Each one corresponds to
       configuring the plugin in some way.  An example result might be
       labeled: "Configure msysGit Bash Path".

       - Select an appropriate result and launch it.

       FARR should switch to a web view with a form for appropriately
       configuring the selected choice.  An example label might be:
       "CommandPromptHere.msysGitBashExe".  An appropriate value might
       be: c:\apps\msysgit\bin\bash.exe

       - Enter an appropriate value in the form field and click the
         button labeled "update".

       - Dismiss FARR or go back to using it as usual.

     Method 3: Via FARR User Variables

     Alternatively, manually create an appropriate FARR User Variable
     with an appropriate value.  For example, for Cygwin Bash, one
     configuration might be:

       [CommandPromptHere]
       CygwinBashExe = c:\cygwin\bin\bash.exe

     The following lists names of FARR User Variables for specifying
     "command prompt" executables:

       ConEmuExe
       CygwinBashExe
       CygwinZshExe
       MSYSBashExe
       msysGitBashExe
       NYAOS3Exe
       PowerShellExe
       TCCExe

  3. It's possible to configure the plugin to use a submenu to display
     menu items for each command prompt if there are two or more
     usable command prompts.  The following is an example
     configuration:

       [CommandPromptHere]
       UseSubmenu = 1

     Note: if the submenu mode is used, the names of some of the menu
     items may differ from the earlier descriptions.

  4. Adding support for other command prompts may be possible.

     Apart from a few exceptions, support for each command prompt is
     provided via a corresponding .js file in the plugins subdirectory
     of the CommandPromptHere plugin directory and an appropriate
     addition to the CommandPromptHere.alias file.

Credits:

  Find And Run Robot

    mouser

  FScript

    ecaradec

  Discussion and Testing

    cranioscopical
    mouser
    oumu

  Icons

    https://www.fatcow.com/free-icons

« Last Edit: January 21, 2013, 03:36:15 AM by ewemoa »

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 36,421
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: N.A.N.Y 2013 Submission - CommandPromptHere for FARR
« Reply #1 on: December 07, 2012, 10:27:10 AM »
Great, works well here  :up:

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: N.A.N.Y 2013 Submission - CommandPromptHere for FARR
« Reply #2 on: December 07, 2012, 05:45:09 PM »
Thanks for the testing :)

cranioscopical

  • Friend of the Site
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,368
    • View Profile
    • Donate to Member
Re: N.A.N.Y 2013 Submission - CommandPromptHere for FARR
« Reply #3 on: December 08, 2012, 02:13:20 AM »
Thanks for the plug-in — flawless on W7-64.  :Thmbsup:

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: N.A.N.Y 2013 Submission - CommandPromptHere for FARR
« Reply #4 on: December 08, 2012, 02:55:21 AM »
Thanks for testing!

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: N.A.N.Y 2013 Submission - CommandPromptHere for FARR
« Reply #5 on: December 08, 2012, 04:47:20 AM »
There's what appears to be support for a Cygwin bash prompt in the local version now :)

Willing to investigate other analogous things.

cranioscopical

  • Friend of the Site
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,368
    • View Profile
    • Donate to Member
Re: N.A.N.Y 2013 Submission - CommandPromptHere for FARR
« Reply #6 on: December 08, 2012, 03:30:53 PM »
And, for peculiar reasons of my own, I set a system environment variable that points to my favourite command processor. Then I substituted that variable for %ComSpec% in the script. That lets me keep the native processor as default but have CommandLineHere call that which I prefer.

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: N.A.N.Y 2013 Submission - CommandPromptHere for FARR
« Reply #7 on: December 08, 2012, 10:18:58 PM »
I've uploaded an experimental version (see first post for link to archive) that contains support for Cygwin's bash:

CygwinPromptHereToo.pngN.A.N.Y 2013 Submission - CommandPromptHere for FARR

If Cygwin is installed in its default location of C:\cygwin, the plugin should detect Cygwin and the "Cygwin Prompt Here" should work without configuration.

If Cygwin is installed in a different location, this can be specified to the plugin by setting an appropriate FARR User Variable.

To specify a non-default installation location for Cygwin, in FARR's User Variable options, ensure there is something analogous to:

  [CommandPromptHere]
  Cygwin = C:\apps\cygwin

Where the value represents the directory Cygwin is installed in.

Relative paths ought to work as well.  The following worked in one environment:

  [CommandPromptHere]
  Cygwin = ..\cygwin

Note that the path is relative to the directory that the FindAndRunRobot.exe executable lives in.


Update: Autodetection is not done any more.  See the README.txt for updated configuration instructions.
« Last Edit: December 30, 2012, 09:28:16 PM by ewemoa »

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: N.A.N.Y 2013 Submission - CommandPromptHere for FARR
« Reply #8 on: December 10, 2012, 04:29:01 AM »
Uploaded a new experimental version (see first post for link).

This version has support for:

  • cmd.exe
  • Cygwin's bash
  • ConEmu
  • TCC (or TCC/LE)

VariousPromptHeres.pngN.A.N.Y 2013 Submission - CommandPromptHere for FARR

Quote from: from README.txt
     To enable support for ConEmu, specify a path to ConEmu.exe (or
     ConEmu64.exe if appropriate) via FARR's User Variable options.
     The following is a typical examples:

       [CommandPromptHere]
       ConEmuExe = C:\apps\ConEmu\ConEmu.exe

     To enable support for TCC (or TCC/LE), specify a path to tcc.exe via
     FARR's User Variable options. The following is a typical example:

       [CommandPromptHere]
       TCCExe = C:\apps\TCC\tcc.exe

Thanks to cranioscopical and mouser for discussion and testing :)

cranioscopical

  • Friend of the Site
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,368
    • View Profile
    • Donate to Member
Re: N.A.N.Y 2013 Submission - CommandPromptHere for FARR
« Reply #9 on: December 10, 2012, 03:53:46 PM »
Nicely done. Works a treat here  :Thmbsup:

It's good to see this working in conjunction with FARR, gives it a nice DC feel.

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: N.A.N.Y 2013 Submission - CommandPromptHere for FARR
« Reply #10 on: December 10, 2012, 09:26:59 PM »
Thanks for the kind words, testing, and reporting back :)

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: N.A.N.Y 2013 Submission - CommandPromptHere for FARR
« Reply #11 on: December 11, 2012, 12:34:00 AM »
In the pipeline:

  • PowerShell support
  • Option to display menu items in submenu if there are two or more menu items
  • Move the non-cmd.exe code to external files

I think the last change should make it easier (and safer) to support additional command prompts.

To add support for another command prompt, one would create an appropriate .js file in the lib subdirectory.  The .js files in lib should get loaded when the plugin is initialized.  The last thing each .js file needs to do is evaluate to an appropriate function value.  The function should take one argument (representing the full-path of the currently selected item in FARR) and build an appropriate menu item string.

Update: What is below is obsolete -- the current mechanism is a bit different.  See source or please ask for details :)

Below is what I currently have for lib\PowerShell.js:

Code: Javascript [Select]
  1. (function () {
  2.   return function (path) {
  3.     var launchstr, menuitemstr,
  4.         cpname, psmodulepath, psexepath;
  5.     cpname = "PowerShell";
  6.     //
  7.     menuitemstr = "";
  8.     psmodulepath = FARR.getStrValue("resolve:%PSModulePath%");
  9.     if (psmodulepath !== "") {
  10.       psexepath = psmodulepath.replace("Modules\\", "powershell.exe");
  11.       if (!pu.fso.FileExists(psexepath)) {
  12.         return "";
  13.       }
  14.       /*
  15.          thanks to:
  16.            http://brianreiter.org/2010/08/11/ \
  17.              command-prompt-and-powershell-here-with-console-exe/
  18.        */
  19.       launchstr = psexepath +
  20.                   " -NoExit" +
  21.                   " -Command Set-Location" +
  22.                   " -LiteralPath " +
  23.                   "'" + path + "\\" + "'"; // extra backslash for drive
  24.       menuitemstr =
  25.         buildMenuItemString({caption: prepareCaptionText(cpname),
  26.                              hint: prepareHintText(cpname, path),
  27.                              icon: psexepath,
  28.                              launch: launchstr});
  29.     }
  30.     return menuitemstr;
  31.   };
  32. } ());
« Last Edit: December 30, 2012, 09:28:54 PM by ewemoa »

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: N.A.N.Y 2013 Submission - CommandPromptHere for FARR
« Reply #12 on: December 12, 2012, 02:02:32 AM »
New version uploaded as the only current release -- initial post updated to reflect changes.

In addition to changes mentioned before, there is now support for Cygwin's Zsh (if installed) and NYAOS3.

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: N.A.N.Y 2013 Submission - CommandPromptHere for FARR
« Reply #13 on: December 12, 2012, 07:45:42 AM »
Added support for msysGit's Bash.

See the first post for a link to an archive.

To install:

1. Unzip the archive's content (2 files) to the plugin's lib subfolder.

2. Create an appropriate FARR User Variable like:


[CommandPromptHere]
msysGit = C:\apps\msysgit

Note that the path is to where msysGit is installed -- not the path of Bash.

3. Restart FARR (or use either of the rplugins or goreload FARR commands).


Update: Comes bundled now.
« Last Edit: December 30, 2012, 09:21:45 PM by ewemoa »

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: N.A.N.Y 2013 Submission - CommandPromptHere for FARR
« Reply #14 on: December 21, 2012, 01:39:56 AM »
For fun, have implemented something like Firefox's about:config:

1. Enumerating variables:
1. start-config.pngN.A.N.Y 2013 Submission - CommandPromptHere for FARR

2. Filtering candidates:
2. filter.pngN.A.N.Y 2013 Submission - CommandPromptHere for FARR

3. Editing a value:
3. edit.pngN.A.N.Y 2013 Submission - CommandPromptHere for FARR

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: N.A.N.Y 2013 Submission - CommandPromptHere for FARR
« Reply #15 on: December 30, 2012, 09:20:42 PM »
New version uploaded.

First post has been updated to reflect changes and posts with instructions in this thread have also been updated.
« Last Edit: December 30, 2012, 09:29:59 PM by ewemoa »

oumu

  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 5
    • View Profile
    • Donate to Member
Re: N.A.N.Y 2013 Submission - CommandPromptHere for FARR
« Reply #16 on: January 11, 2013, 07:17:31 PM »
Great works! BTW, can you add some one-letter shortcuts to the command prompt entry, the same as other menu entries, so that we can open a cmd without clicking?

screenshot-20130112-001.png

Thanks!

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: N.A.N.Y 2013 Submission - CommandPromptHere for FARR
« Reply #17 on: January 13, 2013, 12:44:42 AM »
I didn't think it would be doable, but I just tried an experiment and it looks like something might be possible.  Will investigate further.

In the mean time, this is probably less than ideal, but I believe tapping on the down arrow key an appropriate number of times might be a luke-warm work-around.

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: N.A.N.Y 2013 Submission - CommandPromptHere for FARR
« Reply #18 on: January 13, 2013, 12:55:12 AM »
Uploaded a new version which includes support for a history of paths.

See README.txt for more details -- in first post or included in plugin.



Hope to have some good news regarding the suggestion from oumu.

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: N.A.N.Y 2013 Submission - CommandPromptHere for FARR
« Reply #19 on: January 13, 2013, 02:19:45 AM »
BTW, can you add some one-letter shortcuts to the command prompt entry, the same as other menu entries, so that we can open a cmd without clicking?

From your screenshot it looks like you're using the submenu functionality.  A quick hack that might improve upon the arrow key work-around mentioned earlier is:

1. Update to version 0.0.0.4 of the plugin
2. Find the function named augmentContextMenuForPath in the file lib/optv2.js
3. Change the code:

Code: Javascript [Select]
  1. pu.buildSubmenuStartString({caption: "Prompt Here...",

to:

Code: Javascript [Select]
  1. pu.buildSubmenuStartString({caption: "Prompt &Here...",

The effect of this should be to make the submenu accessible via typing the H key (assuming the context menu for the result is already displayed).



So once the submenu is brought up using the H key, one of the following should invoke the desired command prompt:

Case 1:

The desired submenu item starts with a letter which no other submenu item starts with.  In this case, just typing the first letter in the desired submenu item should invoke the appropriate submenu item.

Case 2:

The desired submenu item starts with a letter which at least one other submenu item also starts with.  In this case, type the first letter the appropriate number of times until the desired submenu item is highlighted.  Then press Enter to invoke the submenu item.

IIUC, the behavior described above in cases 1 and 2 is pretty common in Windows.



Do you think this is good enough?  If not, do you have an alternate suggestion?

I know the idea above is not ideal for the case of not using the submenu, so I'd like to come up with a better idea.

oumu

  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 5
    • View Profile
    • Donate to Member
Re: N.A.N.Y 2013 Submission - CommandPromptHere for FARR
« Reply #20 on: January 16, 2013, 08:20:11 PM »
Works like a charm. Thanks!

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: N.A.N.Y 2013 Submission - CommandPromptHere for FARR
« Reply #21 on: January 21, 2013, 03:37:52 AM »
Thanks for reporting back :)



Uploaded a new version containing the keyboard accelerator along with restructuring of the code.