-
Notifications
You must be signed in to change notification settings - Fork 0
/
.xonshrc
102 lines (76 loc) · 3.34 KB
/
.xonshrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# Note to self: keep this fairly minimal
# load default path stuff
source-bash $(/usr/libexec/path_helper -s)
source-bash ~/.zshenv
# setup a good prompt
$XONSH_COLOR_STYLE = 'nord-darker'
$PROMPT = '{cwd}{branch_color}{curr_branch: {}}{RESET} {RED}{last_return_code_if_nonzero:[{BOLD_INTENSE_RED}{}{RED}] }{RESET}{BOLD_BLUE}{prompt_end}{RESET} '
# make ls not blue for directories (not really readable by default)
$LSCOLORS = "Axfxcxdxbxegedabagacad"
# vim style editing (set -o vi)
$VI_MODE = True
# completion settings
# $UPDATE_COMPLETIONS_ON_KEYPRESS = True
# $AUTO_SUGGEST_IN_COMPLETIONS = True # populate first completion with autosuggest result
$COMPLETIONS_CONFIRM = False # <enter> runs command (doesn't need to confirm completion first)
$COMPLETION_MODE = 'menu-complete' # first <tab> completes to longest,
# subsequent cycles through options
# better cd
execx($(zoxide init xonsh), 'exec', __xonsh__.ctx, filename='zoxide')
aliases['cd'] = 'z'
# if command not found, try to cd to it (setopt auto_cd)
$AUTO_CD = True
# good fix, now that pip doesn't have global packages
xontrib load vox
vox activate global
# -------------------------- setup some useful aliases -------------------------
# mkdir and cd in one
aliases['mkcd'] = lambda d: ![mkdir @(d)] and ![cd @(d)]
aliases['..'] = 'cd ..'
for i in range(1, 10):
# "..." doesn't work, I think because it's a python keyword
aliases['...' + '.' * i] = f"cd {'../' * (i + 1)}"
aliases['ll'] = 'ls -aAlFG'
aliases['777'] = 'chmod -R 777'
aliases['755'] = 'chmod -R 755'
aliases['e'] = 'nvim'
aliases['crago'] = 'cargo' # inside joke
aliases['krago'] = 'cargo'
aliases['mkdir'] = 'mkdir -p' # why would this not be the default
aliases['python'] = 'python3'
aliases['py'] = 'python3'
aliases['pip'] = 'python3 -m pip'
aliases['loc'] = 'tokei' # I always forget what tokei is called
# rotate screen
aliases['rot0'] = 'displayplacer "id:295EFFCF-5579-DFC0-9543-25CA8492520A degree:0"'
aliases['rot90'] = 'displayplacer "id:295EFFCF-5579-DFC0-9543-25CA8492520A degree:90"'
# -------------------------------- local aliases -------------------------------
# my scripts
aliases['mdscript'] = '~/mdscript/mdwatch.py'
aliases['dungeon'] = '~/dungeon-note-3/dungeon.py'
# my directories
aliases['school'] = 'cd ~/school'
aliases['gamedev'] = 'cd ~/gamedev'
aliases['keyboard'] = 'cd ~/keyboard'
aliases['resume'] = 'cd ~/resume'
aliases['chinese'] = 'cd ~/Desktop/chinese'
aliases['aoc'] = 'cd ~/Desktop/aoc2022'
# for every directory in ~/school, create an alias
for dir in $(ls -d ~/school/*/).split('\n'):
if len(dir) == 0: continue
aliases[dir.split('/')[-2]] = f'cd {dir}'
# create a good shorthand for Clang, with the usual flags I want to use
aliases['c'] = 'clang++ -std=c++11 -Wall -Wextra -Wpedantic -Werror'
# ----------------------------------- scripts ----------------------------------
# for every file in ~/scripts, create an alias
for file in $(ls ~/scripts/).split('\n'):
if len(file) == 0: continue
name, extension = file.rsplit('.', 1)
if extension == 'py':
aliases[name] = f'python3 ~/scripts/{file}'
elif extension == 'sh':
aliases[name] = f'~/scripts/{file}'
elif extension == 'hs':
aliases[name] = f'stack ~/scripts/{file}'
else:
aliases[name] = f'~/scripts/{file}'