Category Archives: shell tips

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 :) … Continue reading

Posted in bash, shell tips | Comments Off on datsize, simple command line row and column count

Getting the most out of your ssh config

I typically find myself with voluminous bashrc files filled with aliases and functions for connecting to specific hosts via ssh. I would like an easier way to manage the various ssh hosts, ports, and keys. I typically maintain an ssh-agent … Continue reading

Posted in shell tips, ssh | Comments Off on Getting the most out of your ssh config

git, obliterate specific commits

I would like to obliterate a series of git commits between two points, we'll call these the START and END commits. First, determine the SHA1 for the two commits, we'll be forcefully deleting everything in between and preserving the END … Continue reading

Posted in shell tips | Comments Off on git, obliterate specific commits

vim: Visual mode

I have been using vim for years and am consistently surprised at the amazing things it can do. Vim has been around longer than I have been writing code, and its predecessor (Vi) is as old as I am. Somehow … Continue reading

Posted in shell tips, vim | Comments Off on vim: Visual mode

vim: tags and tabs

Previously, I discussed using vim and screen with automagic titles. The great part about working with vim and screen is that I can work from anywhere with minimal setup, and when working remotely I can pick up the cursor exactly … Continue reading

Posted in shell tips, vim | Comments Off on vim: tags and tabs

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 … Continue reading

Posted in bash, shell tips, vim | Comments Off on vim and screen, automagic titles

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 … Continue reading

Posted in bash, shell tips | Comments Off on multiuser screen

scripting Photoshop for stop motion

I would like a simple and quick way to save a copy of an image in Photoshop, with an auto-incrementing filename. Ideally, a single button to capture a frame in a stop motion animation. In other words, I would like … Continue reading

Posted in html, javascript, shell tips | Comments Off on scripting Photoshop for stop motion

locking and concurrency in python, part 2

Previously, I created a "MultiLock" class for managing locks and lockgroups across a shared file system. Now I want to create a simple command-line utility that uses this functionality. To start, we can create a simple runone() function that leverages … Continue reading

Posted in python, shell tips, software arch. | Comments Off on locking and concurrency in python, part 2

zip archive in python

I would like to create zip archives within a python batch script. I would like to compress individual files or entire directories of files. You can use the built-in zipfile module, and create a ZipFile as you would a normal … Continue reading

Posted in python, shell tips | Comments Off on zip archive in python

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, … Continue reading

Posted in bash, shell tips, ssh | Comments Off on chaining ssh tunnels

timeout command in python

I would like to add a timeout to any shell command such that if it does not complete within a specified number of seconds the command will exit. This would be useful for a any long-running command where I'd like … Continue reading

Posted in python, shell tips | Comments Off on timeout command in python

sqlplus, utility scripts

I would like to use sqlplus in development projects, and I would like it to be easy to use. First off, I want command-history and tab-completion. The easiest approach is to use rlwrap which uses the GNU readline library as … Continue reading

Posted in oracle, shell tips | Comments Off on sqlplus, utility scripts

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 … Continue reading

Posted in bash, shell tips | Leave a comment

sqlplus pagesize and linesize

I would like sqlplus output to be more readable. Fortunately, you can adjust the pagesize and linesize variables on the fly, e.g., foo_owner@FOO> set pagesize 50000 foo_owner@FOO> set linesize 120 You can set pagesize to 0, which is very useful … Continue reading

Posted in oracle, shell tips | Leave a comment