92 lines
2.1 KiB
Plaintext
92 lines
2.1 KiB
Plaintext
import shutil
|
|
from pathlib import Path
|
|
from typing import List
|
|
from xonsh.platform import ON_DARWIN, ON_LINUX
|
|
|
|
_xontribs = [
|
|
"vox",
|
|
]
|
|
|
|
if _xontribs:
|
|
xontrib load @(_xontribs)
|
|
|
|
$UPDATE_OS_ENVIRON = True
|
|
$XONSH_HISTORY_BACKEND = "sqlite"
|
|
$HISTCONTROL = "ignoredups"
|
|
$MULTILINE_PROMPT = " "
|
|
|
|
aliases["-"] = "cd -"
|
|
aliases[".."] = "cd .."
|
|
aliases["..."] = "cd ../.."
|
|
$AUTO_CD = True
|
|
|
|
$MANPAGER = "less -X"
|
|
$LESS = "--ignore-case --quit-if-one-screen --QUIET --RAW-CONTROL-CHARS"
|
|
|
|
# ============
|
|
# Basics, etc…
|
|
# ============
|
|
|
|
$EDITOR = "emacsclient"
|
|
$ALTERNATE_EDITOR = "vim"
|
|
$TERMINAL = "kitty"
|
|
|
|
def ensure_path(*paths: List[str]):
|
|
for p in paths:
|
|
abs_p = str(Path(p).expanduser().absolute())
|
|
if abs_p not in $PATH:
|
|
$PATH.append(abs_p)
|
|
|
|
ensure_path("~/.dotfiles/bin", "~/.local/bin", "~/bin", "~/.eamcs.d/bin")
|
|
|
|
config_dir = Path.home() / ".dotfiles" / "xonsh"
|
|
|
|
if (config_dir / "local.xsh").exists():
|
|
source @(config_dir / "local.xsh")
|
|
|
|
aliases["ec"] = "emacsclient -n --alternate-editor=emacs"
|
|
aliases["src"] = "source ~/.xonshrc"
|
|
aliases["pubip"] = "curl icanhazip.com"
|
|
aliases['ll'] = lambda args: $[$LC_COLLATE='C' ls -lAh @(args)]
|
|
|
|
if ON_DARWIN:
|
|
$JAVA_HOME = $(/usr/libexec/java_home).strip()
|
|
|
|
if ON_LINUX:
|
|
aliases["pulsefix"] = "pulseaudio --kill; pulseaudio --start"
|
|
|
|
def find_venv():
|
|
d = Path.cwd()
|
|
|
|
while True:
|
|
if (d / "venv").exists():
|
|
vox activate @(str(d / "venv"))
|
|
return True
|
|
|
|
if d == d.parent or (d / ".git").exists():
|
|
print("Could not find venv.")
|
|
return False
|
|
|
|
d = d.parent
|
|
|
|
|
|
aliases["vv"] = find_venv
|
|
|
|
# # Hybrid Vi Mode
|
|
# set -g fish_key_bindings hybrid_bindings
|
|
|
|
# # Fix prompt for Emacs TRAMP
|
|
# # https://github.com/oh-my-fish/theme-bobthefish/issues/148
|
|
# if test "$TERM" = "dumb"
|
|
# function fish_prompt
|
|
# echo "\$ "
|
|
# end
|
|
# function fish_right_prompt; end
|
|
# function fish_greeting; end
|
|
# function fish_title; end
|
|
# end
|
|
|
|
# autojump equivalent
|
|
if shutil.which("zoxide"):
|
|
execx($(zoxide init xonsh --cmd j --hook prompt), 'exec', __xonsh__.ctx, filename='zoxide')
|