Is there a command containing command1, command2, command3, command4, etc that when run will cycle between these?

My idea would be then to use that one command with a shortcut or launcher (in ~/.local/share/applications for example, or a panel or dock launcher) to cycle between different commands .

I am looking for something similar to what disper does to cycle displays: disper --cycle-stages='-e : -c : -S : -s' --cycle is a command that cycles between commands that can be run separately: disper -e, disper -c, disper -S, disper-s. It helps cycling between what otherwise would be different commands.

But while disper is for cycling displays, I want to know if there is a CLI tool that would cycle between any separate commands. I am thinking about cycling displays without using disper, which doesn't always work; for example, I would in this way have a launcher or shortcut to cycle commands like:

xrandr --output VGA1 --auto --output LVDS1 --off 
xrandr --output VGA1 --auto --left-of LVDS1 --output LVDS1 --auto --primary 
xrandr --output VGA1 --auto --left-of LVDS1 --primary --output LVDS1 --auto  
xrandr --output VGA1 --off --output LVDS1 --auto 

It should be something like: cycling-tool 'command1, command2, command3, command4'

I am a medium GUI user and not at all advanced in using CLI. If there are reasons of principle for which what I ask is not possible, please provide an answer in terms suitable to a certain level of vulgarization (not too esoteric).

  • 3
    For a generic solution, the command would have to save state somewhere.
    – Kusalananda
    Commented Jan 23, 2017 at 11:04
  • Not being familiar with disper, do you want this cycling-tool to call each of the 4 commands in sequence?
    – Jeff Schaller
    Commented Jan 23, 2017 at 16:24
  • @JeffSchaller - the Main-command should each time trigger the next Command-in-the-series. (But this is a question that I ask out of curiosity more than anything else, and the real answer to "Is there etc?" might very well be "NO".)
    – user32012
    Commented Jan 23, 2017 at 18:14

1 Answer 1


If you are in BASH shell,

Ctrl + r   Recall the last command including the specified character(s)
             searches the command history as you type.

You can try Ctrl + r and type first common characters between all the commands like disp. If you keep ctrl pressed and repeat r, shell will cycle through the commands.

  • Maybe my question isn't clear. I want a single command that could be triggered by shortcut or launcher (panel, dock, desktop launcher, etc) in a desktop interface (not in console) in order to cycle between different commands
    – user32012
    Commented Jan 23, 2017 at 10:58
  • 1
    I can't recollect having seen anything like that. I suppose it can be achieved with a tiny script leveraging xargs
    – fossil
    Commented Jan 23, 2017 at 11:16

You must log in to answer this question.