2

I want a way to quickly launch programs while I'm in an SSH terminal. But I don't want to have to remember the exact command. For example, if I type "fox" into kupfer/synapse/quicksilver or unity search, it will bring up firefox. Likewise if I type "browser" it'll bring up firefox.

What is the commandline equivalent to this? Such that I can type browser and it lists firefox in the terminal

I am familiar of course with hitting tab, but that assumes I have the first few letters correct, and doesn't let me type 'browser'. I am familiar with findutils locate command, but again, same problem. I want the smooth desktop experience via text, much like lynx browser gives a web experience via console.

4

There are several command line shells. The main ones for interactive use are:

  • Bash, which is the default shell on most Linux distributions. Its main selling point is that it's the default.
  • Zsh is extremely powerful and configurable.
  • Fish has some neat features out of the box but very little customizability.

You're more likely to find such advanced features either built into fish, or provided in zsh through some customization code (either shipped with zsh or through a third-party plugin). Unfortunately for you, I don't think fish has anything remotely like what you're looking for, and I'm not aware of anything really nice for zsh either.

Looking for fox

In zsh, you can have completion based on typing a part of the name. How that works depends on the configuration. With the following configuration, you can type *fox and press Tab to get the completion firefox:

autoload -U compinit; compinit
zstyle ':completion:*' completer _expand _complete _match _prefix

You can get this setup from the configuration screen that's displayed when you start zsh without a configuration file. You may want to play a bit with the completion-related configuration options.

Looking for browser

Looking for browser is a very different problem because the information is not stored in the same place. Getting firefox from fox only requires looking at the names of the executable files, whereas the information that firefox is a browser has to come from somewhere else.

You can use the apropos command to look for programs based on the one-line description at the top of their documentation.

apropos browser

In a way this is the official answer to your question — it's the command line way to look for a program based on its description. But you probably won't find it as convenient for two reasons:

  • There are a lot more command line programs than programs that can be usefully run from a GUI, so there's a lot more noise in the apropos output. The apropos command also shows you programming interfaces; you can cut that out with

    apropos -s 1,8 browser
    

    or apropos -s 1 browser to exclude system administration commands. The numbers are man page sections.

  • The one-line description at the top of the man page is maintained by the developers of each application and they don't always use the same terminology. So sometimes you'll miss an application because its developer used a different way to describe the application. For example, if you wanted to find only web browser, you could run

    apropos -a web browser
    

    and you'd find lynx and firefox, but not links because it's described as a “WWW browser”.

The GUI interface to look up applications is based on .desktop files. You can explore these files with commands such as

grep browser /usr/share/applications/*

It would be possible to build a user interface on top of this, but I don't have one to offer.

  • Thank you for your detailed answer. Fish is awesome. I just want someone to port the kupfer/synapse code to a commandline UI, and we can get a long way – Jonathan May 16 '17 at 23:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.