def completions(self, text, cwd, context=None): bc = BuiltinCompleter() for completion in bc.completions(text, cwd, context=context): yield completion aliases = AliasRegistry.getInstance() for alias in aliases: compl = self._match(alias.name, text, alias) if compl: yield compl textpath = FilePath(text, cwd) expanded_textpath = path_expanduser(textpath) (text_dpath, text_prefix) = os.path.split(expanded_textpath) if text.find('/') >= 0 or text.startswith('.' + os.sep): pc = PathCompleter() for completion in pc.completions(text, cwd): fobj = completion.target if fobj.is_directory or fobj.is_executable: yield completion else: fs = Filesystem.getInstance() for dpath in fs.get_path_generator(): if not os.access(dpath, os.X_OK): continue for fpath in iterd_sorted(dpath): fname = unix_basename(fpath) if not fname.startswith(text_prefix): continue fobj = fs.get_file_sync(fpath) if fobj.is_executable: yield _mkfile_completion(text, fpath, fobj)
def __help_all(self): pbcache = PixbufCache.getInstance() self._buf.insert_markup('Hotwire <i>%s</i>\n\n' % (__version__,)) self._buf.insert_markup(_('Documentation on the web: ')) self._buf.insert_markup(' ') self.append_link(_('Tutorial'), 'http://code.google.com/p/hotwire-shell/wiki/GettingStarted0700') self._buf.insert_markup(' ') external_pixbuf = pbcache.get('external.png', size=10) self._buf.insert_pixbuf(self._buf.get_end_iter(), external_pixbuf) self._buf.insert_markup('\n\n') registry = BuiltinRegistry.getInstance() for (setname,builtins) in zip((_('User'), _('Standard'), _('System')), map(list, [registry.user_set, registry.hotwire_set, registry.system_set])): if len(builtins) == 0: continue self._buf.insert_markup('<larger>%s:</larger>\n' % (_('%s Builtin Commands' % (setname,)),)) builtins.sort(lambda a,b: cmp(a.name, b.name)) for builtin in builtins: self.__append_builtin_base_help(builtin) self.__append_builtin_aliases(builtin) self.__append_builtin_arghelp(builtin) self.__append_builtin_doc(builtin) self._buf.insert_markup('\n') self._buf.insert_markup('<larger>%s:</larger>\n' % (_('Languages'),)) langreg = PipelineLanguageRegistry.getInstance() hotwire_lang = langreg['62270c40-a94a-44dd-aaa0-689f882acf34'] python_lang = langreg['da3343a0-8bce-46ed-a463-2d17ab09d9b4'] self.__append_language(hotwire_lang) self.__append_language(python_lang) languages = list(langreg) languages.sort(lambda a,b: cmp(a.langname, b.langname)) for language in languages: if language in [hotwire_lang, python_lang]: continue self.__append_language(language) self._buf.insert_markup('\n<larger>%s:</larger>\n' % (_('Aliases'),)) aliases = list(AliasRegistry.getInstance()) aliases.sort(lambda a,b: cmp(a.name,b.name)) for alias in aliases: self._buf.insert_markup(' <b>%s</b> - %s\n' % tuple(map(gobject.markup_escape_text, (alias.name, alias.target))))
# THE USE OR OTHER DEALINGS IN THE SOFTWARE. import os, sys from hotwire.cmdalias import AliasRegistry default_aliases = { 'su': 'term su', 'vi': 'term vi', 'vim': 'term vim', 'gdb': 'term gdb', 'man': 'term man', 'info': 'term info', 'most': 'term most', 'less': 'term less', 'more': 'term more', 'ipython': 'term ipython', 'top': 'term top', 'iotop': 'term iotop', 'htop': 'term htop', 'powertop': 'term powertop', 'nano': 'term nano', 'pico': 'term pico', 'irssi': 'term irssi', 'mutt': 'term mutt', 'nethack': 'term nethack', } aliases = AliasRegistry.getInstance() for name, value in default_aliases.items(): aliases.insert(name, value)
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR # THE USE OR OTHER DEALINGS IN THE SOFTWARE. import os,sys from hotwire.cmdalias import AliasRegistry default_aliases = {'su': 'term su', 'vi': 'term vi', 'vim': 'term vim', 'gdb': 'term gdb', 'man': 'term man', 'info': 'term info', 'most': 'term most', 'less': 'term less', 'more': 'term more', 'ipython': 'term ipython', 'top': 'term top', 'iotop': 'term iotop', 'htop': 'term htop', 'powertop': 'term powertop', 'nano': 'term nano', 'pico': 'term pico', 'irssi': 'term irssi', 'mutt': 'term mutt', 'nethack': 'term nethack', } aliases = AliasRegistry.getInstance() for name,value in default_aliases.iteritems(): aliases.insert(name, value)