-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathxonsh.xsh
105 lines (85 loc) · 3.01 KB
/
xonsh.xsh
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
101
102
103
104
105
# === Init ===
# > Xontrib
xontrib load coreutils
# < Xontrib
# > General
$FORCE_POSIX_PATHS = True
$UPDATE_OS_ENVIRON = True
# < General
# > Interactive Prompt
$VI_MODE = True
$XONSH_AUTOPAIR = True
$XONSH_HISTORY_MATCH_ANYWHERE = True
$XONSH_SUPPRESS_WELCOME = True
# < Interactive Prompt
# > Interpreter Behavior
$DOTGLOB = True
# < Interpreter Behavior
# > Tab-completion behavior
$CMD_COMPLETIONS_SHOW_DESC = True
$COMPLETIONS_CONFIRM = True
$COMPLETIONS_DISPLAY = 'single'
$COMPLETION_IN_THREAD = True
$UPDATE_COMPLETIONS_ON_KEYPRESS = False
# < Tab-completion behavior
# === Tools ===
# > carapace-bin
exec($(carapace _carapace))
# < carapace-bin
# > zoxide
execx($(zoxide init xonsh), 'exec', __xonsh__.ctx, filename='zoxide')
# < zoxide
# > starship
{{#if (eq dotter.os "windows")}}
import uuid
def starship_prompt():
last_cmd = __xonsh__.history[-1] if __xonsh__.history else None
status = last_cmd.rtn if last_cmd else 0
# I believe this is equivalent to xonsh.jobs.get_next_job_number() for our purposes,
# but we can't use that function because of https://gitter.im/xonsh/xonsh?at=60e8832d82dd9050f5e0c96a
jobs = sum(1 for job in __xonsh__.all_jobs.values() if job['obj'] and job['obj'].poll() is None)
duration = round((last_cmd.ts[1] - last_cmd.ts[0]) * 1000) if last_cmd else 0
return $(starship prompt --status=@(status) --jobs=@(jobs) --cmd-duration=@(duration))
def starship_rprompt():
last_cmd = __xonsh__.history[-1] if __xonsh__.history else None
status = last_cmd.rtn if last_cmd else 0
# I believe this is equivalent to xonsh.jobs.get_next_job_number() for our purposes,
# but we can't use that function because of https://gitter.im/xonsh/xonsh?at=60e8832d82dd9050f5e0c96a
jobs = sum(1 for job in __xonsh__.all_jobs.values() if job['obj'] and job['obj'].poll() is None)
duration = round((last_cmd.ts[1] - last_cmd.ts[0]) * 1000) if last_cmd else 0
return $(starship prompt --status=@(status) --jobs=@(jobs) --cmd-duration=@(duration) --right)
$PROMPT = starship_prompt
$RIGHT_PROMPT = starship_rprompt
$STARSHIP_SHELL = "xonsh"
$STARSHIP_SESSION_KEY = uuid.uuid4().hex
{{else}}
execx($(starship init xonsh))
{{/if}}
# < starship
# === Default Aliases ===
# > eza
aliases['es'] = ['eza', '--git', '--icons=auto']
aliases['el'] = ['eza', '-lh', '--git', '--icons=auto']
aliases['et'] = ['eza', '-lTh', '--git', '--icons=auto']
aliases['esa'] = ['eza', '-a', '--git', '--icons=auto']
aliases['ela'] = ['eza', '-lah', '--git', '--icons=auto']
aliases['eta'] = ['eza', '-lTah', '--git', '--icons=auto']
# < eza
# === Custom Section ===
conf_dir = $XONSH_CONFIG_DIR
# > User rc.xonsh
if pf'{conf_dir}/user.xsh'.exists():
source $XONSH_CONFIG_DIR/user.xsh
# <
# > Aliases
if pf'{conf_dir}/alias.xsh'.exists():
source $XONSH_CONFIG_DIR/alias.xsh
# < Aliases
# > Environment Variables
if pf'{conf_dir}/env.xsh'.exists():
source $XONSH_CONFIG_DIR/env.xsh
# < Environment Variables
# > .xonshrc (e.g. for conda init)
if p'~/.xonshrc'.exists():
source ~/.xonshrc
# > .xonshrc