Browse Source

create install mechanism

glmdev 2 months ago
parent
commit
44fff79e61
6 changed files with 41 additions and 8 deletions
  1. 1
    1
      README.md
  2. 0
    3
      do_what.bash
  3. 0
    3
      do_what.fish
  4. 6
    1
      do_what.py
  5. 16
    0
      do_what_aliaser.py
  6. 18
    0
      install.sh

+ 1
- 1
README.md View File

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

+ 0
- 3
do_what.bash View File

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

+ 0
- 3
do_what.fish View File

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

+ 6
- 1
do_what.py View File

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

+ 16
- 0
do_what_aliaser.py View File

@@ -0,0 +1,16 @@
1
+import sys
2
+
3
+if ( len(sys.argv) > 1 ):
4
+	shell = sys.argv[1]
5
+	if ( shell == "fish" ):
6
+		print("function wh")
7
+		print("	set -x DO_WHAT_SHELL fish")
8
+		print("	python3 "+interpreter_location+" $argv | .")
9
+		print("end")
10
+	elif ( shell == "bash" or shell == "zsh" ):
11
+		print("function wh {")
12
+		print("	export DO_WHAT_SHELL="+shell)
13
+		print("	source <(python3 "+interpreter_location+" $*)")
14
+		print("}")
15
+else:
16
+	print("No shell specified.")

+ 18
- 0
install.sh View File

@@ -0,0 +1,18 @@
1
+#!/bin/sh
2
+
3
+INSTALL_DIR=$(readlink -f $1)
4
+
5
+# Make the installation directory
6
+mkdir -p $INSTALL_DIR/do_what
7
+mkdir -p $INSTALL_DIR/bin
8
+
9
+cp ./do_what.py $INSTALL_DIR/do_what/interpreter.py
10
+
11
+echo "#!/usr/bin/env python3" > $INSTALL_DIR/do_what/dowhat
12
+echo "interpreter_location=\"$INSTALL_DIR/do_what/interpreter.py\"" >> $INSTALL_DIR/do_what/dowhat
13
+cat ./do_what_aliaser.py >> $INSTALL_DIR/do_what/dowhat
14
+
15
+ln -s $INSTALL_DIR/do_what/dowhat $INSTALL_DIR/bin/dowhat
16
+chmod +x $INSTALL_DIR/do_what/dowhat
17
+
18
+echo "End."

Loading…
Cancel
Save