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.
$ ps aux | grep uberwriter geronimo 4383 0.6 1.3 536748 47108 ? Sl 21:08 0:00 /usr/bin/python3 /opt/extras.ubuntu.com/uberwriter/bin/uberwriter
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/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:
python3 /opt/extras.ubuntu.com/uberwriter/bin/uberwriter.py filename &
Since I’m lazy and just want to write
uberwriter filename, I will just add the path to my custom scripts to my
~/.bashrc like so:
# include /home/user/scripts for user scripts export PATH=~/scripts/:$PATH
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.
$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.