rc.xsh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. $VI_MODE = True
  2. $AUTO_PUSHD = True
  3. $XONSH_AUTOPAIR = True
  4. xontrib load vox z
  5. def _last_exit_status():
  6. try:
  7. exit_status = __xonsh_history__.rtns[-1]
  8. return exit_status if exit_status != 0 else None
  9. except IndexError:
  10. return None
  11. $PROMPT_FIELDS['last_exit_status'] = _last_exit_status
  12. $XONSH_STDERR_PREFIX = '{RED}'
  13. $XONSH_STDERR_POSTFIX = '{NO_COLOR}'
  14. $DYNAMIC_CWD_WIDTH = '30%'
  15. $PROMPT = ''.join([
  16. '{RED}{last_exit_status:[{}] }',
  17. '{BOLD_GREEN}{user}@{hostname} ',
  18. '{YELLOW}{cwd} ',
  19. '{BLUE}{prompt_end} ',
  20. '{NO_COLOR}',
  21. ])
  22. $RIGHT_PROMPT = '{gitstatus}{env_name: {}}'
  23. import datetime as dt
  24. import dateutil.tz
  25. import os
  26. import re
  27. import shutil
  28. $EDITOR = 'vim'
  29. # required by pinentry-tty when using gpg command:
  30. $GPG_TTY = $(tty)
  31. if shutil.which('gpgconf'):
  32. # required by scute
  33. $GPG_AGENT_INFO = $(gpgconf --list-dir agent-socket).rstrip() + ':0:1'
  34. if not 'SSH_CLIENT' in ${...}:
  35. # in gnupg 2.1.13 the location of agents socket changed
  36. $SSH_AUTH_SOCK = $(gpgconf --list-dir agent-ssh-socket).rstrip()
  37. # wrapper for termite required when launching termite from ranger:
  38. $TERMCMD = os.path.join(os.path.dirname(__file__), 'ranger-termite-termcmd')
  39. def locate(*patterns, match_all=True, ignore_case=True):
  40. params = []
  41. if match_all:
  42. params.insert(0, '--all')
  43. if ignore_case:
  44. params.insert(0, '--ignore-case')
  45. return $(locate @(params) -- @(patterns)).split('\n')[:-1]
  46. def timestamp_iso():
  47. return dt.datetime.now(tz=dateutil.tz.tzlocal()) \
  48. .strftime('%Y%m%dT%H%M%S%z')
  49. aliases['g'] = ['git']
  50. aliases['ll'] = ['ls', '-l', '--all', '--indicator-style=slash',
  51. '--human-readable', '--time-style=long-iso', '--color=auto']
  52. # vim: filetype=python