Last active
February 9, 2019 09:28
-
-
Save userhooke/9edc37c44d543d9cfafe0df640455e1c to your computer and use it in GitHub Desktop.
Very simple bash script to create you own notes on how to use CLI tools
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
#!/bin/bash | |
# Very simple bash script to create you own notes on how to use CLI tools | |
dir=~/myman/.myman/ | |
editor=vi | |
# clear screen | |
clear | |
# check if .myman dir exists | |
if [ ! -d $dir ] | |
then | |
mkdir $dir | |
echo "Directory $dir created" | |
fi | |
# check if no args provided | |
if [[ $# -eq 0 || $# -gt 2 || $1 = "--help" || $1 = "-h" ]] | |
then | |
echo " | |
Usage: myman [command name] <note> | |
Commands: | |
edit - open editor to edit note | |
all - list all notes | |
search <search string> - grep through notes for a string | |
" | |
elif [[ $1 = "edit" ]] | |
then | |
$editor $dir$2 | |
elif [ -s $dir$1 ] | |
then | |
cat $dir$1 | |
elif [[ $1 = "all" ]] | |
then | |
ls -tlah $dir | |
elif [[ $1 = "search" ]] | |
then | |
grep -nr --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn} $2 $dir | |
else | |
$editor $dir$1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment