Terminal info
auto-create new term if not exists
429914
public function term()
	{
		$terminal = Terminal::whereUserId($this->userId())->first();
		if (!$terminal) {
			$terminal = new Terminal;
			$terminal->user_id = $this->userId();
			$terminal->secret = md5($terminal->user_id . time() . uniqid());
			$terminal->mode = Terminal::C_STATE_OFFLINE;
			$terminal->save();
		}

		$this->make('term', compact('terminal'));
	}
662769
def create_new_item(*args)
      if block_given?
        new_item = yield(*args)
      else
        new_item = create(*args)
      end

      transform_item(new_item)
    end
298824
def handle_new(path, **kwargs):
    """"""
    log.info('new: %s %s' %(path, kwargs))
    repo = Local.new(path=path, **kwargs)
    return repo.serialize()
745628
def oh_my_zsh_auto_title():
    

    if 'SHELL' in os.environ and 'zsh' in os.environ.get('SHELL'):
        if os.path.exists(os.path.expanduser('~/.oh-my-zsh')):
            # oh-my-zsh exists
            if (
                'DISABLE_AUTO_TITLE' not in os.environ
                or os.environ.get('DISABLE_AUTO_TITLE') == "false"
            ):
                print(
                    'Please set:\n\n'
                    '\texport DISABLE_AUTO_TITLE=\'true\'\n\n'
                    'in ~/.zshrc or where your zsh profile is stored.\n'
                    'Remember the "export" at the beginning!\n\n'
                    'Then create a new shell or type:\n\n'
                    '\t$ source ~/.zshrc'
                )
571727
def add_command(self, cmd, name=None):
        
        name = name or cmd.name
        if name is None:
            raise TypeError('Command has no name.')
        _check_multicommand(self, name, cmd, register=True)
        self.commands[name] = cmd
1359529
def setterm(self, term):
        ""
        log.debug("Setting termtype to %s" % (term, ))
        curses.setupterm(term) # This will raise if the termtype is not supported
        self.TERM = term
        self.ESCSEQ = {}
        for k in self.KEYS.keys():
            str = curses.tigetstr(curses.has_key._capability_names[k])
            if str:
                self.ESCSEQ[str] = k
        # Create a copy to prevent altering the class
        self.CODES = self.CODES.copy()
        self.CODES['DEOL'] = curses.tigetstr('el')
        self.CODES['DEL'] = curses.tigetstr('dch1')
        self.CODES['INS'] = curses.tigetstr('ich1')
        self.CODES['CSRLEFT'] = curses.tigetstr('cub1')
        self.CODES['CSRRIGHT'] = curses.tigetstr('cuf1')
1250865
def cmd_create(self, name, auto=False):
        """"""

        LOGGER.setLevel('INFO')
        LOGGER.propagate = 0

        router = Router(self.database,
                        migrate_dir=self.app.config['PEEWEE_MIGRATE_DIR'],
                        migrate_table=self.app.config['PEEWEE_MIGRATE_TABLE'])

        if auto:
            auto = self.models

        router.create(name, auto=auto)
711845
def on_terminals(node, compiled_grammar)
      node.children.each do |child|
        name = process(child, compiled_grammar)

        if compiled_grammar.has_terminal?(name)
          compiled_grammar.add_error(
            "The terminal #{name.inspect} has already been defined",
            child.source_line
          )
        else
          compiled_grammar.add_terminal(name, child.source_line)
        end
      end
    end
1055679
def create_spawnve(original_name):
    

    def new_spawnve(mode, path, args, env):
        import os
        send_process_created_message()
        return getattr(os, original_name)(mode, path, patch_args(args), env)

    return new_spawnve
102338
def create_file_new_actions(self, fnames):
        """'"""
        if not fnames:
            return []
        new_file_act = create_action(self, _("File..."), 
                                     icon=ima.icon('filenew'),
                                     triggered=lambda:
                                     self.new_file(fnames[-1]))
        new_module_act = create_action(self, _("Module..."),
                                       icon=ima.icon('spyder'),
                                       triggered=lambda:
                                         self.new_module(fnames[-1]))
        new_folder_act = create_action(self, _("Folder..."),
                                       icon=ima.icon('folder_new'),
                                       triggered=lambda:
                                        self.new_folder(fnames[-1]))
        new_package_act = create_action(self, _("Package..."),
                                        icon=ima.icon('package_new'),
                                        triggered=lambda:
                                         self.new_package(fnames[-1]))
        return [new_file_act, new_folder_act, None,
                new_module_act, new_package_act]
1019805
def on_new_line(self):
        """"""
        self.set_cursor_position('eof')
        self.current_prompt_pos = self.get_position('cursor')
        self.new_input_line = False
1000181
def _clean_terminals(self):
        
        new_terminals = []
        for term in self.grammar.grammar_terminals:
            x_term = term.rfind('@')
            y_term = term.rfind('A')
            if y_term > x_term:
                x_term = y_term
            ids = term[x_term + 1:].split(',')
            if len(ids) < 2:
                """It'input_string a normal terminal, not a state"""
                new_terminals.append(term)
        self.grammar.grammar_terminals = new_terminals
1289112
public function newWithCreateTerm($term): self
    {
        $newTerm = Term::firstOrCreate($term);
        $this->term_id = $newTerm->id;
        $this->term()->associate($newTerm);
        $this->setTaxonomy();

        return $this;
    }
442246
def cli(ctx, pattern):
    """"""
    matches = utils.grep_commands(pattern)
    if matches:
        for cmd, desc in matches:
            click.secho("$ {} :: {}".format(cmd, desc), fg='green')
    elif matches == []:
        click.echo('No saved commands matches the pattern {}'.format(pattern))
    else:
        click.echo('No commands to show. Add one by `keep new`.')
148955
def auto_compilation(on=True):
    """"""
    if on:
        if coconut_importer not in sys.meta_path:
            sys.meta_path.insert(0, coconut_importer)
    else:
        try:
            sys.meta_path.remove(coconut_importer)
        except ValueError:
            pass
203138
def _make_name(current, new):
    '''
    
    '''

    current_tokens = current.split()
    new_tokens = new.split()

    new = ' '.join(
        new_token for new_token in new_tokens
        if new_token not in current_tokens
    )

    return '/'.join((current, new))
630995
private static Prompt createPrompt(Resource<?> currentResource)
   {
      // [ currentdir]$
      if (OperatingSystemUtils.isWindows())
      {
         List<TerminalCharacter> prompt = new LinkedList<>();
         prompt.add(new TerminalCharacter('['));
         for (char c : currentResource.getName().toCharArray())
         {
            prompt.add(new TerminalCharacter(c));
         }
         prompt.add(new TerminalCharacter(']'));
         prompt.add(new TerminalCharacter('$'));
         prompt.add(new TerminalCharacter(' '));
         return new Prompt(prompt);
      }
      else
      {
         List<TerminalCharacter> prompt = new LinkedList<>();
         prompt.add(new TerminalCharacter('[', new TerminalColor(Color.BLUE, Color.DEFAULT),
                  CharacterType.BOLD));
         for (char c : currentResource.getName().toCharArray())
         {
            prompt.add(new TerminalCharacter(c));
         }
         prompt.add(new TerminalCharacter(']', new TerminalColor(Color.BLUE, Color.DEFAULT),
                  CharacterType.BOLD));
         prompt.add(new TerminalCharacter('$'));
         prompt.add(new TerminalCharacter(' '));
         return new Prompt(prompt);
      }
   }