nixos_config/home/conf/xonsh/xonshrc

103 lines
4 KiB
Text
Raw Normal View History

2025-12-06 23:47:07 +01:00
## ALIASES ##
2026-01-19 19:11:07 +01:00
# home network utils
2025-12-06 23:47:07 +01:00
aliases["tsla-fan"] = "ipmitool -H 10.30.0.3 -U ADMIN -P ADMIN raw 0x30 0x70 0x66 0x01 0x0"
2026-01-27 15:44:52 +01:00
aliases["weboot"] = "sudo efibootmgr -n 0000 && reboot"
2026-01-19 19:11:07 +01:00
# nixos helpers
2025-12-06 23:47:07 +01:00
aliases["nixoss"] = "sudo nixos-rebuild switch --flake @('.#' + $(hostname))"
aliases["nixost"] = "sudo nixos-rebuild test --flake @('.#' + $(hostname))"
aliases["nixosb"] = "sudo nixos-rebuild build --flake @('.#' + $(hostname))"
aliases["nixos-dry"] = "sudo nixos-rebuild dry-build --flake @('.#' + $(hostname))"
2026-01-19 19:11:07 +01:00
# devenv
2025-12-06 23:47:07 +01:00
aliases["init-python"] = "nix flake update --flake templates && nix flake init -t 'templates#python' && direnv allow"
2026-01-19 19:11:07 +01:00
# utilities
2025-12-06 23:47:07 +01:00
aliases["ls"] = "exa"
aliases["ll"] = "exa -lah"
aliases["grep"] = "rg"
2026-01-19 19:11:07 +01:00
aliases["op"] = "xdg-open"
# scrips
2025-12-06 23:47:07 +01:00
aliases["theo"] = "python ~/.config/xonsh/theo.py"
aliases["kittycatsay"] = "python ~/.config/xonsh/kittycatsay.py"
2026-02-05 11:50:41 +01:00
aliases["code-extensions"] = "curl https://raw.githubusercontent.com/NixOS/nixpkgs/master/pkgs/applications/editors/vscode/extensions/update_installed_exts.sh | sh"
2025-12-06 23:47:07 +01:00
2026-01-19 19:11:07 +01:00
# Kitty helpers
aliases["kicat"] = "kitten icat"
aliases["kissh"] = "kitten ssh"
aliases["kidiff"] = "kitten diff"
2025-12-06 23:47:07 +01:00
## INTERACTIVE CONFIGURATION ##
2025-09-08 13:30:20 +02:00
if $XONSH_INTERACTIVE:
from datetime import datetime
2026-01-19 19:11:07 +01:00
from xonsh.built_ins import XSH
2025-12-06 23:47:07 +01:00
import importlib.util
2025-09-08 13:30:20 +02:00
t0 = datetime.now()
2026-01-08 18:05:08 +01:00
2025-09-08 13:30:20 +02:00
## ENV ##
$XONSH_COLOR_STYLE = 'native'
$PROMPT = '{YELLOW}{env_name}{RESET}{BOLD_GREEN}{user}@{hostname} {cwd}{branch_color}{curr_branch: {}}{RESET} {RED}{last_return_code_if_nonzero:[{BOLD_INTENSE_RED}{}{RED}] }{RESET}{BOLD_BLUE}{prompt_end}{RESET} '
2026-01-19 19:11:07 +01:00
# Coloured man page support
# using 'less' env vars (format is '\E[<brightness>;<colour>m')
$LESS_TERMCAP_mb = "\033[01;31m" # begin blinking
$LESS_TERMCAP_md = "\033[01;31m" # begin bold
$LESS_TERMCAP_me = "\033[0m" # end mode
$LESS_TERMCAP_so = "\033[01;44;36m" # begin standout-mode (bottom of screen)
$LESS_TERMCAP_se = "\033[0m" # end standout-mode
$LESS_TERMCAP_us = "\033[00;36m" # begin underline
$LESS_TERMCAP_ue = "\033[0m" # end underline
2026-01-01 17:35:58 +01:00
$SHELL_THICKENED = "FALSE"
2026-01-19 19:11:07 +01:00
2025-12-06 23:47:07 +01:00
## XONTRIB ##
if importlib.util.find_spec("xontrib.coreutils") is not None:
xontrib load coreutils
if importlib.util.find_spec("xontrib.fish_completer") is not None:
xontrib load fish_completer
if importlib.util.find_spec("xontrib.direnv") is not None:
xontrib load direnv
if importlib.util.find_spec("xontrib.clp") is not None:
xontrib load clp
if importlib.util.find_spec("xontrib.bashisms") is not None:
xontrib load bashisms
if importlib.util.find_spec("xontrib.fzf_completions") is not None:
xontrib load fzf-completions
2026-01-19 19:11:07 +01:00
XSH.env['fzf_history_binding'] = "c-r"
2026-01-01 17:35:58 +01:00
2026-01-19 19:11:07 +01:00
## THICC SHELL ##
if XSH.env.get("SHELL_THICCNESS", "LOW") == "HIGH" and not XSH.env.get("SHELL_THICKENED", "FALSE") == "TRUE":
2026-01-08 18:05:08 +01:00
t0_0 = datetime.now()
# Standard Library Imports
2025-12-15 16:00:57 +01:00
import os
import sys
import subprocess
import platform
import socket
import getpass
import pathlib
import re
import json
2026-01-08 18:05:08 +01:00
import threading
import multiprocessing
# Third Party Imports
if importlib.util.find_spec("scapy") is not None:
import scapy.all
if importlib.util.find_spec("yaml") is not None:
import yaml
if importlib.util.find_spec("requests") is not None:
import requests
2026-01-01 17:35:58 +01:00
$SHELL_THICKENED = "TRUE"
2026-01-08 18:05:08 +01:00
t0_1 = datetime.now()
else:
xonsh_rc_path = $XONSHRC[0]
aliases["thicken-shell"] = f"export SHELL_THICCNESS=HIGH && source {xonsh_rc_path}"
2026-01-01 17:35:58 +01:00
2026-01-19 19:11:07 +01:00
## SHELL GREETING ##
2025-09-20 09:36:21 +02:00
theo | kittycatsay
2025-09-08 13:30:20 +02:00
dt = round((datetime.now() - t0).microseconds/1000000, 2)
2026-01-01 17:35:58 +01:00
if $SHELL_THICKENED == "TRUE":
2026-01-08 18:05:08 +01:00
print_color("{BOLD_GREEN}SHELL THICKENED IN " + str(round((t0_1 - t0_0).microseconds/1000000, 2)) + "{RESET}")
print("Load time:", dt, "seconds")