blob: 1a5822c1b799541495668486e2122bba6dc9a1af [file] [log] [blame]
Guillaume Nodet97431032016-03-21 16:53:06 +00001#
2# Licensed to the Apache Software Foundation (ASF) under one
3# or more contributor license agreements. See the NOTICE file
4# distributed with this work for additional information
5# regarding copyright ownership. The ASF licenses this file
6# to you under the Apache License, Version 2.0 (the
7# "License"); you may not use this file except in compliance
8# with the License. You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing,
13# software distributed under the License is distributed on an
14# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15# KIND, either express or implied. See the License for the
16# specific language governing permissions and limitations
17# under the License.
18#
19# default gosh_profile
20# only read if etc/gosh_profile doesn't exist relative to the System property
21# gosh.home or failing that the current directory.
22
23# catch all exceptions from this script to avoid it aborting startup
24try {
25
26 # ensure gogo commands are found first
27 SCOPE = gogo:*
28
29 # add methods on BundleContext object as commands
30 addcommand context ${.context}
31
32 # add methods on System object as commands
33 #addcommand system (((${.context} getClass) getClassLoader) loadClass java.lang.System)
34
35 # alias to print full stack trace
36 e = { $exception printStackTrace }
37
38 ## disable console auto-formatting of each result
39 # you will then need to explicitly use the 'format' command
40 # to print the result of commands that don't write to stdout.
41 #.Gogo.format = false
42
43 ## disable printing the formatted result of a command into pipelines
44 #.Format.Pipe = false
45
46 # set prompt
47 prompt = 'g! '
48 \#rprompt = { (new java.text.SimpleDateFormat "HH:mm:ss") format (new Date) }
49
50
51 __option_not_present = {
52 res = true
53 opts = ([ $args ] get 0)
54 each $opts {
55 arg = $it
56 each ($.commandLine words) {
57 if { ($it toString) contentEquals ($arg toString) } {
58 res = false
59 }
60 }
61 }
62 $res
63 }
64
65 __load_class = {
66 (($.reader class) classLoader) loadClass $1
67 }
68
69 __as_list = {
70 (__load_class java.util.Arrays) asList $1
71 }
72
73 __set_unset_arguments = {
74 is_setopt = (($.commandLine words) get 0) equals "setopt"
75 enums = ((__load_class 'org.jline.ConsoleReader$Option') enumConstants)
76 candidates = new ArrayList
77 each (__as_list $enums) {
78 name = ((($it name) toLowerCase) replace '_' '-')
79 is_set = ($.reader isSet $it)
80 neg = %(( if(is_setopt, is_set, not(is_set)) ))
81 if { $neg } {
82 name = "no-${name}"
83 }
84 if { not { (($.commandLine words) subList 1 ($.commandLine wordIndex)) contains $name } } {
85 $candidates add (new org.jline.Candidate $name $name (if { $neg } { "unset" } { "set" }) null null null true)
86 }
87 }
88 $candidates
89 }
90
91 setopt pad-prompts
92 setopt group
93
94 complete -c gogo:complete -e
95 complete -c gogo:complete -d "Edit command specific completions"
96 complete -c gogo:complete -s c -l command --description "Command to add completion to" -n '__option_not_present -c --command' -a '$.commands'
97 complete -c gogo:complete -s s -l short-option --description "Posix-style option to complete" -n '__option_not_present -s --short-option'
98 complete -c gogo:complete -s l -l long-option --description "GNU-style option to complete" -n '__option_not_present -l --long-option'
99 complete -c gogo:complete -s a -l arguments --description "A list of possible arguments" -n '__option_not_present -a --argument'
100 complete -c gogo:complete -s d -l description --description "Description of this completions" -n '__option_not_present -d --description'
101 complete -c gogo:complete -s h -l help --description "Display help and exit" -n '__option_not_present -h --help'
102 complete -c gogo:complete -s n -l condition --description "The completion should only be used if the specified command has a zero exit status" -n '__option_not_present -n --condition'
103 complete -c gogo:complete -s e -l erase --description "Remove completion" -n '__option_not_present -e --erase'
104
105 complete -c gogo:history -e
106 complete -c gogo:history -d "Show and manipulate command history"
107 complete -c gogo:history -l clear --description "Clear history" -n '__option_not_present --clear'
108 complete -c gogo:history -l save --description "Save history" -n '__option_not_present --save'
109
110 complete -c gogo:setopt -e
111 complete -c gogo:setopt -d "Set or view set shell options"
112 complete -c gogo:setopt -a '__set_unset_arguments'
113
114 complete -c gogo:unsetopt -e
115 complete -c gogo:unsetopt -d "Unset or view unset shell options"
116 complete -c gogo:unsetopt -a '__set_unset_arguments'
117
118 complete -c gogo:cat -e
119 complete -c gogo:cat -d "Concatenate and print files"
120 complete -c gogo:cat -s n "Number the output lines, starting at 1"
121 complete -c gogo:cat -a '__files'
122
123 complete -c gogo:pwd -e
124 complete -c gogo:pwd -d "Get current directory"
125
126 complete -c gogo:ls -e
127 complete -c gogo:ls -d "List files"
128
129 complete -c gogo:cd -e
130 complete -c gogo:cd -d "Change current directory"
131 complete -c gogo:cd -a '__directories'
132
133 complete -c gogo:sleep -e
134 complete -c gogo:sleep -d "Pause execution for the specified amount of time"
135
136 complete -c gogo:echo -e
137 complete -c gogo:echo -d "Write arguments to the standard output"
138 complete -c gogo:echo -s n -d "No trailing new line"
139
140 complete -c gogo:grep -e
141 complete -c gogo:grep -d "File pattern searcher"
142 # TODO
143
144 complete -c gogo:sort -e
145 complete -c gogo:sort -d "Sort lines of text files"
146 # TODO
147
148 complete -c gogo:gosh -e
149 complete -c gogo:gosh -d "Execute script with arguments in a new session"
150 # TODO
151
152 complete -c gogo:sh -e
153 complete -c gogo:sh -d "Execute script with arguments in a new session"
154 # TODO
155
156 complete -c gogo:source -e
157 complete -c gogo:source -d "Execute script with arguments"
158 # TODO
159
160 # TODO: format getopt new set tac type addcommand removeCommand eval
161
162 complete -c gogo:each -e
163 complete -c gogo:each -d "Loop and execute script on the specified elements"
164
165 complete -c gogo:if -e
166 complete -c gogo:if -d "Conditionaly execute a script"
167
168 complete -c gogo:not -e
169 complete -c gogo:not -d "Negates the result of a script"
170
171 complete -c gogo:throw -e
172 complete -c gogo:throw -d "Throws an exception"
173
174 complete -c gogo:try -e
175 complete -c gogo:try -d "Try executing a script and catch any exception"
176
177 complete -c gogo:until -e
178 complete -c gogo:until -d "Loop and execute script until a condition is satisfied"
179
180 complete -c gogo:while -e
181 complete -c gogo:while -d "Loop and execute script while a condition is satisfied"
182
183 complete -c gogo:less -e
184 complete -c gogo:less -d "File pager"
185 complete -c gogo:less -s e -l quit-at-eof --description "Exit on second EOF"
186 complete -c gogo:less -s E -l QUIT-AT-EOF --description "Exit on EOF"
187 complete -c gogo:less -s q -l quiet -l silent --description "Silent mode"
188 complete -c gogo:less -s Q -l QUIET -l SILENT --description "Completely silent"
189 complete -c gogo:less -s S -l chop-long-lines --description "Do not fold long lines"
190 complete -c gogo:less -s i -l ignore-case --description "Search ignores lowercase case"
191 complete -c gogo:less -s I -l IGNORE-CASE --description "Search ignores all case"
192 complete -c gogo:less -s x -l tabs --description "Set tab stops"
193 complete -c gogo:less -s N -l LINE-NUMBERS --description "Display line number for each line"
194 complete -c gogo:less -a '__files'
195
196 complete -c gogo:nano -e
197 complete -c gogo:nano -d "File editor"
198 complete -c gogo:nano -a '__files'
199
200 complete -c gogo:keymap -e
201 complete -c gogo:keymap -d "Manipulate keymaps"
202 complete -c gogo:keymap -s N --description "Create a new keymap" -n '__option_not_present -N -d -D -l -r -s -A'
203 complete -c gogo:keymap -s d --description "Delete existing keymaps and reset to default state" -n '__option_not_present -N -d -D -l -r -s -A'
204 complete -c gogo:keymap -s D --description "Delete named keymaps" -n '__option_not_present -N -d -D -l -r -s -A'
205 complete -c gogo:keymap -s l --description "List existing keymap names" -n '__option_not_present -N -d -D -l -r -s -A'
206 complete -c gogo:keymap -s r --description "Unbind specified in-strings" -n '__option_not_present -N -d -D -l -r -s -A'
207 complete -c gogo:keymap -s s --description "Bind each in-string to each out-string" -n '__option_not_present -N -d -D -l -r -s -A'
208 complete -c gogo:keymap -s A --description "Create alias to keymap" -n '__option_not_present -N -d -D -l -r -s -A'
209 complete -c gogo:keymap -s e --description "Select emacs keymap and bind it to main" -n '__option_not_present -e -a -v -M'
210 complete -c gogo:keymap -s v --description "Select viins keymap and bind it to main" -n '__option_not_present -e -a -v -M'
211 complete -c gogo:keymap -s a --description "Select vicmd keymap" -n '__option_not_present -e -a -v -M'
212 complete -c gogo:keymap -s M --description "Specify keymap to select" -n '__option_not_present -e -a -v -M' -a '(keymap -l | tac) split " "'
213 complete -c gogo:keymap -s R --description "Interpret in-strings as ranges"
214 complete -c gogo:keymap -s p --description "List bindings which have given key sequence as a a prefix"
215 complete -c gogo:keymap -s L --description "Output in form of keymap commands"
216
217 complete -c gogo:widget -e
218 complete -c gogo:widget -d "Manipulate widgets"
219 complete -c gogo:widget -s N --description "Create a new widget" -n '__option_not_present -N -A -D -U -l'
220 complete -c gogo:widget -s A --description "Create alias to widget" -n '__option_not_present -N -A -D -U -l'
221 complete -c gogo:widget -s D --description "Delete widgets" -n '__option_not_present -N -A -D -U -l'
222 complete -c gogo:widget -s U --description "Push characters to the stack" -n '__option_not_present -N -A -D -U -l'
223 complete -c gogo:widget -s l --description "List user-defined widgets" -n '__option_not_present -N -A -D -U -l'
224 complete -c gogo:widget -s a --description "With -l, list all widgets" -n '__option_not_present -l'
225
226 complete -c gogo:telnetd -e
227 complete -c gogo:telnetd -d "Telnet daemon"
228 complete -c gogo:telnetd -s i -l ip --description "Listening IP interface" -n '__option_not_present -i --ip'
229 complete -c gogo:telnetd -s p -l port --description "Listening IP port" -n '__option_not_present -p --port'
230 complete -c gogo:telnetd -a '[start stop status]'
231
232 complete -c gogo:sshd -e
233 complete -c gogo:sshd -d "SSH daemon"
234 complete -c gogo:sshd -s i -l ip --description "Listening IP interface" -n '__option_not_present -i --ip'
235 complete -c gogo:sshd -s p -l port --description "Listening IP port" -n '__option_not_present -p --port'
236 complete -c gogo:sshd -a '[start stop status]'
237
238 complete -c gogo:tmux -e
239 complete -c gogo:tmux -d "Terminal multiplexer"
240
241 # print welcome message
242 cat ($0 resolve motd)
243} {
244 echo "$0: ERROR: $exception"
245}
246
247# end