rc.xsh 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 datetime as dt
  24. import dateutil.tz
  25. import os
  26. import re
  27. $EDITOR = 'vim'
  28. # required by pinentry-tty when using gpg command:
  29. $GPG_TTY = $(tty)
  30. # wrapper for termite required when launching termite from ranger:
  31. $TERMCMD = os.path.join(os.path.dirname(__file__), 'ranger-termite-termcmd')
  32. def locate(*patterns, match_all=True, ignore_case=True):
  33. params = []
  34. if match_all:
  35. params.insert(0, '--all')
  36. if ignore_case:
  37. params.insert(0, '--ignore-case')
  38. return $(locate @(params) -- @(patterns)).split('\n')[:-1]
  39. def timestamp_iso():
  40. return dt.datetime.now(tz=dateutil.tz.tzlocal()) \
  41. .strftime('%Y%m%dT%H%M%S%z')
  42. aliases['ll'] = ['ls', '-l', '--all', '--indicator-style=slash', '--human-readable', '--time-style=long-iso', '--color=auto']
  43. # vim: filetype=python