#!/usr/bin/env xonsh from prompt_toolkit.key_binding.vi_state import InputMode $SHELL_TYPE = "prompt_toolkit" $PROMPT_TOOLKIT_COLOR_DEPTH = "DEPTH_24_BIT" $NFOX_BLACK = "#393b44" $NFOX_RED = "#c94f6d" $NFOX_GREEN = "#81b29a" $NFOX_YELLOW = "#dbc074" $NFOX_BLUE = "#719cd6" $NFOX_MAGENTA = "#9d79d6" $NFOX_CYAN = "#63cdcf" $NFOX_WHITE = "#dfdfe0" $NFOX_ORANGE = "#f4a261" $NFOX_PINK = "#d67ad2" $NFOX_COMMENT = "#738091" $NFOX_BG0 = "#131a24" $NFOX_BG1 = "#192330" $NFOX_BG2 = "#212e3f" $NFOX_BG3 = "#29394f" $NFOX_BG4 = "#39506d" $NFOX_FG0 = "#d6d6d7" $NFOX_FG1 = "#cdcecf" $NFOX_FG2 = "#aeafb0" $NFOX_FG3 = "#71839b" $NFOX_SEL0 = "#2b3b51" $NFOX_SEL1 = "#3c5372" # Darker $NFOX_BLACK_D = "#13151e" $NFOX_RED_D = "#a32947" $NFOX_GREEN_D = "#5b8c74" $NFOX_YELLOW_D = "#b59a4e" $NFOX_BLUE_D = "#4b76b0" $NFOX_MAGENTA_D = "#7753b0" $NFOX_CYAN_D = "#3da7a9" $NFOX_WHITE_D = "#b9b9ba" $NFOX_ORANGE_D = "#ce7c3b" $NFOX_PINK_D = "#b054ac" #Lighter $NFOX_BLACK_L = "#5F616A" $NFOX_RED_L = "#ef7593" $NFOX_GREEN_L = "#9bccb4" $NFOX_YELLOW_L = "#ffe69a" $NFOX_BLUE_L = "#97c2fc" $NFOX_MAGENTA_L = "#eac6ff" $NFOX_CYAN_L = "#89f3f5" $NFOX_WHITE_L = "#ffffff" $NFOX_ORANGE_L = "#ffc887" $NFOX_PINK_L = "#fca0f8" # Load all plugins xontrib load commands xontrib load gitinfo xontrib load broot xontrib load hist_navigator xontrib load vox xontrib load autovox xontrib load voxapi xontrib load abbrevs xontrib load argcomplete xontrib load django xontrib load docker_tabcomplete xontrib load fish_completer xontrib load jedi xontrib load makefile_complete $VI_MODE = True $XONSH_SHOW_TRACEBACK = True $COMPLETIONS_CONFIRM=True $DOCKER_BASE_URL = "unix://var/run/docker.sock" $VISUAL = "nvim" $EDITOR = "lvim" $PAGER = "nvimpager" $BROWSER = "elinks" $PATH = [ p"~/.local/bin", p"~/.cargo/bin", p"~/go/bin", p"/usr/sbin", p"/sbin", p"/usr/local/sbin", p"/usr/local/bin", p"/usr/bin", p"/bin", p"/usr/games" ] $NOTMUCH_CONFIG = p"~/.config/notmuch/notmuch-config" $PROJECT_PATHS = [p"~/projects"] $KEYRING_PROPERTY_SCHEME = "Bitwarden" $XONSH_COLOR_STYLE = 'nightfox_transparent' if p"~/.config/xonsh/rc-private.xsh".is_file(): source ~/.config/xonsh/rc-private.xsh if p"~/.config/xonsh/rc-root.xsh".is_file(): source ~/.config/xonsh/rc-root.xsh def color_str(fg:str="DEFAULT", bg:str="DEFAULT") -> str: """ Return color string for print_color based on hex values """ return f"{{BACKGROUND_{bg}}}{{{fg}}}" def color_to_ansi(color:str): """ Return color string for print_color based on hex values """ color_r = int(color[1:3], 16) color_g = int(color[3:5], 16) color_b = int(color[5:7], 16) return f"2;{color_r};{color_g};{color_b}" __PROMPT_VI_MODES = { InputMode.INSERT: color_str($NFOX_BG0, $NFOX_YELLOW) + "I" + color_str($NFOX_YELLOW) + "", InputMode.INSERT_MULTIPLE: color_str($NFOX_BG0, $NFOX_YELLOW) + "I+" + color_str($NFOX_YELLOW) + "", InputMode.REPLACE: color_str($NFOX_BG0, $NFOX_BLUE) + "R" + color_str($NFOX_BLUE) + "", InputMode.REPLACE_SINGLE: color_str($NFOX_BG0, $NFOX_CYAN) + "r" + color_str($NFOX_CYAN) + "", InputMode.NAVIGATION: color_str($NFOX_BG0, $NFOX_MAGENTA) + "N" + color_str($NFOX_MAGENTA) + "", } def __get_user_prompt(): import os user_name = os.getlogin() if "SSH_CLIENT" in ${...}: $IS_REMOTE = True host_color = $NFOX_ORANGE else: $IS_REMOTE = False host_color = $NFOX_BLUE if user_name == "root": $IS_ROOT = True user_color = color_str($NFOX_BG0, $NFOX_RED) user_sep = color_str($NFOX_RED, host_color) + "" else: $IS_ROOT = False user_color = color_str($NFOX_BG0, $NFOX_CYAN) user_sep = color_str($NFOX_CYAN, host_color) + "" return user_color + user_name + user_sep $PROMPT_FIELDS["user"] = __get_user_prompt() def __get_host_prompt(): import socket if $IS_REMOTE: host_color = color_str($NFOX_BG0, $NFOX_ORANGE) host_sep = color_str($NFOX_ORANGE, $NFOX_FG3) + "" else: host_color = color_str($NFOX_BG0, $NFOX_BLUE) host_sep = color_str($NFOX_BLUE, $NFOX_FG3) + "" return host_color + socket.gethostname().split(".", 1)[0] + host_sep $PROMPT_FIELDS["hostname"] = __get_host_prompt() if $IS_ROOT: __PROMPT_CWD_COLOR = color_str($NFOX_BG0, $NFOX_RED) __PROMPT_CWD_SEP = color_str($NFOX_RED, $NFOX_BG2) + "" else: __PROMPT_CWD_COLOR = color_str($NFOX_BG0, $NFOX_GREEN) __PROMPT_CWD_SEP = color_str($NFOX_GREEN, $NFOX_BG2) + "" def __get_cwd_prompt(): from xonsh.prompt.cwd import _dynamically_collapsed_pwd cwd = _dynamically_collapsed_pwd() return __PROMPT_CWD_COLOR + cwd + __PROMPT_CWD_SEP $PROMPT_FIELDS["cwd"] = __get_cwd_prompt __PROMPT_ENV_COLOR = color_str($NFOX_BG0, $NFOX_FG3) __PROMPT_ENV_SEP = color_str($NFOX_FG3, $NFOX_GREEN) + "" __PROMPT_ENV_SEP_ERROR = color_str($NFOX_FG3, $NFOX_RED) + "" def __get_env_prompt(): string_venv = "" string_rbenv = "" string_nvm = "" env_result = "" string_rbenv = str(!(rbenv local err> /dev/null)) if not string_rbenv: string_rbenv = str(!(rbenv global err> /dev/null)) string_rbenv = string_rbenv.replace('\n', '') if string_rbenv == "system": string_rbenv = "" if "nvm_current_version" in ${...}: string_nvm = $nvm_current_version if "VIRTUAL_ENV" in ${...}: string_venv = $VIRTUAL_ENV.split('/')[-1] if string_nvm or string_rbenv or string_venv: env_result = f" {string_nvm}| {string_rbenv}| {string_venv}" if $LAST_RETURN_CODE == 0: return __PROMPT_ENV_COLOR + env_result + __PROMPT_ENV_SEP return __PROMPT_ENV_COLOR + env_result + __PROMPT_ENV_SEP_ERROR $PROMPT_FIELDS["env_name"] = __get_env_prompt __PROMPT_LAST_STATE_SUCCESS = color_str($NFOX_BG0, $NFOX_GREEN) + "xonsh✔" \ + color_str($NFOX_GREEN) + "" __PROMPT_LAST_STATE_ERROR = color_str($NFOX_BG0, $NFOX_RED) + "xonsh✗" __PROMPT_LAST_STATE_ERROR_SUFFIX = color_str($NFOX_RED) + "" def __get_last_state_prompt(): if $LAST_RETURN_CODE == 0: return __PROMPT_LAST_STATE_SUCCESS return __PROMPT_LAST_STATE_ERROR + str($LAST_RETURN_CODE) \ + __PROMPT_LAST_STATE_ERROR_SUFFIX $PROMPT_FIELDS["last_state"] = __get_last_state_prompt $PROMPT_FIELDS["vi_mode"] = lambda: __PROMPT_VI_MODES.get( __xonsh__.shell.shell.prompter.app.vi_state.input_mode, color_str($NFOX_BG0, $NFOX_GREEN) + "E" + color_str($NFOX_GREEN) + "" ) $PROMPT_FIELDS['gitstatus.branch'].prefix = color_str($NFOX_ORANGE, $NFOX_BG2) + "" $PROMPT_FIELDS['gitstatus.conflicts'].prefix = color_str($NFOX_RED, $NFOX_BG2) + "x" $PROMPT_FIELDS['gitstatus.operations'].prefix = color_str($NFOX_ORANGE, $NFOX_BG2) + "" $PROMPT_FIELDS['gitstatus.changed'].prefix = color_str($NFOX_GREEN, $NFOX_BG2) + "-" $PROMPT_FIELDS['gitstatus.deleted'].prefix = color_str($NFOX_RED, $NFOX_BG2) + "+" $PROMPT_FIELDS['gitstatus.staged'].prefix = color_str($NFOX_BLUE, $NFOX_BG2) + "●" $PROMPT_FIELDS['gitstatus.lines_added'].prefix = color_str($NFOX_GREEN, $NFOX_BG2) + "+" $PROMPT_FIELDS['gitstatus.lines_removed'].prefix = color_str($NFOX_RED, $NFOX_BG2) + "-" $PROMPT_FIELDS['gitstatus.clean'].prefix = color_str($NFOX_BLUE, $NFOX_BG2) + "C" $PROMPT_FIELDS['gitstatus_sep'] = color_str($NFOX_BG2) + "\n" $PROMPT_FIELDS['gitstatus.ahead'].prefix = color_str($NFOX_ORANGE, $NFOX_BG2) + "↑·" $PROMPT_FIELDS['gitstatus.behind'].prefix = color_str($NFOX_ORANGE, $NFOX_BG2) + "↓·" $PROMPT_FIELDS['gitstatus.numstat'].prefix = color_str($NFOX_BLUE, $NFOX_BG2) + "N" $PROMPT_FIELDS['gitstatus.porcelain'].prefix = color_str($NFOX_ORANGE, $NFOX_BG2) + "p" $PROMPT_FIELDS['gitstatus.repo_path'].prefix = color_str($NFOX_GREEN, $NFOX_BG2) + "P" $PROMPT_FIELDS['gitstatus.short_head'].prefix = color_str($NFOX_PINK, $NFOX_BG2) + "h" $PROMPT_FIELDS['gitstatus.stash_count'].prefix = color_str($NFOX_YELLOW, $NFOX_BG2) + "S" $PROMPT_FIELDS['gitstatus.tag'].prefix = color_str($NFOX_BLUE, $NFOX_BG2) + "T" $PROMPT_FIELDS['gitstatus.tag_or_hash'].prefix = color_str($NFOX_CYAN, $NFOX_BG2) + "T" $PROMPT_FIELDS['gitstatus.untracked'].prefix = color_str($NFOX_YELLOW, $NFOX_BG2) + "…" $VC_GIT_INCLUDE_UNTRACKED = True $UPDATE_OS_ENVIRON = True $UPDATE_PROMPT_ON_KEYPRESS = True $PROMPT_REFRESH_INTERVAL = 1 $PROMPT = "{user}{hostname}{env_name}{last_state}\n{cwd}{gitstatus}{gitstatus_sep}{vi_mode}" $MULTILINE_PROMPT = color_str($NFOX_YELLOW) + "█" #$ENABLE_ASYNC_PROMPT = True $INDENT = " " $XONSH_STDERR_PREFIX = color_str($NFOX_RED) + "ERR:" $XONSH_STDERR_POSTFIX = "{RESET}" $AUTO_SUGGEST_IN_COMPLETIONS = True $CMD_COMPLETIONS_SHOW_DESC = True $COMPLETIONS_DISPLAY = "multi" $COMPLETION_IN_THREAD = True $CASE_SENSITIVE_COMPLETIONS = False $MOUSE_SUPPORT = True $XONSH_AUTOPAIR = True $LS_COLORS = 'rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=00:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.avif=01;35:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:*~=00;90:*#=00;90:*.bak=00;90:*.old=00;90:*.orig=00;90:*.part=00;90:*.rej=00;90:*.swp=00;90:*.tmp=00;90:*.dpkg-dist=00;90:*.dpkg-old=00;90:*.ucf-dist=00;90:*.ucf-new=00;90:*.ucf-old=00;90:*.rpmnew=00;90:*.rpmorig=00;90:*.rpmsave=00;90:'; pushd "~/.config/xonsh" import rc_private import rc_desktop if $IS_ROOT: import rc_root import rc_common_aliases popd json-fortune