$VI_MODE = True $AUTO_PUSHD = True $XONSH_AUTOPAIR = True # tab selection: do not execute cmd when pressing enter $COMPLETIONS_CONFIRM = True xontrib load vox z def _last_exit_status(): try: exit_status = __xonsh_history__.rtns[-1] return exit_status if exit_status != 0 else None except IndexError: return None $PROMPT_FIELDS['last_exit_status'] = _last_exit_status $XONSH_STDERR_PREFIX = '{RED}' $XONSH_STDERR_POSTFIX = '{NO_COLOR}' $DYNAMIC_CWD_WIDTH = '30%' $DYNAMIC_CWD_ELISION_CHAR = '…' $PROMPT = ''.join([ '{RED}{last_exit_status:[{}] }', '{BOLD_GREEN}{user}@{hostname} ', '{YELLOW}{cwd} ', '{BLUE}{prompt_end} ', '{NO_COLOR}', ]) $RIGHT_PROMPT = '{gitstatus}{env_name: {}}' import datetime as dt import os import re import shutil $EDITOR = 'vim' # required by pinentry-tty when using gpg command: $GPG_TTY = $(tty) if shutil.which('gpgconf'): # required by scute $GPG_AGENT_INFO = $(gpgconf --list-dir agent-socket).rstrip() + ':0:1' if not 'SSH_CLIENT' in ${...}: # in gnupg 2.1.13 the location of agents socket changed $SSH_AUTH_SOCK = $(gpgconf --list-dir agent-ssh-socket).rstrip() # wrapper for termite required when launching termite from ranger: $TERMCMD = os.path.join(os.path.dirname(__file__), 'ranger-termite-termcmd') def dpkg_search(path_search_pattern): assert isinstance(path_search_pattern, str) return re.findall( '^(\S+): (.*)$\n', $(dpkg --search @(path_search_pattern)), flags=re.MULTILINE, ) def dpkg_which(cmd): cmd_path = shutil.which(cmd) assert cmd_path, 'cmd {!r} not found'.format(cmd) matches = dpkg_search(cmd_path) assert len(matches) in [0, 1] return matches[0] if len(matches) == 1 else None def locate(*patterns, match_all=True, ignore_case=True): params = [] if match_all: params.insert(0, '--all') if ignore_case: params.insert(0, '--ignore-case') return $(locate @(params) -- @(patterns)).split('\n')[:-1] def timestamp_iso(): # if called without tz argument astimezone() assumes # the system local timezone for the target timezone return dt.datetime.now().astimezone().strftime('%Y%m%dT%H%M%S%z') aliases['dpkg-which'] = lambda args: str(dpkg_which(args[0])) aliases['g'] = ['git'] aliases['ll'] = ['ls', '-l', '--all', '--indicator-style=slash', '--human-readable', '--time-style=long-iso', '--color=auto'] # vim: filetype=python