I just wrote a "on start up" script for Mac OS X and want it to NOT fire if I hold down a key, e.g. the shift key.
Anyone know how to check if the shift key is down from a bash script?
You need to interface with a Mac-OS-X-specific API that has this "hold down a key" concept. There's no such thing in bash, nor in related Unix/POSIX APIs. Doubly so with the modifier keys like Shift or Control.
Related
I've gotten used to having the Ctrl key being located below the Shift key instead of above.
I occasionally hit the CapsLock by mistake and would like to map to act like another Shift key.
Searching the web, I see plenty of postings on how to map it to a Ctrl key, or swap the CapsLock <-> Ctrl, so please don't tell me how to do these.
Also I only want to know the parameters for setxkbmap not xmod. I've looked at system configuration files but still haven't figured out which names I need to use.
As described in this answer is possible to map keystrokes to commands in a terminal. And to do this, there is a specific bash syntax for describes each key, as \e[11~ for F1 or Control-o for ControlO
How not everyone is deductible, I would like to find a way to discover each key associated string. If I just press it in terminal nothing happens for most of non-alphanumeric keys
I think you can alternatively install expect, start autoexpect and see what are the codes for your key strokes in generated file.
In Windows we can create a shortcut for any batch script and assign a shortcut for it. (Right-Click on shortcut->Properties->Shortcut key)
How can I assign a double-shortcut for a shortcut like this? For example Ctrl+Alt+J, Ctrl+Alt+K. When I press Ctrl+Alt+J and Ctrl+Alt+K in a sequential order I want the batch script to execute.
Is this possible in Windows? If this method doesn't work, is there any other method this can be achieved through?
No, assigning a combination of hotkeys is impossible. Windows shortcuts are essentially stored IShellLink objects. The object's GetHotKey() documentation shows that only a single hotkey can be used.
Perhaps you could try AutoHotKey. Although I have no experience with it, AHK is usually the solution for such things.
You can also use the SHIFT key which will give you more combinations of keys.
CTRL+ALT+key
CTRL+SHIFT+key
CTRL+SHIFT+ALT+key
SHIFT+ALT+key
Lots of times I'll use Ctrl-R for reverse search and mistype some letter. Bash jumps up hundreds of lines and I'm in the middle of commands I was using a week ago.
Is there a shortcut for jumping back down to the lastest commands I had typed?
Edit: after testing it out on a CentOS server and Mac OS X, it looks like this only happening on OS X.
I've struggled with this same issue.
You can solve this by aborting with ctrl-c. Whether you're in the middle of a reverse search or scrolling through history with the arrows, aborting returns you to a prompt with the history scroll just after the last command.
UPDATE
Here's a nice trick I just learned. Bash and many other programs use Readline under the hood for command-line interpretation. Key bindings for Readline can be configured in a .inputrc file or with the bind command. The bindings can make use of a few functions provided by Readline. For example, I use Bash in vi mode but I still like to use Emacs-style ctrl-A so I have this line in my .bashrc file:
bind '\C-a:beginning-of-line'
To list all the available Readline functions:
bind -l
Among the functions is end-of-history. The function does like its name suggests. The difference between this approach and just using the abort command is that this keeps you on the same prompt.
If using libreadline, Alt-> (or Meta->). More info on Readline shortcuts or search for Commands for Manipulating the History in the man page.
On Mac, try command + .
It works for me.
I was trying alt+. and alt+shift+. , neither works for me. And then found command + . actually works
Maybe not exactly what you want, but you can fix your mistyped character(s) by using backspace when you're in the CTRL-r (reverse-i-search) mode.
You may wan to try "suggest box"-like history HSTR. It reads the bash history and allows quick navigation and filtering - you can see the context of similar history entries. Once you select a history entry it can be edited on the command line.
In Zsh with emacs binding set the actual default key sequence is ^[> binded to end-of-buffer-or-history command rather than command-. suggested above (or end-of-history depending on effect you want to achieve)
Cmd-. produces in Apple Terminal the similar or the same key sequence as Ctrl-C, which can be confirmed by running something useless and long, e.g. find . >/dev/null 2>&1 and pressing one and then other keys on keyboard.
Ctrl-C forces input to be ended and reset. and history scroll is just a side effect for it.
I'm trying out org-mode and the tutorial says Meta-Shift-Enter is bound to org-insert-todo-heading, and I did a describe-function to verify it is bound to that key in my environment
I tried inputting it using escape as meta, so I typed ESC, then holding shift down, enter. I got an error message that ESC- is not defined. Is there a special way I should input this key sequence?
Have you read the Aquamacs FAQ, specifically the section on the meta key?