Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/usr/bin/env python3
import sys
import re
def jobs_line(string):
return re.match(
r"^\[(?P<id>\d+)\]\s+(?P<default>\+|-)?\s+(?P<state>.*?)\s+(?P<rest>.*)", string
).groupdict()
# I may need something more sophisticated in future
def is_vim(rest):
return "vim" in rest
if __name__ == "__main__":
if sys.stdin.isatty():
sys.stderr.write("Usage: jobs | {}".format(sys.argv[0]))
sys.exit(-1)
data = sys.stdin.read().strip().split("\n")
data = map(jobs_line, data)
for d in data:
if is_vim(d["rest"]):
print("fg %{id}".format_map(d))
sys.exit(0)
else:
print("/usr/bin/env vim")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.