create install mechanism

This commit is contained in:
glmdev 2018-11-30 14:23:45 -06:00
parent 64ff921a36
commit 44fff79e61
6 changed files with 41 additions and 8 deletions

View File

@ -13,7 +13,7 @@ This project is currently a work-in-progress. Only the fish shell is supported a
## TODO ## TODO
- Documentation/License - Documentation/License
- Installation & Generalization - Uninstaller & Updater
- Command Memory/Env Support - Command Memory/Env Support
- Double wh does an la, not ls - Double wh does an la, not ls
- directory history for ls'ing back - directory history for ls'ing back

View File

@ -1,3 +0,0 @@
function wh {
source <(python3 /home/glmdev/Projects/do_what/do_what.py $*)
}

View File

@ -1,3 +0,0 @@
function wh
python3 /home/glmdev/Projects/do_what/do_what.py $argv | .
end

View File

@ -8,7 +8,12 @@ import json
mime = magic.Magic(mime=True) mime = magic.Magic(mime=True)
# supported values: fish, bash, zsh # supported values: fish, bash, zsh
shell="fish" if ( 'DO_WHAT_SHELL' in os.environ ):
shell=os.environ['DO_WHAT_SHELL']
else:
print("echo Shell type not set. To set up the environment, add the following line to your shell\\\'s init file:")
print("echo dowhat {shell} \| .")
exit()
# Defaults # Defaults
print_file="cat" print_file="cat"

16
do_what_aliaser.py Normal file
View File

@ -0,0 +1,16 @@
import sys
if ( len(sys.argv) > 1 ):
shell = sys.argv[1]
if ( shell == "fish" ):
print("function wh")
print(" set -x DO_WHAT_SHELL fish")
print(" python3 "+interpreter_location+" $argv | .")
print("end")
elif ( shell == "bash" or shell == "zsh" ):
print("function wh {")
print(" export DO_WHAT_SHELL="+shell)
print(" source <(python3 "+interpreter_location+" $*)")
print("}")
else:
print("No shell specified.")

18
install.sh Executable file
View File

@ -0,0 +1,18 @@
#!/bin/sh
INSTALL_DIR=$(readlink -f $1)
# Make the installation directory
mkdir -p $INSTALL_DIR/do_what
mkdir -p $INSTALL_DIR/bin
cp ./do_what.py $INSTALL_DIR/do_what/interpreter.py
echo "#!/usr/bin/env python3" > $INSTALL_DIR/do_what/dowhat
echo "interpreter_location=\"$INSTALL_DIR/do_what/interpreter.py\"" >> $INSTALL_DIR/do_what/dowhat
cat ./do_what_aliaser.py >> $INSTALL_DIR/do_what/dowhat
ln -s $INSTALL_DIR/do_what/dowhat $INSTALL_DIR/bin/dowhat
chmod +x $INSTALL_DIR/do_what/dowhat
echo "End."