How to: Start any application from the terminal

Starting any application from the terminal can ease your workflows a lot. I’ve gotten used to being able to open files from the shell, when I’m working on a project. I navigate to the project folder and start editing, either markdown files for documentation or source code.

Usually I’d type gvim file.md and watch the gVim window open.

Not all applications come with the ability to start and edit a file directly from the command line, the good thing is: It’s easy to make them do it anyways. In my case I wanted to open files with uberwriter from the terminal.

find path of a running application

To find out which command actually runs an application on Linux, you can run ps aux | grep application_name.

This will show you how this application is run, in this example it’s located in /opt, which explains why it doesn’t show up as a command in the terminal right away.

Start UberWriter from the terminal

Since I’m currently doing a lot of writing, for the university, a book and of course the blog posts, I want to be able to open files from my terminal, but have them pop up in my graphical application of my choice.

To achieve that with a program that doesn’t build a launch script in /usr/bin/ or /usr/something/bin/, we can just roll our own script. If we were to launch UberWriter from the shell I technically could type the following every time:

Then in my home directory, inside the scripts folder, I created a file called uberwriter with the following content:

python3 /opt/extras.ubuntu.com/uberwriter/bin/uberwriter.py $1 &

After you’ve created such a file, remember to make it executable through a line like chmod +x uberwriter.

The $1 represents the file name I want to open and the & frees up the terminal, so I can make use of it for other purposes.

Use it for anything

Most programs work in similar ways and even if they don’t seem to be executable by default, you can write your own scripts to do pretty much anything. This by the way should work on MacOS too by the way, if you spend a lot of time in your terminal anyways, it might come in handy.

Thank you for reading! If you have any comments, additions or questions, please leave them in the form below! You can also tweet them at me