Closed iKakoud closed 2 years ago
You are probably talking about this change 5.2.0 Retire command console.
5.2.1 Editor console -> Interactive
is just reshaping of editor console.
Anyway, the command console is no longer provided. It was too advanced for Far Manager and it used too fragile API. The Far team constantly changes things in this area. Far 3.0.4781 was the last breaking drop for me. Also, a few hacks were used in order to make panels totally hidden. I asked for some official API but the Far team was not interested. Far Manager is not a friendly platform for the command console.
Thus, I decided to drop this feature. I am very sorry about this. I liked it too. I put a lot of effort in it. But supporting it in Far Manager is not fun at all. Hopefully, when Far API is stabilized and matured I will resurrect it.
P.S. I have to add a few words.
You are right that the interactive is not the replacement of the command console. It is designed and more useful for particular classes of commands.
The Far command line is the replacement, I can tell you this, I use it daily.
Yes, you have to type the prefix ps:
, but you can use a macro to insert it
for you, I use Space
. Yes, you will miss your custom prompt, but it is not
always needed, is not it? When it is really needed, you can type ps: prompt
and get it. You can also have a helper macro for this prompt. TabExpansion
can be done by a macro F11 \ PSF \ Complete
, I use F9
for all areas.
The ideas on how to improve this scenario are welcome. Currently, this is the most realistic way to go with Far Manager. It is not the best possible, alas. I understand your frustration and even anger, perhaps. I am with you.
Thank you for the response.
The last 2 years, for my daily tasks, I rely on PowerShellFar mainly in three ways:
File Management: I call scripts utilizing PowershellFar API from Far custom user menus and assign appropriate hot-keys for quick access. This functionality is useful for file management tasks. One of the many automation examples:
# Get Far's current directory
$currentDir = $Far.Panel.CurrentDirectory
# Get an Array of Far's selected files paths
$filePaths = New-Object System.Collections.ArrayList
$filePaths = $Far.Panel.SelectedFiles
# Convert the array of selected file paths to string
[string]$fpString = ''
foreach ($fp in $filePaths)
{
$fpString = $fpString + " " + "`"$currentDir\$fp`""
}
# Get the target file name
$fileName = $far.Input("Output File Name:", "", "Combine to PDF", ".pdf") -as [string]
$outFile = "`"$currentDir\$fileName`""
# The exe to combine selected pdfs
$gs='d:\Bin\gs\bin\gswin64c.exe'
# Combine selected files
Start-Process -FilePath $gs `
-Args "-dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=$outFile $fpString" `
-NoNewWindow `
-Wait `
# Open the target pdf
. "$currentDir\$fileName"
File Editor: I automate Far's text Editor with PowerShellFar hooks
($Far.PostMacro
, $Far.$editor.InsertText()
, $Far.Message()
etc) and
have build hierarchical custom menus with New-FarMenu
and New-FarItem
.
For example:
New-FarItem -IsSeparator -Text '[Replace Selection]'
New-FarItem '&e. Convert to Latin' {
$far.CopyToClipboard($far.Editor.GetSelectedText())
iex -Command "latin -m"
sleep -Milliseconds 500
$far.Editor.SetSelectedText($far.PasteFromClipboard())
}
New-FarItem '&b. Paragraph <p></p>' {
$sb = New-Object -TypeName 'System.Text.StringBuilder'
[void]$sb.Append('<p>')
[void]$sb.Append($Far.Editor.GetSelectedText())
[void]$sb.Append('</p>')
$far.Editor.SetSelectedText($sb.Tostring())
}
# ...
cls
Out-FarList
etc) for ps scripts.For my daily work, I use hundred of isolated tools to automate my tasks. What I like about PowershellFar, is that with a single API, I could automate (a) File Manager, (b) Text Editor, (c) Shell Console, using my favorite (and more powerful?) scripting language i.e. Powershell. Probably, Far Manager is not the best choice for all the above, but I could live with it because with PowrshellFar I could automate them all with PS scripts. For example, I also use Total Commander (as orthodox file manager), but the automation there is not based on powershell, and is not very "clean" approach. For text editor, I also use Sublime, has some nice feature for extensions (snippets, macros etc), but it doesn't support native PS automation. For PS shell console, I'm aware of helpful extensions/modules (eg. PSReadLine) but I found the experience with PowershellFar Console to be the best.
Regarding PowershellFar Console, I totally understand all your points
"...too advanced for Far Manager...constantly changes...Far Manager is not a
friendly platform for the command console...". However, Far command line
(I'm
using it occasionally with Space
and Tab Expansion
assigned to
Alt+/ hot-key) and Interactive
(first time noticed
yesterday) are also VERY useful features, but still, to my opinion, are not
replacements to the direct and native shell experience of PowershellFar Console.
Anyway, I'm going to miss a lot the PowershellFar Console
, and I'll have to
replace its convenience with other substitutes.
Please keep up with the excellent project, and consider to extend it to other platforms. As I mentioned earlier, the use case is an API automating (a) File Manager and (b) Text Editor with PowerShell ... and provide an excellent console shell experience ...
Thank you for the useful review of your PSF use cases. I have a few related tips.
In panels, to get selected file/folder paths you can use the PSF cmdlet:
Get-FarPath -Selected
In editor or any other area, you can open the user menu by a macro:
mf.usermenu(0, "")
Or you can use menus from separate files:
mf.usermenu(2, "full menu file path")
mf.usermenu(3, "file name in Profile\Menus")
Far user menus have some advantages over created by PSF. They may be modified
on the fly and you do not have to reload the session after changes. In such
menus you call PSF by the prefix ps:
, as usual.
Do not forget to add a space + #
to the end of PSF menu commands.
By the convention, such commands are not added to the history.
Retired command console vs. PS commands in Far command line
Custom Prompt
It is missing. But you can invoke ps: prompt
any time you need this info.
This command may be assigned to a macro, so you do not have to type.
I also recommend to have some space in panels for small outputs like such
"prompts". Use CtrlUp
and CtrlDn
in order to adjust the panel height
and make this space available. Thus, for some commands you do not have
to hide panel in order to see the output.
Permanent command history
It is available.
Excellent command history lookup (as you type)
It is available and works just fine. As soon as you types ps:
, only saved PS
commands are shown. But is it enabled in your case for the command line? Check
you AutoComplete settings.
Support for cls
It is available. You do not even have to type ps:
. Use just cls
.
Excellent Tab Expansion
It is available. It's just not a Tab
key but some other key and a macro.
PowershellFar hooks (Out-FarList etc) for ps scripts.
All such things are available.
In some cases you may choose to hide/show panels by CtrlO
, of course.
In other words, the functionality of the retired command console is not missing. The user experience is different, I agree. But I have to add that "different" is not "worse". Personally, I find some advantages of using the Far command line over the retired command console. There are disadvantages, too, yes.
And one more thing. If I decide to resurrect the command console I will perhaps try to use PSReadline
instead. It is somewhat working right now (note, in the Far PS session). But it is not yet ready for proper use, we need some hooks for using PSF UI. For now, it's just an idea:
# FarNet.5.2.2 - no need for ShowUserScreen/SaveUserScreen
Import-Module PSReadline
for() {
$Far.UI.Write((prompt))
if (!($_ = PSConsoleHostReadline)) {break}
try {
[scriptblock]::Create($_).Invoke()
}
catch {
$Far.UI.WriteLine($_.ToString(), 'Red')
}
}
After your recommendation, I did some further investigation on Far Command line
with ps:
prefix as replacement of PSF Console
.
My current setup is based on the following:
area="Shell"; key="Space"; flags="EmptyCommandLine"; description="PSF: Easy prefix"; ...
area="Shell"; key="CtrlSpace"; flags="EmptyCommandLine"; description="PSF: Easy prefix - viewer";
Set-Alias go 'd:\Bin\Far\FarNet\Modules\PowerShellFar\Bench\Go-To-.ps1'
Set-Alias fhi 'd:\Bin\Far\FarNet\Modules\PowerShellFar\Bench\Show-History-.ps1'
Things I have to do:
area="Dialog"
hot-key macros used to work at PSF Console
because now most of them conflict with Far's hot-keys.Pros
Cons
PSF Console
I had custom prompt with two lines. The top line included
(among others) the current directory while the bottom line was all
dedicated to the input command with just a single character prompt >
. Now,
with Far command
and it's single line prompt, when visiting long paths, the
visible space left for the command is restricted.
(C)$P$#33(E)$G
as
Command line settings -> command line prompt format,
where the $#nn
is max promt width, given in percents relative to the
width of the window. My 33%
value truncates long paths but leaves descent
space for long commands. As you suggested I can assign a macro to call my
old prompt on demand for extra info.$_ - Carriage return and linefeed
as commented at cmdline.cpp
line 694.Minor Cons
Space
prior invoking a command for ps:
prefix.Tab
for TabExpansion.cd
and drive changes (e.g. c:
) without the ps:
prefix or
use go -> Go-To-.ps1
.Regarding, PSReadline
, as I mentioned in my previous comment, I find the
experience of PSF
approach superior and superset of that functionality. In
PSF
both TabExpansion and Command History are far better to my taste with
searchable- scrollable lists, not to mention the precious API hooks for UI
components. Regarding multiple line commands, with PSF
we could always use
PSF Interactive
which leads to superior experience for multiple line commands.
For my usage, the only very minor superiority of PSReadline
is probably
the MaximumHistoryCount which can be set above 1.000.
In your PSF profile do $psf.Settings.MaximumHistoryCount = 2000
.
thanks for that tip!
I was only aware of:
= 5.0.63 =
PowerShell history:
- Default MaximumHistoryCount: 512 -> 1000.
For the prompt try the below macro, or something similar (you get the idea):
_G.FarNet = function(cmd) return Plugin.Call("10435532-9BB3-487B-A045-B0E6ECAAB6BC", cmd) end
Macro {
area="Shell"; key="CtrlShiftSpace"; flags="EmptyCommandLine"; description="PSF: Prompt + prefix"; action=function()
FarNet [[ps: prompt #]]
Keys "p s : Space"
end;
}
Yes, I'got the idea and put it in practice. Thank you for the tip.
Please share your ideas on how we can improve things and submit requests as new issues. E.g. we can get rid of the first line ps: prompt #
in such a "prompt" using some sort of convention (##
?). Happy scripting!
FWIW In the next version I am resurrecting the useful command console, v2. The Far API looks more stable in this area and FarNet with PowerShellFar have more supportive tools.
FWIW In the next version I am resurrecting the useful command console, v2. The Far API looks more stable in this area and FarNet with PowerShellFar have more supportive tools.
I'm looking forward to test it!
@iKakoud Please take FarNet 5.8.0 and PowerShellFar 5.8.0. and enjoy. Your feedback is welcome. Happy New Year!
and PSF 5.8.1 with amended history navigation.
I think it's a good (re)start and I like its initial look and feel. More good stuff is coming. I am thinking a complete async and non modal implementation, with panels on/off on will, with commands able to open panels, etc., etc. Stay tuned.
More good stuff is coming. I am thinking a complete async and non modal implementation, with panels on/off on will, with commands able to open panels, etc., etc. Stay tuned.
v5.8.2 has it all.
For the last two years, I used daily as my shell environment
ConEmu + FarManager + PowerShellFar
.The startup task on ConEmu was
>d:\Bin\Far\Far.exe /w ps:$Psf.StartConsole()
as suggested here.Also, I had made a multiple-color, two-lines custom prompt for my PowerShellFar Console.
I have build the majority of my ps scripts (100s) around the above environment, utilizing the PowershellFar library, which I find extremely helpful.
After my FarNet update today, when I opened my shell I've got the error:
I traced the latest commits and History, and I've noticed that on version 5.2.0
Retired command console
, and on 5.2.1Editor console -> Interactive
To my opinion, Interactive is totally different experience compared to Console, and PowershellFar's Console was one of the main strengths.
Please restore back PowershellFar Console!