Testing exit values in Bash
In Bash scripting (and shell scripting in general), we often want to check the exit value of a command to decide an action to take after it completes, likely for the purpose of error handling. For...
View ArticlePrompt directory shortening
The common default of some variant of \h:\w\$ for a Bash prompt PS1 string includes the \w escape character, so that the user’s current working directory appears in the prompt, but with $HOME shortened...
View ArticleShell config subfiles
Large shell startup scripts (.bashrc, .profile) over about fifty lines or so with a lot of options, aliases, custom functions, and similar tweaks can get cumbersome to manage over time, and if you keep...
View ArticleCron best practices
The time-based job scheduler cron(8) has been around since Version 7 Unix, and its crontab(5) syntax is familiar even for people who don’t do much Unix system administration. It’s standardised,...
View ArticleCustom commands
As users grow more familiar with the feature set available to them on UNIX-like operating systems, and grow more comfortable using the command line, they will find more often that they develop their...
View ArticleBash hostname completion
As part of its programmable completion suite, Bash includes hostname completion. This completion mode reads hostnames from a file in hosts(5) format to find possible completions matching the current...
View ArticleShell from vi
A good sign of a philosophically sound interactive Unix tool is the facilities it offers for interacting with the filesystem and the shell: specifically, how easily can you run file operations and/or...
View ArticleVimways: From .vimrc to .vim
I’ve written a new article over on Vimways for the 2018 Vim advent calendar. It’s about converting a long and unwieldy .vimrc into a ~/.vim runtime directory.
View ArticleVimways: Runtime hackery
I’ve written another new article over on Vimways for the 2018 Vim advent calendar. This is a followup to my previous article, adding some more detail about ways to use Vim’s runtime directory structure.
View ArticlePassing runtime data to AWK
Shell script and AWK are very complementary languages. AWK was designed from its very beginnings at Bell Labs as a pattern-action language for short programs, ideally one or two lines long. It was...
View Article