So when I am in in VSCode using PowerShell extension the parameter options do not show up. For example if I type in "new-azresourcegroup -name test -location " the optional locations do not populate so I have to manually type them in. The odd thing is if I go to the VSCode PowerShell Console, this feature works as intended and I can tab though the "-location" options and choose which one I want. While doing this I am connected to Azure. The weird thing is that the console works, but the window where you write your code does not which to me is odd as its my understanding that the window uses the console in the background (if that makes sense). Not sure if this is a PowerShell extension issue or a VSCode issue. Any help much appreciated.
The answer = CTRL + SPACEBAR will reveal the options. Would be nice if if could be switched to the TAB key so that it would match the behavior of commandline or terminal.
Related
I have the PowerShell extension installed under VSCode. When I open up a PowerShell script, VS Code automatically pops open a "PowerShell Integrated Console" window in my terminal. It's different from the normal PowerShell terminal:
It's better than the default one because keyboard shortcuts like Ctrl+Backspace to delete a word work. But when I try to open one of these fancy terminals myself, the option isn't there:
How can I get one of these improved terminals without opening a script file, and how can I get VSCode to use them automatically instead of the old PS terminal?
Note:
Normally, a PIC (PowerShell Integrated Console) is automatically created the first time you open a PowerShell source-code file for editing in a session.
The instruction below show to how to directly create a PIC, which may also be helpful if you need to restart it after a crash - though you're usually prompted to create a new one when that happens.
Instruction as of v2022.12.1 of the PowerShell extension for VSCode (Visual Studio Code):
Execute the PowerShell: Show Session Menu command from the command palette (Ctrl-Shift-P).
This will create a PIC and show a submenu, which you can simply dismiss with Esc.
Note: If the PowerShell extension was already loaded but the PIC has crashed, choose Restart Current Session from the submenu instead.
Additionally, you may assign a keyboard shortcut to the command, by clicking the cog icon on the right edge of the command palette entry.
Because the PIC doesn't have an external executable entry point you can not define it as a custom shell profile (at least as of VSCode 1.67.1).
GitHub issue #3918 discusses implementing simpler ways to activate / load the PIC on demand as a future enhancement:
Making the PIC show in the list of available shells (as shown in your question, analogous to the extension-contributed JavaScript Debug Terminal entry) is one of the suggestions, but the concern is that there can only be one PIC as of this writing, so such an entry would behave differently from other shells in the list, which create a new session every time.
However, this concern would go away if support for multiple PICs were to be implemented, which is being proposed in GitHub issue #2418.
Ive been scratching my head with this one. Previously VS Code highlighted Powershell scripts and modules just fine with highlighting functions in yellow and variables $var in light blue. Both as part of a string and "stand-alone". However, suddenly it doesn't highlight functions or variables anymore? I've tried to uninstall and reinstall the powershell extension from Microsoft, as well as disable and re-enable the built in language support for powershell.
I've not been able to find any support regarding this issue and hope that I might be able to find it here.
Have you tried this?
File Association.
Basically:
The easiest way I've found for a global association is simply to Ctrl+k m (or Ctrl+Shift+P and type "change language mode") with a file of the type you're associating open.
In the first selections will be the option "Configure File Association for 'x' " (whatever file type - see image attached). Selecting this gives you the option to choose the language and will then make the filetype association permanent.
if you start your code block with a ```PowerShell it will highlight the syntax properly.
I've noticed that you may also need to end your code block with a ``` in VSCode specifically.
If you can start powershell in admin privileges with keyboard shortcut WIN+X>A, how do you exit it. Alt+F4 does not work. I have tried other possible combinations but none seems to work.
Note: I am not asking about Powershell ISE(which i can close with Alt+f4).
I am asking about the on-demand readily available terminal powershell.
To close a PowerShell window using the system menu you can use
Alt + Spacebar, C
Nearly every Windows window has this option. The Close or Exit option may differ based on the context so you'll just have try it and see.
This answer is accurate for the time of its writing but things may change.
Update: If you're using Windows Terminal, no workaround is needed: Alt-F4 works as-is.
The following therefore only applies to regular (conhost.exe) console windows.
Note:
For an ad hoc solution that uses different keys (strictly speaking, a keyboard shortcut followed by an additional, UI-language-dependent keypress), but requires no setup, see No Refunds No Returns's answer.
This answer provides a workaround that works transparently, i.e., with the original shortcut key, but it requires modification of your $PROFILE file; on the plus side, you can use the same technique to make other unavailable shortcuts available too.
It is the imported-by-default PSReadline module that prevents Alt+F4 from being effective[1].
While unloading PSReadline (Remove-Module -Force PSReadline) is an option in principle, you'll lose valuable command-line editing features if you do.
The best approach is therefore to define a Alt+F4 handler for PSReadline that emulates the default behavior:
Add the following to your $PROFILE, which sets up a PSReadline key-chord handler that uses the .SendKeys() method of the WScript.Shell COM object to send Alt+F4 to the caller's console window, which closes it:
Set-PSReadlineKeyHandler Alt+F4 -ScriptBlock {
(New-Object -ComObject WScript.Shell).SendKeys('%{F4}')
}
[1] As of v2.0.0-beta3. The longstanding underlying technical problem is explained in this GitHub issue, which also contains workarounds for other standard keyboard shortcuts, such as Ctrl+F.
The default PowerShell is not convinient to copy/paste command output. SublimeREPL solves this problem very well; however, there's no tab-completion. This made PowerShell hard to use. Is there a way to get the tab-completion?
Keyboard shortcuts can differ, based on your configuration and OS.
Have you tried Alt+/?
I'm running Console2, which I believe is just an interface to windows cmd
I have a custom batch file that does most of my dirty work for me, but there are lot of commands in it now. Is there a way I can get a tap autocomplete working for it in the windows command prompt?
For example: my script is called rob.bat and it takes in a various number of arguments
It'd like to type rob set{Tab} and then have it cycle through
setup_envvars
setup_userprefs
setup_whateverothersetupscriptsIhave
Is there a way to do this?
Console2 has no special provisions for tab completion and instead relies on the program running within it to provide such features. Picture Console2 as little more than something that runs a console program hidden somewhere, regularly polls that hidden window for changes, and forwards all input to that window; this is, in essence, what's happening.
Note that Console2 does nothing special with cmd. You can run any shell within it. As for customizing tab completion, cmd offers nothing of that sort. You may be able to change this by installing clink, which has extension points for Lua code. Another option would be PowerShell, which has customizable tab completion out of the box, either by wrapping your program in a function that provides the necessary parameters, or by writing a custom TabExpansion or TabExpansion2 function.