6 ms·
Here's a few more that the diagram is missing, along with a function I created that inserts these commands (in dark gray so it's not intrusive) every time I sta
by Exuma 9y ago
Here's a few more that the diagram is missing, along with a function I created that inserts these commands (in dark gray so it's not intrusive) every time I start ZSH shell, like flash cards.
Keep in mind, most of these work anywhere in OS X, not just in the terminal.
Put this in your .bashrc or .zshrc
# MOTD
function echo_color() {
local color="$1"
printf "${color}$2\033[0m\n"
}
echo_color "\033[0;90m" "c-f Move forward"
echo_color "\033[0;90m" "c-b Move backward"
echo_color "\033[0;90m" "c-p Move up"
echo_color "\033[0;90m" "c-n Move down"
echo_color "\033[0;90m" "c-a Jump to beginning of line"
echo_color "\033[0;90m" "c-e Jump to end of line"
echo_color "\033[0;90m" "c-d Delete forward"
echo_color "\033[0;90m" "c-h Delete backward"
echo_color "\033[0;90m" "c-k Delete forward to end of line"
echo_color "\033[0;90m" "c-u Delete entire line"
- pbhjpbhj 9y agoCtrl+W Delete word (and following spaces). [works in BASH at least]
- b5 9y agoKeep in mind, most of these work anywhere in OS X, not just in the terminal. That's one of my absolute favourite things about Mac OS -- because Cmd exists, and takes over what Ctrl is used for on Windows and Linux, I can use these Ctrl commands and they work as I expect. I wonder if it's possible to get Linux to work the way the Mac does in this regard? Allocate a Meta key to do what Ctrl does move of the time, so that these Ctrl commands became available again? I'd really find it easier to use Linux if that was possible.
- emidln 9y agoGnome/GTK and KDE both have keybinding themes that can be set to emacs. You can do it for GNOME/GTK from gnome-tweak tool. Otherwise you can use gsettings or edit the config directly. Just google "emacs gnome keybindings".
- bmn__ 9y agoYes, that works out of the box with every KDE application. I recommend Super as modifier key rather than Meta because most keyboards on the market have a physical Super key or two. https://encrypted.google.com/search?tbm=isch&q=kde+rebind+keys+dialog https://encrypted.google.com/search?tbm=isch&q=kde+rebind+ke...
- knight17 9y ago>>That's one of my absolute favourite things about Mac OS Mine too, but I'm on Windows where none of this work out of the box. However, I've found XKeymacs [0] which allows Emacs keys system wide. It is not fool proof, but I've found that the movement keys can be used without much trouble. Currently I use: Movement: C-b C-f backward/forward-char M-b M-f backward/forward-word C-p C-n previous/next-line C-a C-e Home End C-x h Capitalisation: M-l M-c downcase-word, capitalise-word M-F12 rollup-window C-z iconify-deiconify-frame C-q enable-disable xkeymacs [0] https://github.com/fujieda/xkeymacs https://github.com/fujieda/xkeymacs http://xkeymacs.osdn.jp/ http://xkeymacs.osdn.jp/ I also use TouchCursor [1] to get vim like hjkl movement system wide while Space is pressed [1] https://martin-stone.github.io/touchcursor/overview.html https://martin-stone.github.io/touchcursor/overview.html
- StavrosK 9y agoThis is great, does anyone have an equivalent for fish?
- eltoozero 9y agoHere's a version for fish, goes in ~/.config/fish/config.fish # MOTD function echo_color printf "\033[0;90m$argv[1]\033[0m\n" end echo_color "c-f Move forward" echo_color "c-b Move backward" echo_color "c-p Move up" echo_color "c-n Move down" echo_color "c-a Jump to beginning of line" echo_color "c-e Jump to end of line" echo_color "c-d Delete forward" echo_color "c-h Delete backward" echo_color "c-k Delete forward to end of line" echo_color "c-u Delete entire line" And a slightly optimized bash version (YMMV): # MOTD function echo_color() { printf "\033[0;90m$1\033[0m\n" } echo_color "c-f Move forward" echo_color "c-b Move backward" echo_color "c-p Move up" echo_color "c-n Move down" echo_color "c-a Jump to beginning of line" echo_color "c-e Jump to end of line" echo_color "c-d Delete forward" echo_color "c-h Delete backward" echo_color "c-k Delete forward to end of line" echo_color "c-u Delete entire line"
- branchless 9y agoC-u deletes everything to the left of the cursor
- oxidized 9y agoKeep in mind, most of these work anywhere in OS X, not just in the terminal. Adding on to this - this works in many places in OS X, since many programs happen use NSTextField, which can have shortcuts configured at the OS level. You can further customize the shortcuts available in a file called DefaultKeyBinding.dict I use a very slightly modified version of this: https://gist.github.com/cheapRoc/9670905 https://gist.github.com/cheapRoc/9670905 I highly recommend looking into that, for anyone who is familiar with emacs keybindings and would like them everywhere.
- zeptomu 9y agoNice idea and important quick-movements. However as a Vim user (mostly motivated by the fact that I can move around pressing single keys which I find more "wrist-ergonomic" - potential fast navigation is a nice plus), I always wonder how heavy emacs users deal with CTRL-acrobatics and movement - do you use c-f/c-b for going forward/backward or the usual cursor keys? For vi users it makes sense to set $readline (~/.inputrc) to vi-style, so for completion here the vi-style bindings (although probably obvious if you used to Vim). l "Move forward" h "Move backward" k "Move up" (step history backward) j "Move down" (step history forward) ^ "Jump to beginning of line" $ "Jump to end of line" Deleting works as usual with `d` combinations. Furthermore it is convenient to search the history via `/`.
- krylon 9y ago> do you use c-f/c-b for going forward/backward or the usual cursor keys? I do. With emacs, you usually have a finger near the Ctrl key at all times anyway, so hitting f or b is much more convenient than moving my right hand over to the arrow keys.
- xorcist 9y agoCtrl-heavy programs are much easier to use when you map the Ctrl key back to its original position, leaving the Ctrl-labeled key for whatever Hyper needs you have.
- sedachv 9y agoYes, the Lisp Machine keyboard layout: https://deskthority.net/wiki/Symbolics_layout https://deskthority.net/wiki/Symbolics_layout That way you can press Control or Alt/Meta (or both at the same time) with the thumb of either hand without a lot of movement. C-f and C-b can be done with either left hand only, or left hand for f/b and right thumb on Control (what used to be Alt, on PC keyboards). Rebinding Caps Lock to Backspace also saves a lot of hand movement. Only a handful of small changes and you get a much better keyboard layout.
- sanbor 9y ago
- deleted 9y ago[deleted]
- rmetzler 9y agoc-t Swap chars (useful for correcting typos)
- pax 9y agoCan someone explain the benefits of c+(f,b,p,n) instead of plain arrow keys? Also, for c+h/d there's always a dedicated key/single stroke for at least one of those delete actions.
- mjepronk 9y agoYou can keep your hands in typing position on the keyboard while performing these operations. Using the arrow keys or backspace means you need to move to another part of the keyboard which interrupts your flow.
- pax 9y agoPoint taken, thank you. Though, trying it out now, I realised f,b,p,n are not quite next to each other, and funnily enough, while I can easily type without looking at the keyboard, when I use a modifier key, the muscle memory used for typing doesn't seem to help as much, it seems it needs new training. Seems I need to flex more :)
- mkesper 9y agoYour fingers stay near home row so you can type faster. Cursor keys are way to far off and differ very much between different keyboards.
- coldtea 9y agoWhat about any benefits of moving your hands around though? Unless one is a court typist, where wpm matters fully, maybe moving a little and not keeping one's hands on the home row can help avoid carpal tunnel and RSI?
- c256 9y agoIn addition to the control- versions, there are meta- and control+alt- versions that work the same way in greater logical units. For example, moving forward by 1 character/word/sentence-or-expression uses different modifiers for the same keybinding. In Emacs, these consistenly pervade the interface, so, for example, paragraphs in text modes are akin to blocks in or functions in programming modes (depending on if the language is block or function based). This is one reason that Emacs tends to swallow other user interfaces for dedicated Emacs users — everything is highly consistent, and you get a giant head-start on a new systems. Of course, it helps that Emacs is massively customizable, so when something doesn’t quite do what you want, it’s usually a very small bit of hacking to change that. Historically, many of those keybindings date back to very crude remote terminals where control codes and tty modes were a real concern. For example, I’ve used systems (in the 90’s) where the delete key could freeze your remote connection. Emacs, because of it’s age and ubiquity, has grown up somewhat “around” those traps.
- baby 9y agoUnfortunately a lot of these don't work anymore in Firefox in newer versions. No idea why. (alt-b for example)
- frumiousirc 9y agoIn Firefox under Ubuntu/MATE with keyboard theme "emacs", most of these bindings are followed. Ctrl-W is taken up as "close tab".