Execute highlighted command with single keypress in fzf - command-line

I'm using fzf Ctrl+R binding to navigate the command line history. Now first Enter keypress selects the command, and the second one executes it.
Is it possible to configure fzf to perform both of these actions with a single keypress?

Related

Fish is not returning to new line after executing bind

I'm binding Ctrl+f to fg so I can Ctrl+z and Ctrl+f back into vim. However after two times doing the combo twice, it ruins the terminal:
user#pc:~$ vim
Job 1, 'vim' has stopped
user#pc:~$ Send job 1, “vim” to foreground
Job 1, 'vim' has stopped
^F▉
Cursor is now not on a line (which begins with user#pc) and executing any command show it as string (^Fas example).
Pressing enter fixes this, but there should be a better solution.
Edit: using bind \cf 'fg; commandline -f repaint' shows the PS1, but it's still in text mode, meaning pressing Ctrl+f, doesn't run fg but outputs ^F.
Solution was to instad of using:
bind \cf 'fg'
use:
bind \cf 'fg; commandline -f execute'
It ocassionaly does an extra enter, but whatever.

How to run edit, reload commands of an ahk file via a windows shortcut or command line?

I want to be able to launch the script file .ahk in edit mode (in sublime), reload, pause etc script via a windows shortcut.
Basically I want some of the following commands, (edit, reload):
Is there a flag like /e or --edit --reload that is specified in the windows shortcut editor dialog & command line so as to launch the any of above commands:
Thanks
There are built-in commands for both Reload and Edit
You can just assign hotkeys to the commands, to execute them directly inside of the code:
^!r::Reload ; Ctrl+Alt+R
^!e::Edit ; Ctrl+Alt+E

VSC Command Log

Trying to figure out how to create a key binding for a specific command.
I can see the command in the pallete but it has no bindings so I can't see it in the keybindings.json.
Is there any way I can LOG all commands being executed within VSC so that I can perform the command and see the command name in the log?
Edit:
To make it clear:
I want general method to know how I can find what commands were issued along with their command IDs.
I already know I find some commands in the default keybindings file and that's NOT a general way to find the command you have run. It doesn't list all command not does it explain what they each are and you can't use it to verify that it is the command you executed.
You can create binding using Keyboard Shortcuts as well (Preferences: Open Keyboard Shortcuts command). You can search by command name and and even check its corresponding id:
Second option is that you can enable tracing and see executed commands in output panel (it looks like it doesn't log commands executed from command palette though):
Set log level to trace.
You can either pass --log argument when starting VS Code like: code --log trace (doesn't work for me for some reason) or execute Developer: Set Log Level... from command palette:
After that, you should see executed commands in output panel for Window process.
The "Toggle Line Comment" command's id is editor.action.commentLine.
You can find all the command ids by using the search feature in the Keyboard Shortcuts Editor (on macOS you can open it via Application Menu > Preferences > Keyboard Shortcuts or using the shortcut Cmd+K Cmd+S).
In the keybindings.json you can trigger the autocomplete help (i.e. Ctrl+Space) and search all available commands.

Ctrl+c not working in integrated terminal which uses Powershell

I'm using Powershell in the integrated terminal by adding the following line to the settings.json file.
"terminal.integrated.shell.windows": "C:\\WINDOWS\\system32\\WindowsPowershell\\v1.0\\powershell.exe",
It works very well, but usually, when I'm in Powershell, typing ctrl+c cancels what I had typed and opens a new line.
But in the integrated terminal it just prints ^C.
Is there a way to fix it or find an alternative method to achieve this?
Thanks
This is with VSCode and not necessarily with the PowerShell Extension. You can see this by just using the default cmd.exe terminal, CTRL+C does nothing. It does not print the ^C at all, and creates no new line.
If you want this to work as expected in the normal command prompt or PowerShell.exe you will need to submit an issue to VSCode repository and request it.
I would expect this is all tied to the keybindings.json file. I went through that file but could not find a command available to the same function that occurs in the full command prompt or console. So this will likely need a new command added for VSCode.
If you search through the keybindings file you can see the terminal has that key CTRL+C bound to copySelection when terminalFocus && terminalTextSelected. This is why the ^C is being output, and no new line is being added.
A workaround:
Pressing Esc will erase the line back to the beginning.

PowerShell history of commands

I use Bash and PowerShell interchangeably, and find it quite annoying when I can't do a Ctrl+R on my PowerShell Console.
Is there a plugin/alternate command that can help me switch between Bash and PowerShell seamlessly?
Update (2018)
PowerShell now supports Ctrl + R. Please see this answer.
An alternate command is to type e.g #ls and press Tab keep pressing tab to cycle through all command history that starts with ls.
In previous versions you could type ls then F8 to match history. Keep pressing F8 to cycle through multiple matches.
Note:ls is just a placeholder in this case. Replace it with any command you want.
As of today PowerShell supports the Ctrl + R shortcut.
Simply press Ctrl + R when in the PowerShell console and start typing any part of a command you have run before.
Alternatively:
Start typing part of a command you have run before, and press or hit F8.
Keep pressing F8 to cycle through similar commands.
Take a look at PSReadline: https://github.com/lzybkr/PSReadLine
This module supports interactive history search in emacs mode and you can bind Ctrl+R to ReverseHistorySearch in Windows mode if you prefer.
The long term goal of PSReadline is to make it much easier to switch from bash to PowerShell w.r.t. command line editing while providing a PowerShell experience, e.g. tab completion.