dots/.xonshrc

99 lines
2.4 KiB
Text
Raw Normal View History

2021-09-23 01:38:18 +00:00
# general shit
2021-11-08 20:44:55 +00:00
if $HOSTNAME != "riley-laptop":
$PROMPT = '<> {RESET}| {BOLD_GREEN}{cwd_base}{RESET}'
else:
$PROMPT = '{RED} <3 {RESET}| {BOLD_GREEN}{cwd_base}{RESET} ) '
2021-09-25 19:08:51 +00:00
$XONSH_COLOR_STYLE = 'default'
2021-09-22 03:46:08 +00:00
xontrib load apt_tabcomplete argcomplete autovox jedi z
2021-09-22 07:52:45 +00:00
# path stuff
2021-10-20 03:09:24 +00:00
def load_path():
import sys
$PATH.extend([
'~/addins',
'~/.local/bin',
'~/bin',
'~/go/bin'
])
sys.path.insert(0, '')
load_path()
2021-09-22 07:52:45 +00:00
2021-09-23 01:38:18 +00:00
import addins # my extra stuffs :p
def _colortest():
import sys
for i in range(256):
sys.stdout.write(f"\033[48;5;{i}m ")
if (i+1) % 16 == 0:
sys.stdout.write("\033[0m\n")
# tmux
2021-09-25 19:08:51 +00:00
if !(which tmux) and $TERM != 'tmux-256color':
folder = p'.'
tmux -2 new-session -A -s @(folder.resolve().name)
exit
2021-09-22 07:52:45 +00:00
2021-09-22 03:46:08 +00:00
# debug
def _debug():
if $XONSH_SHOW_TRACEBACK:
$XONSH_SHOW_TRACEBACK = False
print("Debug mode disabled.")
else:
$XONSH_SHOW_TRACEBACK = True
print("Debug mode enabled.")
# bitwarden shit
2021-10-20 03:09:24 +00:00
def _bwc(object : str, bw_id: str):
2021-09-22 03:46:08 +00:00
if p'~/.bw_session'.exists():
if $XONSH_SHOW_TRACEBACK:
print("loaded .bw_session")
source ~/.bw_session
2021-09-23 01:38:18 +00:00
else:
raise FileNotFoundError("~/.bw_session")
2021-10-20 03:09:24 +00:00
output = $(bw get @(object) @(bw_id))
2021-09-22 03:46:08 +00:00
$(echo @(output) | xclip -sel clipboard)
2021-10-20 03:09:24 +00:00
if "password" in object and !(bw get totp @(object[1]) a> /dev/null):
input("totp found, press any key to copy totp ")
output = $(bw get totp @(object[1]))
$(echo @(output) | xclip -sel clipboard)
# return output
2021-09-22 03:46:08 +00:00
2021-11-08 04:36:58 +00:00
def _ensure_tmux(args: list):
if $XONSH_SHOW_TRACEBACK:
print(args)
if not $(tmux has-session -t @(args[0])):
tmux new-session -d -s @(args[0]) all> /dev/null
$(tmux send-keys -t @(args[0]) @(f"cd {args[1]}") C-m)
$(tmux send-keys -t @(args[0]) @(f"{args[2]}") C-m)
def _alias():
for alias in aliases:
if callable(aliases[alias]):
print(alias + " = ", aliases[alias].__name__)
else:
print(alias + " =", " ".join(aliases[alias]))
2021-09-23 01:38:18 +00:00
# aliases
aliases.update({
'bwg': _bwc,
'bwc': _bwc,
'colortest': _colortest,
'config': '/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME',
'debug': _debug,
'ls': 'ls -alhs --color=auto',
':q': 'exit',
2021-10-20 03:09:24 +00:00
'owo': 'echo uwu',
2021-11-08 04:36:58 +00:00
'ensure-tmux': _ensure_tmux,
'alias': _alias,
2021-09-23 01:38:18 +00:00
})
2021-09-22 07:52:45 +00:00
2021-09-23 01:38:18 +00:00
# man page colors :O
$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
2021-09-25 19:08:51 +00:00