I lost my configuration or never had it.
I need to send shift+F1 and ctrl+F1, shift+F2 and ctrl+F2 and so on to the terminal since I'm connecting to a linux machine via ssh.
well, my current config is missing these string mappings as you can see in the image.
do you know what are the string mappings for those key combinations ?
thanks.
UPDATE:
in some stackexchange i found this command:
$>for x in {1..12}; do echo -n "F$x "; tput kf$x | cat -A; echo; done
can you help me to print the strings for shift + f1 ?
First: From this page http://invisible-island.net/xterm/xterm.faq.html, you will understand that shift-F1 maps to F11, shift-F2 maps to F12 and so on.(Search the page 'a summary of the keyboard mapping' without ', you will see the list).
Second: From this page http://aperiodic.net/phil/archives/Geekery/term-function-keys.html, you will know F1 or F11 or F20 maps to what string(at the bottom).
More to say:
If you want to send Shift-F1 to a program through Terminal, these will happen:
You hit Shift-F1, the Terminal will translate the Shift-F1 to a string sequence
The string sequence will be sent to the program
For example, you send a Shift-F1 to emacs through the Terminal,the Terminal translate it into string sequence and send the string sequence to emacs, emacs will recognise it as a key strokes then do something.
I'm not quite familiar about this, so this answer may be not right.
Related
The "delete" key on my Macbook is broken. I am attempting to use the hidutil command to remap F1 as my new delete key. The command isn't performing as expected.
The command requires the hex ID's for the keys whose values I'd like to interchange. I've located a resource that provides these hex ID's as well as an overview of how to perform the remapping (https://developer.apple.com/library/archive/technotes/tn2450/_index.html).
I've posted my specific code below. It adheres to the suggested format, but my OS doesn't seem to register any change. Can someone help me identify the issue? I suspect my Hex ID's are wrong, but it may very well be another issue.
Input :
hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x2a,"HIDKeyboardModifierMappingDst":0x3a}, {"HIDKeyboardModifierMappingSrc":0x3a,"HIDKeyboardModifierMappingDst":0x2a}]}'
Output :
UserKeyMapping:(
{
HIDKeyboardModifierMappingDst = 58;
HIDKeyboardModifierMappingSrc = 42;
},
{
HIDKeyboardModifierMappingDst = 42;
HIDKeyboardModifierMappingSrc = 58;
})
There are no error objects. And judging by the output after the command is run some key remapping has occurred. However, my F1 key still retains functionality as F1 and doesn't delete I'd expected.
Your referenced link on apple.com says "The keys take a hexadecimal value that consists of 0x700000000 or’d with the desired keyboard usage value." So I think you should try e. g. HIDKeyboardModifierMappingSrc":0x70000002a ...
Thanks for the above information, I was able to remap the right Ctrl key to be the Command key on the mac with the following command.
% hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x7000000e4,"HIDKeyboardModifierMappingDst":0x7000000e3}]}'
This is because I am using a very old IBM original keyboard that does not have a windows key, just an empty space between the Ctrl and Alt keys on the left and right of the Space bar.
I am trying to inject key combinations (like ALT+.) into a tty using the TIOCSTI in Python.
For some key combinations I have found the corresponding hex code for Bash shells using the following table which works good.
From this table I can see that for example CTRL+A is '\x01' etc.
import sys,os,Queue
import termios,fcntl
# replace xx with a tty num
tty_name = "/dev/pts/xx";
parent_fd = os.open(tty_name, os.O_RDWR)
special_char = "Ctrl_a"
if special_char == "Ctrl_a":
send_char = '\x01'
if special_char == "Ctrl_e":
send_char = '\x05'
if special_char == "Ctrl_c":
send_char = '\x03'
fcntl.ioctl(self.parent_fd, termios.TIOCSTI, send_char)
But how can I get the hex codes for other combinations such as
ALT+f etc. I need a full list or a way how to get this information for any possible combo as I want to implement most bash shortcuts for moving, manipulating the history etc. to inject.
Or is there any other way to inject key-combinations using TIOCSTI ?
As I can only send single chars to a tty I wonder if there is anything else possible.
Thank you very much for your help!
The usual working of "control codes" is that the "control" modifier substracts 64 from the character code.
"A" is ASCII character 65, so "Ctrl-A" is "65-64=1".
Is it enough for you to extend this scheme to your situation?
So, if you need the control code for, for example, "Device Control 4" (ASCII code 20), you'd add 64, to obtain "84", which is "T".
Therefore, the control-code for DC4 would be "Control+T".
In the reverse direction, the value for "Control+R" (history search in BASH) is R-64, so 82-64=18 (Device Control 2)
ASCIItable.com can help with a complete listing of all character codes in ASCII
Update: Since you were asking specifically for "alt+.":
The 'Control mean minus 64" doesn't apply to Alt, unfortunately; that seems to be handled completely differently, by the keyboard driver, by generating "key codes" (also called "scancodes", variably written with or without spaces) that don't necessarily map to ASCII. (Keycodes just happen to map to ASCII for 0-9 and A-Z, which leads to much confusion)
This page lists some more keycodes, including "155" for "alt+."
I'm currently sshing from my mac to a CentOS box, where I run emacs. For whatever reason, the shift key doesn't seem to work when issuing a keyboard sequence. I suspect the wrong key code is being sent.
For example, I've remapped my help command to the following:
(global-set-key (kbd "C-?") 'help-command)
Executing this keyboard sequence in a typescript file reveals that it's invoking the delete-backward-char command, which is a compiled Lisp function from simple.el. (In order to even check what command the keyboard sequence was executing, I had to temporarily remap help to C-o.)
Similarly, I have the following key binding set up for typescript mode
(setq tss-popup-help-key "C-:")
Likewise, it looks like the SHIFT key hasn't registered because I get the following definition in the help manual when I reverse lookup the sequence:
; runs the command typescript-insert-and-indent, which is an
interactive compiled Lisp function in `typescript.el'.
It is bound to ,, ;, ), (, }, {.
(typescript-insert-and-indent KEY)
In other words, emacs registers the colon as a semi-colon.
This is a recurring problem with keyboard sequences that require me to use a SHIFT key. How do I get the SHIFT key to work properly when working on emacs through a mac?
For the record, when I use Emacs for OSX, the shift key works great.
I am yad'fying an alarm script I use from the terminal multiple times a day for quick reminders. Anyway, this var assignment:
killOrSnz=$((sleep .1 ; wmctrl -r yadAC -e 0,6,30,0,0) | yad --title yadAC --image="$imgClk" --text "Alarm:\n${am}" --form --field="Hit Enter key to stop the alarm\nor enter a number of minutes\nthe alarm should snooze." --button="gtk-cancel:1" --button="gtk-ok:0"|sed -r 's/^([0-9]{1,})\|[ ]*$/\1/')
is causing me grief. The var works fine, as intended, except that all of the code below it is no longer highlighted in my vim session, making my eyes hurt just to look at it never mind scan for problems or to make alterations.
I borrowed the idea of piping yad command thru wmctrl to gain better control over window geometry, which is great from another post on here, but there was of course no mention of the potential side-affects. I want to keep fine control over the window placement of apps, but it would just be nice to do so while maintaining document highlighting.
I did try to rearrange the pipe and subshell to see if I could get it to work another way that didn't interfere with my vim highlighting, but there was no love to be had any which way but this way.
It appears that VIM's parser is fooled by the $((, mistaking it for the start of an arithmetic expression rather than a command substitution whose first character is a parentheses. Since there is no matching )), the colorizer gets confused about what is what. Try adding an explicit space between the two open parens:
killOrSnz=$( (sleep .1; ... )
Is it possible to catch + + B (as example) in the following example:
#!/bin/bash
echo "give your key combination and press <ENTER>:"
read input
echo $input
I need B literally as a variable.
= Ctrl button
I'm going to say no. Use a different language. If you're totally desparate you might try one of these hacks, but I don't endorse them (other than the KEYBD trap, which isn't Bash).