F-N Shortcuts in the Windows' Command Prompt - command-line

Where can I get some explanations on what F1 , F2 , F3 ,F4 , F5 , F6 , F7 , F8 , F9 , F10 , F11 and F12 do in Windows' Command Prompt?
Are there some other useful shortcuts for Windows' Command Prompt?

These are the function keys used by the old MS-DOS DosKey command. They are now built into Windows NT's command interpeter. Go to Start > Help and Support and search for DosKey.
See Doskey at http://technet.microsoft.com/en-us/library/bb490894.aspx.

Related

i3 keybinding prohibits part of xdotool script

I want to bind holding ctrl and left clicking to a button in i3 using xdotool. I have put
bindsym --release $mod+i exec ~/Bin/xdotoolRight.sh
in my i3 config file including the --release prefix as per the i3 doc https://i3wm.org/docs/userguide.html.
The script xdotoolRight.sh is just:
#!/bin/bash
xdotool mousemove 2800 725
xdotool keydown Control_L
xdotool click 1
xdotool keyup Control_L
When pressing $mod+i, the mousemove line of the script works but the other part not.
Any help would be much appreciated.
Best,
be5tan
I have let the script run from the terminal and it works fine. I really don't understand why part of the script is executed and another part not.

VSCode Terminal - Clear Command Prompt

I'm running on Linux. I have the issue both in bash and pwsh shells.
How do I clear the current command prompt in the VS Code terminal?
For example, say you have copied and pasted a very long string into the terminal.
How do you clear what you just pasted?
The only way I know of for getting back to a an empty command prompt involves hitting backspace until you have deleted every character.
Is there any short cut for getting back to an empty prompt?
Thanks!
How do you clear what you just pasted?
There is no command to clear what you have already pasted. You can do Ctrl + C or Ctrl+D to get the next promt.
Now if you want a short-cut to clear command which we use in terminal, its Cmd + k for Mac OS
CTRL + shift + p, then write clear. You can use the clear command in bash terminal too.
Use Console.Clear() in code.
or use 'cls' cmd on console

create shortcut in cmd prompt using autohotkey

I am using python and virutal environment in windows7. Every time I need to go to the project folder, shift+right click to open command prompt and activate virtualenv.
Instead I can hit win+R them type cmd to open a command prompt.
Then type
C:\cd D:\path\to\project
D:
workon projectEnvironment
Can this be done to create a shortchut like 'work' from autohotkey ??
Your windows-R shortcut would work like this:
Start a cmd window and wait until it is active.
Then begin to send your commands.
#r::
Run, %comspec% /c cmd.exe
SetTitleMatchMode, 2
WinWaitActive, cmd.exe
SendInput, cd D:\projects\folder{enter}
SendInput, D:{enter}
SendInput, workon projectEnvironment{enter}
return
Although I was unable to create shortcut key combination in cmd, I created a shortcut key, i.e. windows button + space
#space::Send cd D:\projects\folder{enter} D:{enter} workon projectEnvironment {enter}
Edit
here's the real solution
::work::cd D:\projects\folder{enter} D:{enter} workon projectEnvironment {enter}
After an hour of researching why my script would write " instead of \ when Sending a path in cmd prompt, I realized that sometimes the cmd prompt will interpret some keys differently for AutoHotkey.
I used to write Send, cd C:\File\Path {Enter} and it returned:
C:"File"Path
You can use ASC codes for / = {ASC 47} and \ = {ASC 92}, which in the end you write:
Send, cd C:{ASC 92}File{ASC 92}Path {Enter}

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.

Use CTRL + D to exit and CTRL + L to cls in Powershell console

I am trying to make
CTRL + D - exit Powershell console
and
CTRL + L - clear the screen
like in bash.
So far, I have seen that we can define
function ^D {exit}
but that means I have to do CTRL+D and then hit enter for it to work.
Also, it doesn't even let me define
function ^L {exit}
Is there anyway to add these key bindings in the default Powershell console?
Old question, but with PowerShell 5.1 and PowerShell Core 6.x and later:
Set-PSReadlineKeyHandler -Key ctrl+d -Function ViExit
There is a new library PSReadline for Powershell v3.0 that emulates the GNU Bash tab completion and key bindings. Even CTRL + R for reverse incremental search works. Exactly what I wanted.
If you don't mind relying on an external program, you could do the following with AutoHotKey:
#IfWinActive ahk_class ConsoleWindowClass
^L::SendInput , {Esc}cls{Enter}
^D::SendInput , {Esc}exit{Enter}
#IfWinActive
The above will work with the PowerShell or CMD console. Otherwise the only thing I can think of would be to work up some P/Invoke magic with SetWindowsHookEx.
Edit: Fixed AutoHotkey script to pass through the shortcut keys to other programs.
The keybindings are controlled by PSReadLine. PSReadLine's default edit mode is Windows style, where Ctrl-D is unbound.
Set your edit mode to Emacs
Set-PSReadlineOption -EditMode Emacs
or bound the key
Set-PSReadLineKeyHandler -Key 'Ctrl+d' -Function DeleteCharOrExit
There is also a PowerShell snapin called PSEventing which will allow you to do this (see the demo on the front page:
http://pseventing.codeplex.com/releases/view/66587
# clear screen in response to ctrl+L, unix style
register-hotkeyevent "ctrl+L" -action { cls; write-host -nonewline (prompt) }
You can set your PSReadline to emacs mode, it will not only exit with ^D, you will be able to go to beginning of line with ^A, end of the line with ^E
Include this in your profile:
Set-PSReadlineOption -EditMode Emacs
I'm using cmder which uses ConEmu, find profile.ps1 with <appdir>/vendor/ for that case and you can add into that file.
Otherwise you can add to default locations where powershell loads it. One of tutorials HERE.