How to use shift to select part of the commandline (like in many text editors) ?
相关问题
- How to get the return code of a shell script in lu
- Invoking Mirth Connect CLI with Powershell script
- Emacs shell: save commit message
- “command not found” errors in expect script execut
- Python script using subprocess and xclip hangs if
相关文章
- 使用2台跳板机的情况下如何使用scp传文件
- In IntelliJ IDEA, how can I create a key binding t
- shell中反引号 `` 赋值变量问题
- How get the time in milliseconds in FreeBSD?
- Launch interactive SSH bash session from PHP
- Generate disk usage graphs/charts with CLI only to
- How can I create a small IDLE-like Python Shell in
- How to specify a custom path for my .zshrc file?
That assumes your terminal sends a different escape sequence upon Shift-Arrows from the one sent upon Arrow and that your terminfo database is properly populated with corresponding kLFT and kRIT capabilities, and that you're using emacs style key binding.
Or, to factorize the code a bit:
Above, hardcoded sequences for cases where the terminfo database doesn't have the information (using xterm sequences).
Expanding on Stephane's excellent answer from almost 3 years ago, I added some more bindings to make the behaviour (almost) completely consistent with all of Windows' standard keyboard behaviour:
Backspace
andDel
delete an active selectionCtrl+Shift+Left
/Ctrl+Shift+Right
Shift+Home
andShift+End
extend the selection to the beginning and end of line respectively.Ctrl+Shift+Home
andCtrl+Shift+End
do the same.Two things that are not exactly the same:
Note that the default mintty behaviour is to bind
Shift+End
andShift+Home
to access the scroll back buffer. This supercedes the zsh configuration; the keys never get passed through. In order for these to work, you will need to configure a different key (or disable scroll back) in/etc/minttyrc
or~/.minttyrc
. See "modifier for scrolling" here - the simplest solution is just setScrollMod=2
to bind it toAlt
instead ofShift
.So everything:
~/.minttyrc
~/.zshrc
This covers keycodes from several different keyboard configurations I have used.
Note: the values in the "key" column don't mean anything, they are just used to build a named reference for zle. They could be anything. What is important is the
seq
,mode
andwidget
columns.Note 2: You can bind pretty much any keys you want, you just need the key codes used in your console emulator. Open a regular console (without running zsh) and type Ctrl+V and then the key you want. It should emit the code.
^[
means\E
.