-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxonshrc
92 lines (68 loc) · 2.83 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
# vi: ft=xonsh
from pathlib import Path
from prompt_toolkit.keys import Keys
from prompt_toolkit.filters import Condition, EmacsInsertMode, ViInsertMode
from datetime import datetime
$XONSH_COLOR_STYLE="native"
aliases['a'] = ['~/dotfiles/bin/agenda.sh']
aliases['t'] = ['task']
aliases['to'] = ['taskopen']
aliases['gst'] = ['git', 'status']
aliases['gpu'] = ['git', 'push']
aliases['gca'] = ['git', 'commit', '-a']
aliases['ga'] = ['git', 'add']
aliases['v'] = ['vim']
aliases['..'] = ['cd','..']
# if not Path("~/.is_presentation").expanduser().exists():
# ~/dotfiles/bin/agenda.sh
# stty -ixon
# Vox, Python virtual environments {{{
xontrib load vox
$VIRTUALENV_HOME="/home/kai/.pyenv/versions"
# xontrib load avox
# xontrib load vox_tabcomplete
# }}}
# Fuzzy change directory {{{
$PATH.append("~/.fzf/bin")
import subprocess
def fzf_cd(args, stdin=None):
fzf_command = ["/home/kai/.fzf/bin/fzf", "--height", "20"]
if len(args) > 0:
fzf_command.extend(["-q", " ".join(args)])
d = subprocess.run(fzf_command, stdout=subprocess.PIPE, input=$(cat ~/dirs).encode("utf-8"))
dir = d.stdout.decode("utf-8").strip()
cd @(dir)
aliases['fcd'] = fzf_cd
# add dir within command
@events.on_ptk_create
def custom_keybindings(bindings, **kw):
# prompt_toolkit 1.x
# handler = bindings.registry.add_binding
# prompt_toolkit 2.x
handler = bindings.add
@handler(Keys.ControlP)
def fzf_dir(event):
fzf_command = ["/home/kai/.fzf/bin/fzf", "--height", "20"]
d = subprocess.run(fzf_command, stdout=subprocess.PIPE, input=$(cat ~/dirs).encode("utf-8"))
dir = d.stdout.decode("utf-8").strip()
event.current_buffer.insert_text(dir)
# }}}
# Prompt {{{
#
path_copy = str($PATH)
$DYNAMIC_CWD_WIDTH='60%'
$PROMPT_FIELDS["time"] = lambda: datetime.now().strftime("%H:%M:%S")
$PROMPT_FIELDS["path_changed"] = lambda: "PATH CHANGED!" if str($PATH) != path_copy else ""
$PROMPT = '{BOLD_RED}{path_changed}{#444}── {time}\n{BOLD_BLUE}┌─ XONSH {env_name:{}}{cwd}{branch_color}{curr_branch: {}}{NO_COLOR}\n{BOLD_BLUE}└─ {prompt_end} {NO_COLOR}'
# }}}
# All applications that are interactive and use the full terminal:
# Also applications that spawn these, e.g. open the editor.
#
__xonsh__.commands_cache.threadable_predictors['taskopen'] = lambda args: False
__xonsh__.commands_cache.threadable_predictors['to'] = lambda args: False
__xonsh__.commands_cache.threadable_predictors['task'] = lambda args: False
__xonsh__.commands_cache.threadable_predictors['t'] = lambda args: False
__xonsh__.commands_cache.threadable_predictors['xdg-open'] = lambda args: False
__xonsh__.commands_cache.threadable_predictors['vim.desktop'] = lambda args: False
__xonsh__.commands_cache.threadable_predictors['wpm'] = lambda args: False
__xonsh__.commands_cache.threadable_predictors['sieve-connect'] = lambda args: False