rc.xsh 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 = '40%'
  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 os
  24. import re
  25. $EDITOR = 'vim'
  26. # required by pinentry-tty when using gpg command:
  27. $GPG_TTY = $(tty)
  28. # wrapper for termite required when launching termite from ranger:
  29. $TERMCMD = os.path.join(os.path.dirname(__file__), 'ranger-termite-termcmd')
  30. def locate(*patterns, match_all=True, ignore_case=True):
  31. params = []
  32. if match_all:
  33. params.insert(0, '--all')
  34. if ignore_case:
  35. params.insert(0, '--ignore-case')
  36. return $(locate @(params) -- @(patterns)).split('\n')[:-1]
  37. # vim: filetype=python