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

Fixes #435: Validity check of terminal plugin optional #523

Open
wants to merge 1 commit 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions PluginDirectories/1/terminal.bundle/options.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
{
"options": [
{
"text": "Terminal Application:",
"type": "dropdown",
"key": "app",
"options": [
"text": "Terminal Application:",
"type": "dropdown",
"key": "app",
"options": [
{"text": "Terminal", "value": "terminal"},
{"text": "iTerm2", "value": "iterm2"},
{"text": "iTerm2.9+", "value": "iterm3"}
]
}
},
{
"type": "checkmark",
"text": "Validity check",
"key": "validity"
},
]
}
}
22 changes: 16 additions & 6 deletions PluginDirectories/1/terminal.bundle/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,34 @@ def get_html(command):
</style>
<body>
%s$ %s

<div id='hint'>
Will be run in the directory currently open in Finder.
</div>
</body>
"""%(getuser(), command)

def results(parsed, original_query):
command = parsed['~command'] if parsed else original_query
if command[0] not in '~/.' and not is_valid_command(command.split(' ')[0]):
return None
import json
settings = json.load(open('preferences.json'))

command = parsed['~command'] if parsed else ' '
if settings["validity"]:
if command[0] not in '~/.' and not is_valid_command(command.split(' ')[0]):
return None
if parsed is None:
dict['dont_force_top_hit'] = True
else:
prefix_split = original_query.split(' ')[0]
prefix_char = original_query[0]
if not (prefix_char == '$') and not (prefix_char == '>') and not (prefix_split == 'run'):
return None

dict = {
"title": "$ {0}".format(command),
"run_args": [command],
"html": get_html(command)
}
if parsed==None:
dict['dont_force_top_hit'] = True
return dict

def run(command):
Expand Down
5 changes: 3 additions & 2 deletions PluginDirectories/1/terminal.bundle/preferences.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"app" : "terminal"
}
"app" : "terminal",
"validity" : 1
}