Tag Archives: far-manager

Far Manager

Calling PureJPEG and PngCrush from Far Manager

I like to keep images that I upload to blog and websites small and free of metadata (EXIF etc). PureJPEG and PngCrush are two tools that help me to reduce image file size without affecting quality.

I invoke them from Far Manager using F2 user menu:

Far Manager user menu

Here’s how to configure it:

  1. Press F2 to open user menu.
  2. Press Insert key. Select ‘Insert Command’.
  3. Enter ‘j’ as hotkey, ‘PureJpeg’ as label and the following as command:
    “C:\Small Programs\PureJpeg\purejpeg.exe” “!.!”
  4. Press OK to save
Far Manager command to invoke PureJPEG

Far Manager replaces “!.!” with selected file name in double quotes.

I keep small apps and tools in ‘Small Programs’ folder. You might have them somewhere else.

Follow the same procedure for PNG Crush. Use this command:

"C:\Small Programs\Pngcrush\pngcrush.exe" -ow "!.!"

Note the -ow switch – it tells pngcrush to overwrite the source PNG file.

Now you can compress an image file losslessly by simply selecting it in Far Manager, pressing F2 and selecting PureJpeg or PngCrush.

Folder Shortcuts in Far Manager

You can quickly jump to your favorite folders in Far Manager by pressing right Control + 1, 2, 3, 4, 5 and so on.

Adding a shortcut is very simple:

  1. Go to your favorite folder in Far Manager
  2. Press Ctrl + Shift + 1 (or 2, 3, 4, 5, …)

Now you can press right Ctrl + 1 to jump to that folder.

You can view all your folder shortcuts by pressing F9 to open the top menu, then C to open Commands submenu, then D:

I have right Ctrl + 1 assigned to my temp folder, I gave it 1Temp name so that it’s always on top and also to remind me that it has 1 as shortcut. Usually I put there files and folders that I’m going to upload somewhere. I train myself to delete everything from that folder from time to time.

You can assign more than folder to a single shortcut. In this case Far Manager would show you a menu with all folders when you press that shortcut. I have folders that I use from time to time assigned to right Ctrl + 0 (zero). Typically they are so deep in the file system that it would be too long to navigate there the normal way:

Folder shortcuts menu in Far Manager

How to Start Beyond Compare from Far Manager

Beyond Compare is an excellent tool for comparing files and folders. I use it most often during software development.

My weapon of choice for file operations is Far Manager so I decided to make launching Beyond Compare fast and painless. After some experimentation I settled on creating bc.cmd in C:\Program Files\Far Manager folder:

@start "" "C:\Program Files\Beyond Compare 4\BComp.exe" %*

Note the empty string as the first argument to the start command: it wouldn’t work properly without it since the full path to BComp.exe has double quotes.

Now I can compare files from Far Manager by typing

bc file1.txt file2.txt

Usually I use Ctrl+F shortcut to insert full path to the selected file in Far Manager.

Comparing Folders

My next idea was to use some keyboard shortcut to compare Far Manager’s left and right panels. Both Far Manager and Beyond Compare have 2 panels so it’s natural to open and compare folders:

Here’s how to set it up:

  1. Press Ctrl+. to start recording a macro
  2. Type bc, then space, then press Ctrl+[ to insert path to the left folder, then space again, then Ctrl+]
  3. Press Enter. This should launch Beyond Compare. Close it and go back to Far Manager.
  4. Press Ctrl+. to stop recording the macro
  5. Press Ctrl+B to assign a hotkey:

Voila! Now you can press Ctrl+B to launch Beyond Compare and compare folders that you have open in Far Manager. Normally Ctrl+B turns on and off the key bar at the bottom of the window but I never do it. You can still turn it off by opening Options menu, then Interface settings:

Don’t forget to save settings by pressing Ctrl+F9. Happy comparing!

Command History in Far Manager

Far Manager has powerful suppport for command history. ConEmu author even suggests using Far Manager with panels turned off instead of standard command prompt.

Ctrl+E gives you previous command entered. You can press it multiple times to get older entries. Ctrl+X moves you forward in the history.

Press Alt+F8 to view command history in the list:

You can execute a command from the list by pressing Enter. If you want to edit a command press Ctrl+Enter.

All shortcuts available in command history list:

Enter Re-execute a command
Shift+Enter Re-execute a command in a new window
Ctrl+Alt+Enter Re-execute a command as administrator
Ctrl+Enter Copy a command to the command line
Del Clear the commands history
Ins Lock/unlock a history item
Shift+Del Delete the current history item
Ctrl+C or Ctrl+Ins Copy the text of the current command to clipboard

Another useful shortcut is Ctrl+Alt+F – it lets you to search in the list by filtering it down. This shortcut is totally non-obvious and not documented anywhere so I was happy when I discovered it. It also works in folder history (Alt+F12).

Far Manager and Console Output

One of the strongest features of Far Manager is the ability to start any program or script from command prompt. You can type anything there, just like in standard command prompt. Ctrl+Enter shortcut greatly helps here – it inserts selected file name to command prompt (Ctrl+F inserts full path).

If you launch a console program all program output will be displayed in Far window. Terrific! After program finishes you can view console output by pressing Ctrl+O.

There is a problem however: you can’t scroll up if program output is long. Only last 25 or so lines of text are visible. Anything before that is lost forever.

Far has a clever little known trick to view all program output. Add view:< before the command and all console output will be intercepted and redirected to internal viewer. For example:

view:<ipconfig /all

You can even redirect output to Far editor by using

edit:<ipconfig /all

This is nice but not ideal. You have to remember to add view:< before starting a console program or script. If a program takes long time to execute you won’t see any progress until it finishes. Also any interactive prompt in program screws the whole process.

ConEmu to the Rescue

ConEmu is a console emulator. It has lots of great enhancements to standard Windows command prompt. It works by intercepting all console output and displaying it in its own window.

ConEmu is also a close friend with Far Manager. After installing ConEmu you can open Far Manager inside ConEmu window:

Far Manager in ConEmu

Once Far Manager is inside ConEmu tab you can scroll console output by switching to so called alternative mode.

This mode hides Far panels and ‘freezes’ console. Ctrl+Up scrolls up, Ctrl+Down scrolls down. Scrolling with a mouse wheel also works.

But that’s not all. You can also assign Ctrl+O to view console output in Far viewer. To do this locate CtrlO_View.reg in ConEmu folder and execute it.

Link

Scott Hanselman on ConEmu

How to open HTML files with Visual Studio from Far Manager

Occasionally I want to edit plain HTML file in Visual Studio. You know, those files with .htm or .html extension. Normally pressing Enter in Far Manager opens them in a browser. This is what I want most of the time, so let’s keep it.

Idea: let’s use F4 key to open file in Visual Studio.

Here’s how to achieve it:

* Open Commands menu, select File associations.
* Add new association, enter *.htm;*.html as a mask. Enter this command for F4:

"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe" /edit "!.!"

Change path to devenv.exe if you have different version of Visual Studio.

Note the /edit parameter. It makes Visual Studio to re-use existing window if it is alredy running. Visual Studio is not exactly a lightweight editor so let’s be efficient here.

What if you want to open HTML file in internal Far editor? Simple: press Alft+F4.

Reference:

Devenv Command Line Switches

Detaching Far Manager from long-running process on Windows 7

Occasionally I launch a program from Far Manager that takes very long to complete. Normally you can use Ctrl+Alt+Tab to “detach” Far from a running process. Technical note #27 explains this well:

If a long-running process (for example, archiving) was run in a FAR console, and for some reasons this very instance of FAR is needed (an editor in the background) or it is undesirable to run a new instance ofFAR, pressing this key combination will create a new console for FAR where it will continue running as if the process has already ended, and the process will continue working in the old console.

Unfortunately this doesn’t work on Windows 7. Instead of detaching you get Windows task switcher:

Windows 7 task switcher

Interestingly the switcher is in “sticky” mode. It doesn’t disappear when you release keys. You can use arrow keys to select a window.

The fix is easy:

  1. Start regedit, open HKCU\Software\far2\System key.
  2. Create ConsoleDetachKey string value, set it to some keyboard shortcut. I use CtrlAltX.
  3. Restart Far Manager

To test it try executing this command from Far:

ping google.com -t

Press Ctrl+Alt+X to get back to Far without stopping pings.

How to safely remove USB flash drive with Far Manager

Do you have one of these:
USB flash drive
When you finish copying files from and to your USB flash drive you need to safely remove it, otherwise you risk losing data. Normally you do this by clicking icon with green arrow in system tray:

You can do the same with Far Manager. Open drive menu (Alt+F1 or Alt+F2), select your flash drive and press Shift+Del. You should get this confirmation:

Select “Remove” and you’re done. Note that the key combo (Shift+Del) is different from ejecting CD/DVD (Del).

Enhancement to launching PowerShell scripts from Far Manager

The method of launching PowerShell scripts from Far Manager I have described previously has 2 important drawbacks:

  1. You can’t pass arguments to the script, and
  2. You can’t launch script in a separate window

Here’s how to fix this:

  1. Start regedit, open HKCR\Microsoft.PowerShellScript.1\shell\Open\command key
  2. Set it to
    "C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe" "-file" "%1" %*

Now you can press Shift+Enter to start PowerShell script in a new window.

As a bonus, you can now double-click .ps1 files in Windows Explorer to launch them. Why is this not a default behaviour? Most likely Microsoft decided to be extra cautious here.

Make sure you have Powershell version 2.0 or higher for this to work. How to check Powershell version.

How to open .docx and .xlsx files from Far Manager

If you try to open Office 2007 document (.docx or .xlsx) in Far Manager it will simply open them as a ZIP archive. Clearly, that’s not what you want. Here’s how to fix it:

  1. Go to Commands › File association.
  2. Create a new association by pressing Ins.
  3. Enter *.doc;*.docx;*.xlsx;*.pptx as a mask.
  4. Enter @"!.!" as Execute command (used for Enter).

File associations in Far Manager

You can still open docx file as an archive by pressing Ctrl+PgDn.