Colorized “qs_launcher.py”

You can download the original file here: qs_launcher.py

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python
# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; coding: utf-8 -*-
"""
qs_launcher.py
~~~~~~~~~~~~~~

:copyright: 2010 Serge Émond
:license: Apache License 2.0

"""

import sys
import os

from qslaunch import execute
from qslaunch.helpers import iterm
from qslaunch.utils import finder

commands = [
    # Local
    (r'^local$', iterm.bookmark('A Local Shell', 'tab')),
    (r'^local-finder$', iterm.bookmark('A Local Shell', 'tab', cd=finder.front_most_path)),
    
    # ssh to "XX.example.org."
    (r'^s-(?P<server>[^\.]*)$', iterm.shell_exec('ssh %(server)s.example.org.', 'tab')),
    # ssh to full server name with '.' added
    (r'^s-(?P<server>.*)$', iterm.shell_exec('ssh %(server)s.', 'tab')),
    
    # Stuff
    (r'^gnuplot$', iterm.shell_exec('/bin/bash -l -c gnuplot'))
]

def main():
    # Strip path
    command = os.path.basename(sys.argv[0])
    if command[-3:] == '.py':
        # Strip '.py' extension
        command = command[0:len(command)-3]
    execute(command, commands)


if __name__ == '__main__':
    try:
        main()
    except Exception as e:
        from qslaunch.utils.growl import growl_error
        growl_error("QS Launch Helper", e.args[0])
        raise