rc.xsh 1.9 KB

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