blob: 04b48b9ce83cd12e3b3ffc943d026e736c5b8954 [file] [log] [blame]
Bram Moolenaarfead3ac2016-03-28 21:26:47 +02001" When you're writing shell scripts and you are in doubt which test to use,
2" which shell environment variables are defined, what the syntax of the case
3" statement is, and you need to invoke 'man sh'?
4"
5" Your problems are over now!
6"
7" Attached is a Vim script file for turning gvim into a shell script editor.
8" It may also be used as an example how to use menus in Vim.
9"
Bram Moolenaar92f645b2022-02-11 13:29:40 +000010" Maintainer: Ada (Haowen) Yu <me@yuhaowen.com>
11" Original author: Lennart Schultz <les@dmi.min.dk> (mail unreachable)
Bram Moolenaarfead3ac2016-03-28 21:26:47 +020012
Bram Moolenaar92f645b2022-02-11 13:29:40 +000013" Make sure the '<' and 'C' flags are not included in 'cpoptions', otherwise
14" <CR> would not be recognized. See ":help 'cpoptions'".
15let s:cpo_save = &cpo
16set cpo&vim
17
Bram Moolenaarb529cfb2022-07-25 15:42:07 +010018imenu ShellMenu.Statements.for for in <CR>do<CR><CR>done<esc>ki <esc>kk0elli
19imenu ShellMenu.Statements.case case in<CR>) ;;<CR>esac<esc>bki <esc>k0elli
20imenu ShellMenu.Statements.if if <CR>then<CR><CR>fi<esc>ki <esc>kk0elli
21imenu ShellMenu.Statements.if-else if <CR>then<CR><CR>else<CR><CR>fi<esc>ki <esc>kki <esc>kk0elli
22imenu ShellMenu.Statements.elif elif <CR>then<CR><CR><esc>ki <esc>kk0elli
23imenu ShellMenu.Statements.while while do<CR><CR>done<esc>ki <esc>kk0elli
24imenu ShellMenu.Statements.break break
25imenu ShellMenu.Statements.continue continue
26imenu ShellMenu.Statements.function () {<CR><CR>}<esc>ki <esc>k0i
27imenu ShellMenu.Statements.return return
28imenu ShellMenu.Statements.return-true return 0
29imenu ShellMenu.Statements.return-false return 1
30imenu ShellMenu.Statements.exit exit
31imenu ShellMenu.Statements.shift shift
32imenu ShellMenu.Statements.trap trap
33imenu ShellMenu.Test.Existence [ -e ]<esc>hi
34imenu ShellMenu.Test.Existence\ -\ file [ -f ]<esc>hi
35imenu ShellMenu.Test.Existence\ -\ file\ (not\ empty) [ -s ]<esc>hi
36imenu ShellMenu.Test.Existence\ -\ directory [ -d ]<esc>hi
37imenu ShellMenu.Test.Existence\ -\ executable [ -x ]<esc>hi
38imenu ShellMenu.Test.Existence\ -\ readable [ -r ]<esc>hi
39imenu ShellMenu.Test.Existence\ -\ writable [ -w ]<esc>hi
40imenu ShellMenu.Test.String\ is\ empty [ x = "x$" ]<esc>hhi
41imenu ShellMenu.Test.String\ is\ not\ empty [ x != "x$" ]<esc>hhi
42imenu ShellMenu.Test.Strings\ are\ equal [ "" = "" ]<esc>hhhhhhhi
43imenu ShellMenu.Test.Strings\ are\ not\ equal [ "" != "" ]<esc>hhhhhhhhi
44imenu ShellMenu.Test.Value\ is\ greater\ than [ -gt ]<esc>hhhhhhi
45imenu ShellMenu.Test.Value\ is\ greater\ equal [ -ge ]<esc>hhhhhhi
46imenu ShellMenu.Test.Values\ are\ equal [ -eq ]<esc>hhhhhhi
47imenu ShellMenu.Test.Values\ are\ not\ equal [ -ne ]<esc>hhhhhhi
48imenu ShellMenu.Test.Value\ is\ less\ than [ -lt ]<esc>hhhhhhi
49imenu ShellMenu.Test.Value\ is\ less\ equal [ -le ]<esc>hhhhhhi
50imenu ShellMenu.ParmSub.Substitute\ word\ if\ parm\ not\ set ${:-}<esc>hhi
51imenu ShellMenu.ParmSub.Set\ parm\ to\ word\ if\ not\ set ${:=}<esc>hhi
52imenu ShellMenu.ParmSub.Substitute\ word\ if\ parm\ set\ else\ nothing ${:+}<esc>hhi
53imenu ShellMenu.ParmSub.If\ parm\ not\ set\ print\ word\ and\ exit ${:?}<esc>hhi
54imenu ShellMenu.SpShVars.Number\ of\ positional\ parameters ${#}
55imenu ShellMenu.SpShVars.All\ positional\ parameters\ (quoted\ spaces) ${*}
56imenu ShellMenu.SpShVars.All\ positional\ parameters\ (unquoted\ spaces) ${@}
57imenu ShellMenu.SpShVars.Flags\ set ${-}
58imenu ShellMenu.SpShVars.Return\ code\ of\ last\ command ${?}
59imenu ShellMenu.SpShVars.Process\ number\ of\ this\ shell ${$}
60imenu ShellMenu.SpShVars.Process\ number\ of\ last\ background\ command ${!}
61imenu ShellMenu.Environ.HOME ${HOME}
62imenu ShellMenu.Environ.PATH ${PATH}
63imenu ShellMenu.Environ.CDPATH ${CDPATH}
64imenu ShellMenu.Environ.MAIL ${MAIL}
65imenu ShellMenu.Environ.MAILCHECK ${MAILCHECK}
66imenu ShellMenu.Environ.PS1 ${PS1}
67imenu ShellMenu.Environ.PS2 ${PS2}
68imenu ShellMenu.Environ.IFS ${IFS}
69imenu ShellMenu.Environ.SHACCT ${SHACCT}
70imenu ShellMenu.Environ.SHELL ${SHELL}
71imenu ShellMenu.Environ.LC_CTYPE ${LC_CTYPE}
72imenu ShellMenu.Environ.LC_MESSAGES ${LC_MESSAGES}
73imenu ShellMenu.Builtins.cd cd
74imenu ShellMenu.Builtins.echo echo
75imenu ShellMenu.Builtins.eval eval
76imenu ShellMenu.Builtins.exec exec
77imenu ShellMenu.Builtins.export export
78imenu ShellMenu.Builtins.getopts getopts
79imenu ShellMenu.Builtins.hash hash
80imenu ShellMenu.Builtins.newgrp newgrp
81imenu ShellMenu.Builtins.pwd pwd
82imenu ShellMenu.Builtins.read read
83imenu ShellMenu.Builtins.readonly readonly
84imenu ShellMenu.Builtins.return return
85imenu ShellMenu.Builtins.times times
86imenu ShellMenu.Builtins.type type
87imenu ShellMenu.Builtins.umask umask
88imenu ShellMenu.Builtins.wait wait
89imenu ShellMenu.Set.set set
90imenu ShellMenu.Set.unset unset
91imenu ShellMenu.Set.Mark\ created\ or\ modified\ variables\ for\ export set -a
92imenu ShellMenu.Set.Exit\ when\ command\ returns\ non-zero\ status set -e
93imenu ShellMenu.Set.Disable\ file\ name\ expansion set -f
94imenu ShellMenu.Set.Locate\ and\ remember\ commands\ when\ being\ looked\ up set -h
95imenu ShellMenu.Set.All\ assignment\ statements\ are\ placed\ in\ the\ environment\ for\ a\ command set -k
96imenu ShellMenu.Set.Read\ commands\ but\ do\ not\ execute\ them set -n
97imenu ShellMenu.Set.Exit\ after\ reading\ and\ executing\ one\ command set -t
98imenu ShellMenu.Set.Treat\ unset\ variables\ as\ an\ error\ when\ substituting set -u
99imenu ShellMenu.Set.Print\ shell\ input\ lines\ as\ they\ are\ read set -v
100imenu ShellMenu.Set.Print\ commands\ and\ their\ arguments\ as\ they\ are\ executed set -x
Bram Moolenaar92f645b2022-02-11 13:29:40 +0000101
102" Restore the previous value of 'cpoptions'.
103let &cpo = s:cpo_save
104unlet s:cpo_save