Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modification to handle executing from alternate locations #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 11 additions & 7 deletions install.sh
@@ -1,8 +1,9 @@
#!/bin/bash
INSTALL_DIR=$HOME/bin
ALIAS_FILE=$HOME/.bashrc
prog="[""$(basename $0)""] "

THIS_SCRIPT=$(readlink -f $0)
CODE_DIR=$(dirname $THIS_SCRIPT)
prog="[""$(basename $THIS_SCRIPT)""] "

Usage(){
echo "Usage: $(basename $0) [options]"
Expand Down Expand Up @@ -53,22 +54,25 @@ while [[ $# -gt 0 ]] ; do
esac
done

[[ -d $INSTALL_DIR ]] || mkdir -p $INSTALL_DIR


#[[ -d $INSTALL_DIR ]] || mkdir -p $INSTALL_DIR
echo $prog"$INSTALL_DIR exists."

[[ -s $INSTALL_DIR/todo.py ]] && Update
#[[ -s $INSTALL_DIR/todo.py ]] && Update

[[ -s $ALIAS_FILE ]] || echo "# Bash RC File" >> $ALIAS_FILE
#[[ -s $ALIAS_FILE ]] || echo "# Bash RC File" >> $ALIAS_FILE
echo $prog"$ALIAS_FILE exists."
## Believe it or not, >> is faster than >.

echo $prog"Copying todo.py to $INSTALL_DIR/todo.py"
if [[ ! -f $INSTALL_DIR/todo.py ]] ; then
cp ./todo.py $INSTALL_DIR
cp ${CODE_DIR}/todo.py $INSTALL_DIR
else
cp -u ./todo.py $INSTALL_DIR
cp -u ${CODE_DIR}/todo.py $INSTALL_DIR
fi


## Establish alias
pre="\n\n#Alias for todo.py\n"
if grep -q -e "todo.sh" -e "todo.py" "$ALIAS_FILE" ; then
Expand Down
4 changes: 2 additions & 2 deletions todo.py
Expand Up @@ -715,8 +715,8 @@ def prepend_todo(args):
@usage('\thelp | h',
'\t\tDisplay this message and exit.\n')
def cmd_help():
print(concat(["Use", CONFIG["TODO_PY"], "-h for option help\n"], " "))
print(concat(["Usage:", CONFIG["TODO_PY"], "command [arg(s)]"], " "))
print(concat(["Use", os.path.basename(CONFIG["TODO_PY"]), "-h for option help\n"], " "))
print(concat(["Usage:", os.path.basename(CONFIG["TODO_PY"]), "command [arg(s)]"], " "))
d = {}
for (key, val) in commands.items():
d[val[1]] = (key, val[1])
Expand Down