A Scripter's Notes โš

Emacs, scripting and anything text oriented.

A Better Less?

I use emacs – with a server1 and client setup – so that I can quickly open new files in it using emacsclient. My typical setup is to have xterm + tmux on one monitor and a single emacs(client) frame on another. But there are times when I do not want to shift focus from one monitor to another, like when I just need to review some log file. So I started using an alias to emacs -nw -Q to quickly open log files, review, filter, and C-x C-c.

Of course, that’s not where this post ends. An alias was no longer adequate to do what I wanted it to do more ..

Installing bleeding edge Hugo + Goorgeous

Update (2017/06/16)

Updated the github source references as per the changes in hugo v0.231. Also made the shell script ShellCheck-passing! ๐Ÿ™Œ ยง


You already got go installed, and that’s why are you reading it.

         If not – Go! Install it!

So.. now that you have go installed, why settle for the release version of hugo! You are reading this blog post generated using the bleeding edge of hugo2.

In addition, Hugo v0.19 onwards supports the org-mode syntax3, which is so much more awesome than markdown, especially if you are using emacs.

This post is about how you can install the latest versions of hugo and the go package that adds the org-mode support – goorgeous.

Installing go toolchain

There are 2 reasons why I suggest installing go to anymore, whether they are Go developers, or not (like me).

  1. You can then build amazing utilities like peco, hugo and noti.
  2. It’s easy!

Stuff about command-line ftp

To connect to a machine with ip MACHINE, you simply need to enter the below at command-line:

ftp MACHINE

See below for a list of commands you would typically use once you ftp to a machine.

Installing rust toolchain

Lately, I have come to know of a command line search utility called ripgrep, coded in rust, that is capable of faster code searches (at least for my use cases) than grep or ag. So I got interested in building the latest versions of rg (ripgrep binary name) directly from its github master branch rather than waiting for its release binaries.

So came the need to install the rust toolchain on my machine. Luckily, installing that was super easy; here are the steps:

Count Down Timer in Shell

I was working on a tcsh script that did some cool stuff. But if a user ran that script not knowing the true impact of the script, it could make some bad irreversible changes.

While I could simply echo a warning statement and put a sleep 10, I wanted the wait time to be shown live.

Optimize your .git

I was reviewing what was occupying the maximum disk space using the ncdu command line utility. One of the top candidates was the git clone of org-mode. It was using 2.4GB of my disk space!

Surprised by that, I started looking around1 if there was a way to optimize the cloned git repositories i.e. the .git/ directories. And sure enough, there was a way.

Check If a Command Exists from Shell Script

I often need to check if a particular executable is present in the PATH before I can proceed with what I am doing in a shell script. Also I need to work with both tcsh and bash scripts. Below presents the different solutions that have worked for these shell scripts for me.

Second Argument to basename

It is quite common knowledge that the basename command is used to get just the file name without its full path.

> basename /home/$USER/file.txt
file.txt

But what wasn’t common knowledge, at least to me, was that basename also accepts a second argument ..

Emacsclient on Windows

Using emacsclient instead of the emacs binary is a very useful technique to prevent loading emacs from scratch each time you open a new file. That technique is useful on Windows too. But for this to work on Windows, we need some more elisp and Windows environment variable configuration than just the below code,

(require 'server)
;; Start a server if (server-running-p) does not return t (e.g. if it
;; returns nil or :other)
(or (eq (server-running-p) t)
    (server-start))