123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- $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
- # default locale
- # will be used for all non-explicitly set LC_* variables
- $LANG = 'en_US.UTF-8'
- # fallback locales
- # GNU gettext gives preference to LANGUAGE over LC_ALL and LANG
- # for the purpose of message handling
- # https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html
- # cave: if this list contains 'de(_.*)?' at any (sic!) position
- # vim 7.4.1689 will switch to german
- $LANGUAGE = ':'.join(['en_US', 'en'])
- $LC_COLLATE = 'C.UTF-8'
- # char classification, case conversion & other char attrs
- $LC_CTYPE = 'de_AT.UTF-8'
- # $ locale currency_symbol
- $LC_MONETARY = 'de_AT.UTF-8'
- # $ locale -k LC_NUMERIC | head -n 3
- # decimal_point="."
- # thousands_sep=""
- # grouping=-1
- $LC_NUMERIC = 'C.UTF-8'
- # A4
- $LC_PAPER = 'de_AT.UTF-8'
- $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_listfiles(pkg_name):
- assert isinstance(pkg_name, str)
- paths = $(dpkg --listfiles @(pkg_name)).split('\n')[:-1]
- assert len(paths) > 0, 'pkg {!r} not installed'.format(pkg_name)
- return paths
- 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_welse(cmd):
- pkg_name, cmd_path = dpkg_which(cmd)
- return dpkg_listfiles(pkg_name)
- 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) != 0, '{!r} not installed via dpkg'.format(cmd_path)
- assert len(matches) == 1
- return matches[0]
- 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_now_utc():
- return dt.datetime.utcnow().replace(tzinfo=dt.timezone.utc)
- def timestamp_now_local():
- # if called without tz argument astimezone() assumes
- # the system local timezone for the target timezone
- return timestamp_now_utc().astimezone()
- def timestamp_iso_local():
- # if called without tz argument astimezone() assumes
- # the system local timezone for the target timezone
- return timestamp_now_local().strftime('%Y%m%dT%H%M%S%z')
- aliases['dpkg-welse'] = lambda args: '\n'.join(dpkg_welse(args[0]))
- aliases['dpkg-which'] = lambda args: '\t'.join(dpkg_which(args[0]))
- aliases['g'] = ['git']
- aliases['ll'] = ['ls', '-l', '--all', '--indicator-style=slash',
- '--human-readable', '--time-style=long-iso', '--color=auto']
- if shutil.which('startx') and $(tty).rstrip() == '/dev/tty1':
- startx
- # vim: filetype=python
|