Open thinlines opened 3 years ago
Hi, @thinlines! I'm happy to hear that you find the script useful. Thanks for your suggestion, it totally makes sense to make it customizable. Will be happy to accept a PR. How about simplifying to a bit to something like this:
diff --unified --recursive a/pmenu b/pmenu
--- a/pmenu 2021-07-06 01:33:36.554971843 +0800
+++ b/pmenu 2021-07-06 01:00:54.000000000 +0800
@@ -21,6 +21,7 @@
def get_args():
parser = argparse.ArgumentParser(usage="pipe newline-separated menu items to stdin and/or pass them as positional arguments")
parser.add_argument('item', nargs='*', help="the menu item text")
+ parser.add_argument('-q', '--query', default='', help="start with the given query")
parser.add_argument('-c', '--command', help="the shell command which output will populate the menu items on every keystroke ({} will be replaced by the current input text)")
parser.add_argument('-n', '--name', help="the cache file name with the most recently used items")
parser.add_argument('-p', '--prompt', help="the prompt text")
@@ -34,6 +35,14 @@
return args
def get_mru_path():
if not args.name:
return
@@ -268,7 +277,7 @@
if __name__ == '__main__':
args = get_args()
- query_text = ''
+ query_text = args.query
input_items = get_input_items()
mru_path = get_mru_path()
mru_items = get_mru_items(mru_path, input_items)
Hi! Great script, thanks for writing it. I wanted to be able to set the initial query string to make pmenu more useful in bash scripting, so I went ahead and made a few changes. It seems to work okay, though I'm barely a novice in python. Here's a patch:
Just thought I'd throw this on here in case anyone's interested. If you want me to submit a pull request, I'd be glad to. Thanks again!