xigoi / xonsh

~/.xonshrc Commits Diff Raw
# Imports
import os

# Prompt
def ignore_if(x, y):
    return None if x == y else x
$PROMPT_FIELDS.update({
    "num_jobs": lambda: ignore_if($(jobs | wc -l).strip(), "0"),
})
$VIRTUAL_ENV_PROMPT = "venv"
$PROMPT = lambda: (
    "\n"
    "{BG#088}{#000} {localtime} {RESET}"
    "{BG#222}{#fff}{short_cwd: {} }{RESET}"
    "{BG#f80}{#000}{env_name: {} }{RESET}"
    "{BG#111}{#fff}{gitstatus: {} }{RESET}"
    "{BG#aa0}{#000}{num_jobs: {} }{RESET}"
    "\n{#ff0}{prompt_end}{RESET} "
)

# Aliases
aliases.update({
    "e": "nvim",
    "ee": "nvim ~/.config/nvim/init.vim",
    "lynx": "lynx --display_charset=utf-8",
    "py": "python3 -q",
    "rb": "ruby",
    "rm": "rm -v",
    "units": "units --compact --one-line",
})

# Device-specific settings
if $(hostname) == "xigoi-pc":
    # Main computer
    aliases.update({
        "ccc": "xclip -selection clipboard",
        "ppp": "xclip -o -selection clipboard",
    })
elif os.path.isdir("/data/data/com.termux"):
    # Phone
    aliases.update({
        "ccc": "termux-clipboard-set",
        "ppp": "termux-clipboard-get",
    })

# Terminal-specific settings
if $TERM == "xterm-kitty":
    xontrib load kitty