Skip to content

Commit

Permalink
Added jman, my personal 'man' pages
Browse files Browse the repository at this point in the history
  • Loading branch information
JosephPecoraro committed May 11, 2008
1 parent 8bc3c24 commit e5d73e9
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
48 changes: 48 additions & 0 deletions jman
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash
# jman
# Sunday May 11, 2008
# Author: Joseph Pecoraro
# Email: joepeck02@gmail.com
# Version: 1.0

# Variables/States
outputType=cat
joemanDir="`echo $HOME`/bin/.joeman/"

# Usage string
usage="usage:`basename $0` [-l] progName\n\n\t-l\t\toutput with /usr/bin/less\n\tprogName\tEx. ruby, tr, awk, grep, ...\n"

# Bad number of arguments
if [[ $# -eq 0 ]] || [[ $# -gt 2 ]]; then
echo -e $usage
exit 1
fi

# If two params the first should be -c, ingore otherwise
if [[ $# -eq 2 ]]; then
if [[ "-l" == "$1" ]]; then
outputType=less
fi
shift
fi

# Ensure filename doesn't every have "../"
if [[ "$1" =~ / ]]; then
echo "Filename cannot contain '/'"
exit 1
fi

# Check for the existence of the filename
path="$joemanDir$1"
if [[ ! -e $path ]]; then
echo "$1: File does not exist."
exit 1
fi

# Print out the file
# $outputType is an element of {less, cat}
# $path is the full path to the joeman file
eval "$outputType $path"

# Successful
exit 0
7 changes: 7 additions & 0 deletions jman-changelog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Author: Joseph Pecoraro

Version 1.0: Sunday May 11, 2008
- usage:jman [-l] progName
- Directory of files is ~/bin/.joeman/
- Defaults to /bin/cat
- Currently the only option is -l which switches to /usr/bin/less

0 comments on commit e5d73e9

Please sign in to comment.