Adam's UNIX shell environment
This is my collection of UNIX shell configuration files and utilities. These days I only use them with zsh and bash on Linux, but in the past I also used them on various Solaris and FreeBSD machines, and for the most part they should work on any POSIX-oriented UNIX.
Configuration files for zsh
.zshrc- config for interactive instances only
.zshenv- config for non-interactive and interactive instances
Configuration files for bash
Configuration files to be shared by any Bourne-compatible shell
Mechanism for automatically switching between shells.
Useful for when you do not have root privileges and want to run a locally compiled version of
zshrather than a system-wide shell. See:
lib/perl5/Sh.pmproviding some handy native Perl replacements for shell-like operations.
Hook-runner mechanism for building composite configuration out of multiple files in a
foo.d/hierarchy. For more information see:
.zsh/functions/find_hooks- find applicable hook files underneath
.zsh/functions/run_hooks- run hook files found by
find_hooks, assuming that they contain shell code
lib/libhooks.sh- concatenate hook files found by
find_hooksinto a single configuration file which can then be consumed by an external program such as
Configuration files for various commonly used UNIX utilities and libraries:
Useful utility and wrapper scripts under
AC-online- Determine if we are running off battery.
AC-state- Determine AC power adapter state.
abs- Convert a relative path to absolute path(s) with all symlinks resolved.
active-since- Determine whether I've touched the keyboard since a given time.
age-of- Show the age in seconds of a running or completed command run under the
age-track- Track the start and end times of a command, ensuring against concurrent invocations. Useful as a helper for asynchronous process invocations.
alertme- Poor man's attention grabber.
beep- Make some kind of noise reliably.
bip- Wrapper around
playto generate a sine wave of a given frequency / duration / volume.
bsplit- Split a file or STDIN into buckets.
c3- Show 3 months of the calendar.
cg- Shortcut for
clip- Copy a symLink In Place - converts a symlink to a real file. Suspiciously similar to
cm- Shortcut which allows you to omit
chmod 775 foocommand lines.
count-dirents- Count the number of files in a bunch of directories.
cp-merge- Copies the entire contents of one directory to another, even if some subdirectories are common to both source and destination directories. See also
crypt- Generate a hashed password.
sort(1)helper which allows custom sort orders based on string/regexp matching
cy- Show a whole calendar year.
dbm- Simple DBM file reader/writer
ls -lis to
diff-inodes- Compares output of
dump-inodes(below) with inode details in another tree.
diff-less- Wrapper around
lessfor viewing output from
colour-diff-output. Used by
div- Echo a highly visible divider.
dts- Runs a command, date/time-stamping each line of STDOUT.
duwith maximum depth 1
duwith maximum depth 2
dump-inodes- Dump machine-readable inode meta-data via
findfor use with
dutree- Print sorted indented rendition of du output.
dwatch- Simple monitor to watch for when things change.
edate- Show seconds since UNIX epoch.
fbig- Find big files.
fds- Shortcut to
feed- Feed keystrokes to a command then interact with it as normal. Requires Perl's
file-datestamp- Produce a date-stamp suitable for use within filenames.
find-wan-gateway- Find upstream WAN's gateway. See also
fs-monitor- Poll a filesystem via
fswap- Swap the names/contents of two files.
ftrace- Shortcut for
strace -e trace=file.
glob-to-re- Filter to convert globs into regexps.
grep-shortcuts- Provide handy egrep shortcuts, e.g.
gilris equivalent to
egrep -i -l -r
gw-dev- Detect the default gateway's network interface.
gw-dev-IP- Detect the IP of the default gateway's network interface.
harden-ln- Suspiciously similar to
hex- Convert numbers to hexadecimal.
ifw- Show a concise summary of network interface information.
isup- Check whether a machine is pingable.
keepalive- Keep an ssh session alive (for port forwarding) via
keymap-menu- OOB mechanism for switching between keyboard layouts.
lesspipe.sh- My personal
lh- View recent logins.
logseek- Jump to a date/time within a large log file.
lsofby pid or command.
mnt-image- Mount a file containing a filesystem via loopback.
mnt-initrd- Mount a Linux initial ram disk image via loopback.
mnt-isos- Mount ISOs in
mnx- Make file(s) non-executable.
mnp- Make file(s) non-public.
mp- Make file(s) public.
multi-syphon- Wrapper around
[syphon](https://github.com/aspiers/shell-env/blob/master/bin/syphon) -i(see below).
mv-merge- Moves the entire contents of one directory to another, even if some subdirectories are common to both source and destination directories. See
mx- Make file(s) executable.
newer- Returns true if a file is newer than the given age.
nth- Return the nth line of file(s).
ntrace- Shortcut for
strace -e trace=network.
ord- Show decimal/octal/hex values of ASCII characters.
bping- Wrapper around ping to make it do a lot of beeping ;-) Pitch of beeps represents latency: concert A (440Hz) for 10ms, going one octave up or down for every order of magnitude.
pinggw- Ping the gateway.
pingns- Ping a nameserver.
pingwan- Ping the WAN gateway found by
protect- UNFINISHED: make a process hard to kill
quietrun- Run a command and only allow output if the exit code didn't reflect success. Useful when writing crontab files, so that you only get e-mailed when something goes wrong.
ra- List unusual processes.
ra.pats- Data file for
racontaining patterns matching "usual" processes.
ran- Advanced replacement for
rcslocks- Check RCS-controlled files for locks, and optionally nag the lock owners via e-mail.
resolver-domain- Extract the resolver domain name from
pswrapper which searches for specific processes. (Its etymology was forgotten long ago...)
rjd- Search for processes in
D(non-interruptible) state (Linux-only).
rm-src-dups- Remove duplicate files from a mirrored directory hierarchy.
expectscript for logging in as root and then loading my shell config.
rot13- ROT13 filter
rotate- Losslessly rotate JPEGs.
rpath- Extract RPATH from object files.
safe-pipe- Pipe through a command with fallback.
service-commands- Shortcuts for starting/stopping/restarting Linux system services.
sfind- Find source files or links, using
show-colours- Show all ANSI 3-bit console colours (foreground and background).
shuffle- Fisher-Yates shuffle lines from STDIN.
so- Prune a list of files using
sort-by-filename- Sort list of newline-separated paths by basename (filename ignoring path segments).
sparse- Show sparseness of files.
split-by-boot- Split syslog messages from STDIN into a new file per system boot.
syphon- Removes lines from top of a file based on pattern matching.
tailfgrep- Monitor a file à la
tail -f, looking for a given regexp.
tail -fshortcut. When only tailing a single file, uses
less +Fwhich is nicer.
tfs- Similar to
tfbut truncates long lines.
timeout- Run a command with a timeout.
trim-lines- Truncate long lines of STDIN, taking non-printing escape sequences (e.g. colour) into account.
trim-whitespace- Trim leading/trailing whitespace from STDIN.
tty-colour-diff- Filter for viewing diff output. If connected to a tty, provides glorious technicolour and paging via
udate- Show human-readable version of UNIX epoch time.
uidle- Finds the session with the smallest idle time corresponding to the specified user and by default outputs the number of seconds idle.
umnt-initrd- Unmounts an initrd image mounted via
mnt-initrd, generating a new initrd file.
up- Safely unpack an archive file. Supports multiple formats.
up-since- Show when the system was last booted.
url-handler- Handler for opening various types of URLs
viz- Customisable change-control wrapper around an editor - a bit like
visudoetc. but with validation mechanism implemented by the user.
waitpid- Wait for a PID to finish.
waitproc- Wait for a command to finish (uses
watch, but output in diff format
ps -O wchanshortcut.
wget-monitor- Simple URL monitor.
whenup- Wait for a host to become pingable and then alert or take some action.
wl- Show the contents of an executable script on
xauth-user- Give another user access to this
zipseqs- Take two or more sequences and 'zip' them together (in the functional programming sense).
This repository is designed to be stowed directly into your home directory:
git clone git://github.com/aspiers/shell-env.git stow -d . -t ~ shell-env
However if you only want to cherry-pick bits and pieces then you can easily just copy or symlink them in manually. Just be aware that some of the files depend on other files, especially the shell configuration files.
The software in this repository is free software: except where noted otherwise, you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.