Пример #1
0
    def __tmuxify(self):
        """
        Create tmux objects here
        """

        # get default operations
        if 'default' in self.manifest.keys():
            default = self.manifest['default']

        if 'directory' in default.keys():
            os.chdir(os.path.expanduser(default['directory']))

        self.__raw_commands(default, 'before')

        # Loop through sessions and create
        for session in self.sessions:
            context = self.sessions[session]

            if '__default' in context.keys():
                if 'directory' in context['__default'].keys():
                    os.chdir(os.path.expanduser(context['__default']['directory']))

            tmux_instance = tmux(session)
            tmux_instance.new(context)
            tmux_instance.create()

        self.__raw_commands(default, 'after')

        # Attach to session if that was the only one created
        if len(self.sessions) == 1:
            os.system('tmux a -t %s' % (tmux_instance.name))
Пример #2
0
def respawn(hi, tmuxrc):
    #print 'DEBUG', hi
    #print 'DEBUG', hi['layout']
    rc = '-f %s '%tmuxrc
    ret = []
    try:
        session_exists = tmux('has-session -t '+hi['context'])[1]==0
    except ValueError, ve:
        session_exists = False
Пример #3
0
    print " %s files ide-descr.hackide          to list the resource files used by this IDE"%script_name
    print " %s templates                        to list the available task templates"%script_name

def respawn(hi, tmuxrc):
    #print 'DEBUG', hi
    #print 'DEBUG', hi['layout']
    rc = '-f %s '%tmuxrc
    ret = []
    try:
        session_exists = tmux('has-session -t '+hi['context'])[1]==0
    except ValueError, ve:
        session_exists = False
    if session_exists:
        print "[Reattaching to existing session %s]"%hi['context']
        try:
            ret = [ tmux('attach -t %s'%hi['context']) ]
        except ValueError, ve:
            print "An error occurred while sending command", ve.message
            return []
    else:
        print "[Spawning new session %s]"%hi['context']
        lcmd = layout2tmux()

        defensive_layout = lcmd[:1] # don't check for session before the new-session :)
        defensive_layout += map(lambda b: 'has-session -t '+get_context_name()+" ';' "+b, lcmd[1:])

        all_cmds = [ 'start-server' ]
        all_cmds += defensive_layout
        all_cmds += open(tmuxrc).xreadlines()
        all_cmds += hi['tmux']
        all_cmds += [ 'select-window -t %s:%s'%(get_context_name(), app_name), 'select-pane -t %s:%s.0'%(get_context_name(), app_name), 'attach -t %s'%(get_context_name()) ]