-
Notifications
You must be signed in to change notification settings - Fork 1
/
xyzsh.xyzsh
168 lines (137 loc) · 4.06 KB
/
xyzsh.xyzsh
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
kanjicode -byte
### make xyzsh setting directory ###
print ~/.xyzsh | if(| -e) (
| if(! | -d) (
print "~/.xyzsh is not directory\n"
exit
)
sys::chmod 700 ~/.xyzsh
) else (
sys::mkdir -p ~/.xyzsh
sys::chmod 700 ~/.xyzsh
)
print ~/.xyzsh/program | if(! | -e) (
print "mail date crontab hostname basename tee find unzip diff seq env sleep ps kill killall pkill autoconf automake od nm gcc uname chgrp chmod chown sed awk make git ssh scp tar sudo gzip bash cat ls pwd cp mv rm rmdir ln vi vim grep egrep find less wc echo which whoami head tail uniq mkdir touch man" | split > ~/.xyzsh/program
)
def install_external_program_to_root_object (
sys::cat ~/.xyzsh/program | each (
| chomp | var -local prog
if(! defined ::$prog) (
try (
ref ::sys::$prog | ref ::$prog
) catch ()
)
)
print 0 | var InstallAllExternalProgram
)
def install_all_external_program_to_root_object (
::sys::show | ::sys::grep "external program" | scan '(.+?): external program' | each (
| chomp | var -local prog
if(! defined ::$prog || typeof ::$prog | chomp | = "external program") (
try (
ref ::sys::$prog | ref ::$prog
) catch ()
)
)
print 1 | var InstallAllExternalProgram
)
def rehash -inherit (
inherit
if(InstallAllExternalProgram | -eq 1) (
install_all_external_program_to_root_object
) else (
install_external_program_to_root_object
)
)
install_external_program_to_root_object
export XYZSH_NEST_LEVEL | + 1 | export XYZSH_NEST_LEVEL
prompt (
if(export XYZSH_NEST_LEVEL | -eq 1) (
pwd | chomp
print " > "
) else (
pwd | chomp
print "("
export XYZSH_NEST_LEVEL | chomp
print ")"
print " > "
) | if(uname |= Darwin\n && (export LANG LC_ALL) | index -quiet -ignore-case utf-8) (
| sys::iconv -f UTF8-MAC -t UTF-8
) else (
| print
)
)
def jump (
if(! print ~/.xyzsh/jump | -e) (
print <<<EOS
/etc/
/var/log/
EOS > ~/.xyzsh/jump
)
cd $(cat ~/.xyzsh/jump | selector | chomp)
)
def menu (
if(! print ~/.xyzsh/menu | -e) (
print <<<EOS
vim ~/.xyzsh/menu
vim ~/.xyzsh/macro
vim ~/.xyzsh/jump
vim ~/.xyzsh/program
ls -al | uc| less
pwd | scan . | less
ls | each ( if(|chomp | -d) ( | print ) )
EOS > ~/.xyzsh/menu
)
eval $(cat ~/.xyzsh/menu | selector | chomp)
)
# when pressing CTRL-X on cmdline, this is called
def cmdline_macro (
if(! print ~/.xyzsh/macro | -e) (
print <<<EOS
whoami | chomp
pwd | chomp
fselector -multiple | each ( | chomp | quote | pomch ) | join | chomp
EOS > ~/.xyzsh/macro
)
| eval $(try (
cat ~/.xyzsh/macro | selector
) catch (
rl::clear_screen
)
)
)
def max (
| var -local MaxValue
| each (
if(| -gt $MaxValue) (
| var -local MaxValue
)
)
MaxValue
)
def min (
| var -local MinValue
| each (
if(| -lt $MinValue ) (
| var -local MinValue
)
)
MinValue
)
### interactive shell settings ###
print 1000 | export XYZSH_HISTSIZE
print ~/.xyzsh/history | export XYZSH_HISTFILE
print "on" | export XYZSH_BLINK_MATCHING_PAREN
# if you don't need to check matching paren on interactive shell, you can set "off" on this variable
print 500 | export XYZSH_BLINK_MATCHING_PAREN_MILLI_SEC
# Above function of xyzsh blink matching paren uses this value to sleep for this milli sec.
print "on" | export XYZSH_MENU_SELECT
# if you don't need to completion with menu select, you can set "off" on this variable
el::keybind -mode emacs
#el::keybind -mode vi
# you can set emacs or vi keybind mode.
el::keybind "^W" "ed-delete-prev-word"
el::keybind "^R" "em-inc-search-prev"
# This is my favorite. you can castamize key binds on interactive shell with el::keybind. Run el::help keybind to see the help.
print off | export HIST_IGNORE_SPACE
# If you enable this, you can add space at head to prohibit from appending commandline history.