-
Power of the command line
Disclaimer: I am not advocating any specific tools or methodologies, but sharing a workflow I find to be efficient and pleasant.
I am a huge fan of working with CLI applications. I use Vim for editing code, composing emails, and various kinds of writing. When I have to manipulate huge amounts of email, I use Mutt: itās intuitive tagging and regular expression engine are extremely useful for the task. I employ
ack,awk,grep, andsed- Linux utilities which allow for precise and fast text manipulation.However, I would not use CLI browsers like
elinksorw3m, and the idea of reading every email in Mutt gives me the creeps. I love the visualization web browser offers, something text-based prompt is not able to provide. And it doesnāt have to.There are two components to most of the tasks performed on a computer: analyzing output and entering input. Certain tasks employ one component more than the other. In most modern applications itās rare to have both solid control from the user perspective and a pleasant informative UI. With increased visual component, itās more time consuming to make the application do what you need, especially if your needs are esoteric. With more editing power, visual display becomes less complex in order to make editing tasks easier.
Where visual tools fall short
What is the alternative? Using multiple programs with different levels of control to accomplish one task: to edit text. Each of the programs excels in itās own field: word processing software allows for beautiful fonts and document presentation, IDE lets you access aggregated meta information about your application. But most of the IDEs and word processors lack the powerful tools needed to manipulate the foundation of what user is working with - plain text.
Ode to plain text
I spend a lot of time writing and editing plain text. Be it source code, emails, documentation, or even blog posts. These tasks take up significant amount of my day, and it is only logical to substitute some of the visual presentation capabilities for effectiveness.
It is hard to mentally process data which is not explicitly and unambiguously visible: different levels of headings, hidden meta information. Unlike more obscuring formats, plain text is all there is - it has nothing to hide. If you donāt see it - itās not there. If you do see it - you know exactly what it is.
One of my favorite tips from āPragmatic Programmerā goes:
Use a single editor well
So I learned one editor well, and now I use it for all my writing and editing needs. I donāt have to jump between IDE, browser, and office software. Most of the text I edit is manipulated with one editor. There is only one set of key bindings to know, one skill to master and hone. Fast, without any additional thought, using single text editor and all of itās powerful features is imprinted in muscle memory. One less task to worry about.
I write my documents in Markdown format, and later convert them to the desired output using
pandoc: be it an HTML page, PDF, or a Microsoft Word document. I use Vim, so I can rearrange paragraphs or manipulate lines within a couple of keystrokes. Since I spend so much time editing text, I also touch type, which makes me even more effective at the given task.Harness the power of the command line
When it comes to bulk manipulating files or working with version control - there is no better candidate then command line applications. Thereās no need to go through a number of obscure menus, ticking and unticking checkboxes, and hoping that your desired result can be achieved with a programās GUI.
Letās look at a few scenarios some users face in their daily workflow.
Creating a backup
With GUI, youād have to take multiple steps:
- Right click
file. - Left click on āCopyā.
- Right click on some empty space.
- Left click on āPasteā.
- Right click on a newly created copy.
- Left click on āRenameā.
- Switch to a keyboard.
- Type
file.bak.
The above steps can be sped up using shortcuts like
C-corC-v, but not by much. Hereās an alternative in bash:cp file{,.bak}While first variant would do great for a novice or a casual user - the second method would be much more preferred by an experienced user whose concern is speed.
Recursively bulk replacing text in a directory
Letās assume we want to do a bulk replace text in a directory and all itās subdirectories. We have our trusted IDE, letās assume this IDE is already configured to work with a desired directory.
- Open your IDE.
- Select āEditā menu.
- Select āFind and Replaceā submenu.
- Click on a āFindā input field.
- Switch to a keyboard.
- Type
function_to_replace. - Switch to a mouse.
- Click on āReplaceā input field.
- Switch to a keyboard.
- Type
new_function_name. - Switch to a mouse.
- Enable āSearch in subdirectoriesā checkbox.
- Click āOKā.
Again, this can be shortened a bit with some keyboard shortcuts, but not by much. You still have to switch between keyboard and a mouse a total of 4 times, and you still have to click through all the menus. This does get time consuming if you do this often. Now letās try to perform the same task in command line:
find . -type f | xargs sed -i 's/function_to_replace/new_function_name/g'Much faster, if youāre able to memorize the structure. And remembering what the commands do is much easier than it looks. Especially with the help of
manor, even better,bro(see http://bropages.org for latter).The above example demonstrates one of the biggest advantages of command line interfaces: an ability to redirect an output of one program into another, chaining the tools together. In this example, we first get a list of all files use
findtool, and then runsedtool on each of those files in order to replace the text.An output from any CLI tool can be fed into any other CLI tool. This allows for countless possibilities and high adaptability to unscripted scenarios.
Is it worth learning CLI tools over their GUI counterparts?
This depends on what your intentions are. If youāre a power user who writes and edits a lot of text or manipulates bulk amounts of text on a daily basis - than itās definitely worth it. Time spent learning these tools will pay off. But if youāre a casual user whose needs end with writing an occasional email or two - then you probably donāt need to worry about this.
Hell, if youāve read this far - this means youāre the former case. I can practically guarantee that you will benefit from employing command line tools and modal editors over their GUI counterparts.
Iāve put together a table for comparison between two. Indeed, there are different times when either GUI or CLI tools excel:
Factor CLI GUI Ability to combine/chain tools Yes No Easy to learn No Yes Efficient for a novice user No Yes Efficient for an experienced user Yes No Good for occasional use No Yes Good for repetitive tasks Yes No Presents visual information well No Yes As you can see - both CLI and GUI programs have their pluses and minuses. CLI tools seem to appeal to experienced users, while GUI tools are great for novice users and do excel in representing visual information. No matter what kind of interface you prefer, itās crucially important to use the right tool for the job.
- Right click
-
Custom templates in vimwiki
I got myself into a habit of using vimwiki for the past year: it helps me to keep track of random bits of information, work and project notes, as well as daily goals and achievements. You can read more about vimwiki in an article I wrote a while back: āPersonal wiki with vimwikiā.

One of vimwikiās features I really like is an ability to convert whole wiki to HTML with a single command:
:VimwikiAll2HTML. There is one annoyance though: HTML vimwiki pages donāt have any navigation elements: the only way to navigate between pages is by clicking through links within a page or using browserās ābackā button.Luckily, vimwiki has a setting which allows using custom templates for generating HTML. Assuming your wiki is in
$HOME/Dropbox/wiki(can be anywhere else though), make following changes to your.vimrc:let g:vimwiki_list = [{ \ 'path': '$HOME/Dropbox/wiki', \ 'template_path': '$HOME/Dropbox/wiki/templates', \ 'template_default': 'default', \ 'template_ext': '.html'}]After that, create a
$HOME/Dropbox/wiki/templates/default.htmlusingvimwiki/autoload/vimwiki/default.tplas a base. I added simple navigation bar to my default template:<html> <head> <link rel="Stylesheet" type="text/css" href="%root_path%style.css" /> <title>%title%</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body> <a href="%root_path%index.html">Index</a> | <a href="%root_path%diary/diary.html">Diary</a> <hr> <div class="content"> %content% </div> </body> </html>Now itās much easier to jump between wiki entries. Of course, customization doesnāt end there: you can change styles, add JavaScript and make your wiki all fancy and advanced.
If youād like to get even better about using Vim, I wrote a book about it: Mastering Vim. Iām pretty proud of how it turned out, and I hope you like it too.
-
Contributing to an existing Octopress blog
I had to download my Octopress blog to a new machine today and the process of setting up didnāt go as smoothly as I expected. At the end of the day the setup turned out to be simple, and here are the steps:
git clone -b source https://github.com/username/username.github.io myblog cd myblog git clone https://github.com/username/username.github.io _deploy bundle installIn a nutshell, you have to manually add
_deployfolder set to trackmasterbranch of your Octopress repository. Otherwiserake deploycommand fails.Happy writing!
-
750 words a day
Iāve had increased interest in writing throughout this year. In addition to being a pleasant and fulfilling activity, it shown a number of benefits in my everyday life and career:
- Composing emails became faster and easier. When you have to reply to a couple of dozen emails a day, speed and attention to details matters. Writing more taught me to write more concise emails which are easy to read.
- Writing a lot isnāt a problem anymore. If I have to write documentation, comment code, or just put together a very long email - Iām not put off by the idea. Iām excited about it.
- Typing speed went up. I already touch type, and constant writing practice increases the acquired speed. Fast typing makes life easier, speeding up mundane tasks, freeing up brain power for more costly activities.
- Itās easy to keep a condensed work log to highlight the issues of the day. Tough programming issues, āEureka!ā moments, meeting notes - this historical data saved me hours or even days of repeating my mistakes.
A while ago, Iāve heard of a thing called ā750 wordsā, a site built around a challenge to write 750 words a day in order to improve writing skills and unleash creativity. This looked like a great idea, and I decided to give it a shot. I prefer to keep my personal entries offline, and I decided not to use the provided service, but to keep a set of plain text files on my local machine. Which worked out just fine. Itās all just text after all.
I lasted for 10 days in a row, which I am proud of (filling up approximately 3 pages a day was no easy task for me). I started of with silly entries about not knowing what to write about, and finished with a piece of a fiction story. Thatās a considerable improvement.
By the end of the challenge I was mentally exhausted. But it taught me a very important lesson: the more you write, the better you become. And thatās one of the main reasons I keep crafting new entries for this blog.
This happened half a year ago, I just never got around to writing about it. I will go ahead and start another 750 words spree today. Maybe this time Iāll be able to make it last for the whole month.
-
Beyond grep
I search for things a lot, especially in my code. Or even worse - someone elseās code. For years
grepserved as an amazing tool for this: fast, simple, and yet powerful. That was until I discoveredackfor myself. An incredibly easy to usegrepimplementation built to work with large (or not really) code trees.A lot can be said to enforce superiority of
ackovergrepwhen it comes to working with code, and itās all said here: ackās features.Amazing thing is -
ackdoesnāt even need a tutorial. Learning progression is natural and ājust happensā by researching necessary use cases as the need arises (ackhas a great manual entry).Hereās a typical use example for
ack:ack --shell 'gr[ae]y'Searches all shell script files in the current code tree for any occurrences of āgrayā or āgreyā. It will search
.sh,.zsh, and just about dot-anything;ackwill even check shebang lines for you.Ease of use, the fact that itās ready to use out of the box, extensive file types, native support for Perlās regular expressions:
ackdoes really good job at searching through code.Download it from Beyond grep.