-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8bc3c24
commit e5d73e9
Showing
2 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |