Bash – Use Mac OS command key in bash’s bind command

bashkeyboard shortcutsterminalterminal.app

In my ubuntu bash, I had remapped Ctrl-y key combo to copy text to clipboard as,

bind -x '"\C-y": copy_line_from_x_clipboard'

It works. Now, I am migrating to Macbook, I like to use Command key instead of Ctrl key above. I am not seeing any keybinding examples on net that contain Mac OS' command key.
And I tried to get the key combo for Command-y using the command sed -n l as explained here, but it shows empty line after taking Command-y key input.

For those who are interested, the callee function to paste text from clipboard is,

copy_line_from_x_clipboard() {
        local n=$READLINE_POINT
        local l=$READLINE_LINE
       local s=$(xsel -ob)
       READLINE_LINE=${l:0:$n}$s${l:$n:$((${#l}-n))}
       #READLINE_LINE=${l:0:$n}$s
       READLINE_POINT=$((n+${#s}))
}

Best Answer

According to one of the comments in Use CMD-mappings in console Vim, you cannot use the Command key in Terminal.app, though you could in iTerm2.

You're probably looking for modifier, like shift, control, e.g., something analogous to the alt or meta key.

In Terminal.app's keyboard preferences, you have an initial set of key definitions which use these modifiers—along with Option. You can alter these definitions, or add new ones.

Here are a couple of screenshots showing that dialog:

showing the keyboard preferences screen

The second screenshot shows Option (alone, or in combination with other modifiers), but Command is not available for use by programs running in the terminal:

showing the available modifiers for keys

Related Question