How can I get CTRL-D to execute my own function before ViExit?
See original GitHub issueI’m using this to exit my powershell sessions:
Set-PSReadlineKeyHandler -Key ctrl+d -Function ViExit
But I would like to do something else before exiting, so how can I have another function be executed before ViExit when doing CTRL-d
?
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
python - Doing something before program exit
It will be called if you press Ctrl+C. That simply raises a KeyboardInterrupt exception. – Ned Batchelder. Oct 3, 2010 at 15:11.
Read more >When pressed ctrl+c only break out of current function and ...
I'm trying to write a script wherein if someone pressed CTRL + C (Keyboard interruption) then it shouldn't exit the entire script, just...
Read more >2 Ways to Assign Keyboard Shortcuts to Macros
You can easily look up your keyboard shortcuts by by searching the VBA code for the word “onkey.” Use the Find window (...
Read more >Keyboard shortcuts - Visual Studio (Windows)
Break at function, Ctrl+B, Debug.BreakatFunction ; Break all, Ctrl+Alt+Break, Debug.BreakAll ; Delete all breakpoints, Ctrl+Shift+F9, Debug.
Read more >Keyboard shortcuts - RStudio IDE
Keyboard shortcuts · Ctrl + Enter · Ctrl + Shift + n · Ctrl + s · Alt + - · Ctrl +...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@gwojan
That’s what i wanted to do, but I was under the impression that
...-Function ViExit
was internal to PSReadLine and thus could not be replaced bymyfun()
.I managed to solve this by setting an event handler inside my profile script like this:
However, I don’t think this is actually executed before
ViExit
, but worked for my purposes.Why not bind <kbd>Ctrl+d</kbd> to a user defined function that ultimately calls
ViExit
?