A collection of Bash utility shell-scripts that I thought must be useful to others.
- _include.sh
- deldiff
- delemptydirs
- kurl.sh
- lpath
- ssh-addauth
- ssh-list
- touchdir
- tree
- deduppath.sh
- deldiffdir
- diffcolored
- diffdir
- fssync-build.sh
- fssync.sh
- Git subcommands
Scripts which are intended to be run from the command-line are marked as executable. Generally, those which are not intended to run from the command line use the .sh suffix. They, of course, can still be run by invoking them via the shell command:
$SHELL myscript.sh
When this writeup describes the usage of a script, parameters in brackets […], indicated optional parameters.
Common settings and functions for use in other scripts so that I don't have to keep rewriting this stuff for every script. It turns out that I don't use it as much as I thought I would, because I don't like to have too many dependencies in scripts.
- ANSI color settings
echo_tabs_align()
echo_align_column()
— Output text padded with tabs necessary to create a fixed-width "column".is_command()
— A silent (and consistent way) to determine if the specified command is accessible.
Delete duplicate files from this "current" or "remote" directory. This iterates over all files in the current directory, looking for matches in the remote directory (based on files of the same name). Matches are determined by diff'ing the files. Matching files are deleted from either the current or remote directory; you are prompted before deleting begins.
deldiff [switches] {remote_directory}
- remote_directory
- is a relative or absolute directory path.
- switches are:
- -c
- No prompt which directory to delete files from, delete the ones in the "current" directory.
- -r
- No prompt which directory to delete files from, delete the ones in the "remote" directory.
- -t
- "Test" only... do not delete any files.
- -n
- "No test", simply prompt (unless `-c` or `-r` are set) which directory to delete from.
Remove empty directories under the specified dir (or current dir)
Provides functions to perform curl
command calls, returning HTTP response
data and the http response code. You can call this script from the command line to run curl from the command line in a different manner and/or to see how the functions will perform within another script.
List the path components of an environment variable (default uses PATH).
lpath [ env_var ]
- env_var
- Name of the environment variable to list paths of (default, PATH)
Add specified .pub key to remote server
ssh-addauth [ -i priv_key.pem ] [host] public_key_file...
- remote
- Remote server (as would be specified to ssh)
- public_key_file
- normally a .pub file.
A pretty list of ssh keys that this login has enabled for access (as indicated by authorized_keys
).
Set directory's time/date based on the newest content within it.
touchdir [switches] [target-dir]
- target-dir
- The directory to set. Default is `.`
- -a
- Check "all" files, i.e., dot-files, for latest date/time.
- -r
- Recurse, setting all directories' date/times within the target directory tree.
Display tree structure
Remote deplicate paths from "path" environment varialbes like PATH
, MANPATH
, etc. This scripted must be sourced in order for changes to affect the calling environment.
source delduppath.sh MANPATH
Delete files in specified tree matching files and relative location in current tree based on file diff
ing. This script uses diffdir, recursively to perform comparisons.
deldiffdir /remote/path/to/compare
Output colored diff
diffcolored
Compare directories, omitting hidden directories (e.g., .git
)
When a filtered set of files change within the directory structure, a command is run. This is a rudamentary "watch" command.
fssync-build.sh
Sync select files to remote machine, mimicing the same relative directory structure
fssync.sh -f ...
Specify the remote server/directory root which matches the current directory as the local root.
Add modifed files to staging.
git addupdated
Add specified files to git-ignore list
git ignore name […name]
where:
- name
- is a file or directory