Typically, you would use mysql client cli as follows, You could also create a ~/.my.cnf file to set default properties, including connection info, You could even store a password but I wouldn’t recommend storing it in the clear. Also, the above approach is not useful when you have more than one MySQL database across multiple hosts, […]

bash histogram

I would like to generate a streamable histgram that runs in bash. Given an input stream of integers (from stdin or a file), I would like to transform each integer to that respective number of “#” up to the length of the terminal window; in other words, 5 would become “#####”, and so on. You […]


I would like to remotely control my Linux desktop via an ssh connection (connected through my phone). Fortunately, we can use xdotool. I created a simple command-interpreter that maps keys to xdotool. I used standard video game controls (wasd) for large mouse movements (100px), with smaller movements available (ijkl 10px). It can toggle between mouse […]

datsize, simple command line row and column count

Lately I’ve been working with lots of data files with fixed rows and columns, and have been finding myself doing the following a lot: Getting the row count of a file, twarnock@laptop:/var/data/ctm :) wc -l lda_out/final.gamma 3183 lda_out/final.gamma twarnock@laptop:/var/data/ctm :) wc -l lda_out/final.beta 200 lda_out/final.beta And getting the column count of the same files, twarnock@laptop:/var/data/ctm […]

vim and screen, automagic titles

Previously, I discussed using multiuser screen so that I could concurrently access a shared screen session across multiple remote hosts (from work, from home, from my phone, etc). I would like to augment screen such that the titles would always tell me what directory I’m currently in, as well as what program is running (if […]

multiuser screen

Previously, I discussed using GNU screen as a window manager. I would like to access my screen session concurrently from multiple hosts (say, at work, at home, and even remotely on my phone). I would also like to define default screens specific to one host. Default screens can be configured easily in the .screenrc in […]

chaining ssh tunnels

Imagine you’re working within a private home network and need to connect to an Oracle database within a corporate network accessible only through a bastion host hidden within the corporate network. Odd as that sounds, it’s a typical network configuration, as follows: The layout is very simple, when you’re within the corporate network you must […]

screen and screenrc

I would like to use GNU screen as a window manager. By default screen seems like little more than a persistent shell (that you can resume even after logging out). By itself, this is incredibly useful if you wish to access the exact same terminal session from different locations. For example, on the command-line you […]

nohup &

I would like to run a script in the background and to keep running even after I log out. To run a command or script in the background use an ampersand, e.g., # ./ & This is equivalent to suspending the process with Ctrl-Z, and then issuing bg, # ./ ^Z [1]+ Stopped ./ # […]

smiley shell prompt, or frown

I’ve been using the following command prompt for years server ~/dir :) whoami victor server ~/dir :) badcommand -bash: badcommand: command not found server ~/dir :( echo sorry sorry server ~/dir :) It’s a smiley emoticon, but only when the previous command returned without error. If the exit code (stored in $?) returns any kind […]