Get Rid Of The GUI: Software Development Using The Terminal
31 July 2017 |
About a 8 minute read
Over at AND Digital, the developers all use a variety of different tools to do similar jobs. I’ve noticed that not a lot of the devs however, use terminal based tools, and instead use those that have a GUI. There’s nothing wrong with this, GUI tools are usually much easier to pick up and immediately start using, however they’re not always the fastest tools for the job.
A lot of tools that run in the terminal are often open source, and customisable, so you’re able to specifically tweak them to your own workflow, as opposed to making your workflow fit around a GUI tool. Below are a set of tools you can use to get started in a GUI-free world of software development. Most of the following tools do have learning curves, but once over the initial hurdle, you can expect to be quicker and more proficient in your development work.
Can be used in place of: Bash, Fish, etc.
Usually Mac and some Linux machines will come with Bash as their default shell (the program that takes your commands from the keyboard and gives them to the operating system to perform).
Zsh is a fairly similar shell to Bash except if offers a lot more customisability with much less of a barrier to entry. Paired with frameworks like oh-my-zsh you can really fine tune Zsh to meet your own specific needs and workflow.
Zsh also arrives out of the box with a couple helpful features like programmable autocompletion, customisable prompts, shared command history across terminal sessions, and even some spelling correction, which all help your time in the terminal be fast and efficient.
Can be used in place of: Atom, Sublime Text, etc.
Vim is a different text editor to Atom or Sublime Text, in that it doesn’t let you use the mouse to navigate, and most tasks are done with keyboard shortcuts. Vim’s main benefits are speed and efficiency. Starting out, it runs within the terminal itself, and is much quicker to load up than other editors, like Atom which is built on electron, coming in handy if you want to make quick changes to a lot of files in different directories, or are SSHed (securely accessing a remote computers terminal) into another computer and don’t have access to a GUI.
Vim’s biggest hurdle is also its greatest strength. It does not allow input via the mouse and instead, all navigation and editing must be done via the keyboard. Vim has a lot more features and customisation that make it one of the quickest and most efficient editors, whilst still being lightweight resource-wise.
For a quick guide on getting started with Vim, check out this article by Leo Allen from Makers Academy.
Vundle is a useful plugin manager for Vim. It lets you add a lot of extra functionality to Vim with not a lot of effort. You can browse a curated list of vim plugins at VimAwesome. A couple of my personal favourites are:
- ctrlp: a fuzzy file finder
- NERDcommenter: quickly comment out blocks of code with a shortcut
- vim-markdown-preview: preview what your markdown file will look like, useful when writing README’s and checking how they will look before uploading to say Github
Vim by default doesn’t show a file tree of your directory like most GUI editors, and is instead hidden behind a command :Explore. Running this will change the current buffer to a view of the files/folders in the current directory. From here you’re able to navigate up and down as well as creating and deleting files using ‘%’ and ‘D’, respectively. If you’d still prefer a more traditional file tree, the same author of NERDcommenter makes a vundle plugin, NERDtree, that I’ve used in the past and can also recommend.
Most GUI editors offer some functionality to be able to search inside some/all files within a given directory, for a specific word or phrase.
Using :vimgrep, you’ll able to achieve similar results. For example, if you wanted to search for the function called setPermissions, you could do :vimgrep /setPermissions/j ** | copen.
The j flag tells vim to open the current buffer to the first instance of ‘setPermissions’. The ** argument tells vimgrep to search through the entire directory and all subdirectories. The pipe into copen opens up a short buffer below the current one, that shows a list of all instances of ‘setPermissions’ and their location.
Tmux is a terminal multiplexer that lets you easily switch between multiple programs running in one terminal. This means you get a level of window management within the terminal itself, like split panes, tabs etc, without having to use the native features of your terminal emulator. You can also detach and reattach tmux sessions if you close your terminal emulator, allowing a persistent layout.
Here’s a little cheat sheet I refer to when I forget a couple commands.
Tmuxinator is immensely helpful on top of Tmux, it allows you to create profiles that will open up Tmux split panes and tabs in a pre-defined layout, as well as running commands within them on initialisation. This means that for each project you’re working on, you’re able to run one command e.g. tmuxinator todo-list and instantly have all your tabs and panes ready to go.
One of my preferred layouts is to have 4 tabs with the following:
- Tab 1: main editor pane using Vim
- Tab 2: 2 vertically split panes for running end-to-end tests and unit tests
- Tab 3: 4 tiled panes running backend and front end application servers
- Tab 4: empty prompt in the project directory for any other commands I may need to run
Tmuxinator greatly aids efficiency when switching between project, and I’d definitely recommend getting this set up once you know your way around Vim and Tmux.
Can be used in place of: Finder
I see a lot of devs still using macOS’ Finder to search through directory and copy/paste/move files about. A much quicker way of doing these actions I’ve found is using Ranger. Available through homebrew, Ranger allows you to run the ranger command and instantly be shown a 3 column split. In the left column, your parent directory, in the middle, your current directory, and in the right, the contents or file preview of whatever directory/file you are hovered over in the middle column.
It uses Vim keybindings to navigate around ( hjkl for left/down/up/right, y for copy, p for paste etc) and I’ve found it to be much quicker than both the finder, and using regular terminal commands for any directory/file manipulation, like creating/deleting/copying/pasting/moving.
In summary, GUI interfaces will always have their place in the dev tool world; they’re easier to pick up, and more intuitive to use. However, if you want to focus on improving speed and efficiency, as well as running less resource-intensive programs on your machine, you may see a benefit switching to the command line for your software development work.
Some other useful CLI programs:
- cmus: A CLI-based music player for UNIX.
- haxor-news: Browse Hacker News in the console.
- htop: Interactive process viewer for UNIX.
- httpie: Command line HTTP client.
- jira-terminal: JIRA ticket info in the terminal.
- khal: CLI calendar application.
- masterpassword: Cross-platform password generator that uses no cloud storage or vault.
- mpsyt: Terminal based Youtube player.
- mpv: Open-source cross-platform media player.
- mutt: A small but very powerful text-based email client for Unix.
- nmtui: A text user interface network configuration tool.
- openvpn: Open-source software application that implements virtual private network techniques.
- rtv: Browse reddit from your terminal.
- sconsify: Spotify console application.
- screenkey: A screencast tool to display your pressed keyboard keys.
- screen: A full-screen window manager that multiplexes a physical terminal between several processes.
- speedtest-cli: A command-line interface for testing internet bandwith speed using speedtest.net.
- wavemon: A CLI-based wireless device monitoring application.
Some fun CLI scripts:
Graduate Developer (Edinburgh)
Kickstart your career in tech, building innovative web applications and software solutions with the latest technology and Agile development methodologies.I'm Interested
Tech Lead (Edinburgh)
Bring your expert tech knowledge to the table to influence the direction of projects, whilst coaching and your team through engineering best practices.I'm Interested
Squad Lead (Edinburgh)
Lead and inspire a squad to succeed, bringing your passion for managing and developing people through career coaching and mentoring.I'm Interested