Score:-4

Shortcut for: | less [ENTER]

cn flag

I often type | less [ENTER].

I would like to optimize this.

Environment: Ubuntu 20.04

This needs to work for terminals running in the browser, too.

Any idea how I could enter above string with less effort?

It would be super cool, if the CapsLock key could be used for this, since I don't need this key (and it is easy to access with the ten finger touch-typing-system).

br flag
Get a keyboard with programmable keys (mine's a Corsair K95) - that's one option
guettli avatar
cn flag
@Chopper3 i am addicted to the trackpoint between G and H. I can't live without it. AFAIK there are no programmable keyboards with a trackpoint.
cn flag
This question belongs to https://superuser.com
Score:5
in flag

With xdotool : sudo apt-get install xdotool

  • Go to : Keyboard settings
  • Create a shortcut with :

bash -c ' sleep 0.3; xdotool getactivewindow type " | less" ; xdotool key Return '

  • Bind a key combinaison, for example : Ctrl + Shift + /

Keyboard settings (sorry in french)

To use caps lock key

Try this :

  • Bind your CAPSLOCK to SuperL : setxkbmap -option caps:super, or an other useless key for you (be careful with keys conflicts).
  • Map your command to your new key enter image description here
guettli avatar
cn flag
Is there a way to use the (otherwise useless) CapsLock key to trigger the xdotool shortcut? CapsLock "L" would be cool.
1F987 avatar
in flag
Yes, just trigger the CapsLock key when the prompt wait the key shorcut (tested on Ubuntu 20.04). But I think it's not a really good idea because your keyboard will be capslocked every time you trigger the shortcut, and you need to trigger again to revert capslock (and off course, your command will be resend again, could be a mess !).
guettli avatar
cn flag
I don't need CapsLock. It would be great if CapsLock could be used for several such cool shortcuts.
1F987 avatar
in flag
It can be tricky to deal with CAPS_LOCK key, but I have edited my answer with a trick (tested on Ubuntu 20.04, french keyboard).
guettli avatar
cn flag
why is "sleep" needed?
1F987 avatar
in flag
If you remove the `sleep` instruction, the behavior can be incorrect.
djdomi avatar
za flag
Requests for product, service, or learning material recommendations are off-topic because they attract low quality, opinionated and spam answers, and the answers become obsolete quickly. Instead, describe the business problem you are working on, the research you have done, and the steps taken so far to solve it.
Score:0
ge flag

Why don't you just use less my_file instead of piping to less ? you could even just add an alias for less so you do not need to type less completly.

alias l=less

guettli avatar
cn flag
I want to use the command less on stdout of a program, not in a file
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.