From 3f9c3b61f2021e92bfc1bff8d49bcb40d9531fbc Mon Sep 17 00:00:00 2001 From: glmdev Date: Wed, 28 Nov 2018 21:59:06 -0600 Subject: [PATCH] add automatic vim sudo; remove example config file --- README.md | 1 - do_what.py | 5 ++++- what.config | 5 ----- 3 files changed, 4 insertions(+), 7 deletions(-) delete mode 100644 what.config diff --git a/README.md b/README.md index bf2d7d7..f3e1fe3 100644 --- a/README.md +++ b/README.md @@ -18,5 +18,4 @@ This project is currently a work-in-progress. Only the fish shell is supported a - Double wh does an la, not ls - Git Repo detection for ls - Clipboard functionality - - sudo vim - Binary File MIME Types diff --git a/do_what.py b/do_what.py index e3ee5df..3baab68 100644 --- a/do_what.py +++ b/do_what.py @@ -141,7 +141,10 @@ elif ( (not active and len(sys.argv) == 2) or (active and len(sys.argv) == 3) ): if ( is_binary_file(path) ): print("echo Binary file.") else: - print(edit_file+" "+path) + if ( os.access(path, os.W_OK) ): + print(edit_file+" "+path) + else: + print("sudo "+edit_file+" "+path) else: # check if file is a path program, then list using which/man on active diff --git a/what.config b/what.config deleted file mode 100644 index dcef7e5..0000000 --- a/what.config +++ /dev/null @@ -1,5 +0,0 @@ -[DEFAULT] -print_file = cat -pretty_print_file = less -R -edit_file = vim -list_directory = ls --color=auto