"######################################################################################### " " Filename: bash-support.vim " " Description: BASH support (VIM Version 7.0+) " " Write BASH-scripts by inserting comments, statements, tests, " variables and builtins. " " Configuration: There are some personal details which should be configured " (see the files README.bashsupport and bashsupport.txt). " " Dependencies: The environmnent variables $HOME und $SHELL are used. " " GVIM Version: 7.0+ " " Author: Dr.-Ing. Fritz Mehner, FH Südwestfalen, 58644 Iserlohn, Germany " Email: mehner@fh-swf.de " " Version: see variable g:BASH_Version below " Created: 26.02.2001 " License: Copyright (c) 2001-2009, Fritz Mehner " This program is free software; you can redistribute it and/or " modify it under the terms of the GNU General Public License as " published by the Free Software Foundation, version 2 of the " License. " This program is distributed in the hope that it will be " useful, but WITHOUT ANY WARRANTY; without even the implied " warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR " PURPOSE. " See the GNU General Public License version 2 for more details. " Revision: $Id: bash-support.vim,v 1.37 2009/05/18 13:16:29 mehner Exp $ " "------------------------------------------------------------------------------ " " Prevent duplicate loading: " if exists("g:BASH_Version") || &cp finish endif let g:BASH_Version= "2.11" " version number of this script; do not change " if v:version < 700 echohl WarningMsg | echo 'plugin bash-support.vim needs Vim version >= 7'| echohl None endif " "######################################################################################### " " Global variables (with default values) which can be overridden. " " Key word completion is enabled by the filetype plugin 'sh.vim' " g:BASH_Dictionary_File must be global " ========== Linux/Unix ====================================================== " let s:MSWIN = has("win16") || has("win32") || has("win64") || has("win95") " if s:MSWIN let s:escfilename = '' let s:plugin_dir = $VIM.'\vimfiles\' let s:BASH_CodeSnippets = s:plugin_dir.'bash-support/codesnippets/' let s:BASH_OutputGvim = 'xterm' let s:BASH_BASH = 'win-bash.exe' let s:BASH_Man = 'man.exe' else " " user / system wide installation " if match( expand(""), $VIM ) >= 0 " " system wide installation let s:plugin_dir = $VIM.'/vimfiles/' else " " user installation assumed let s:plugin_dir = $HOME.'/.vim/' end " let s:escfilename = ' \%#[]' let s:BASH_CodeSnippets = $HOME.'/.vim/bash-support/codesnippets/' let s:BASH_OutputGvim = 'vim' let s:BASH_BASH = $SHELL let s:BASH_Man = 'man' endif " "------------------------------------------------------------------------------ " if !exists("g:BASH_Dictionary_File") let g:BASH_Dictionary_File = s:plugin_dir.'bash-support/wordlists/bash.list' endif " " Modul global variables {{{1 " let s:BASH_AuthorName = '' let s:BASH_AuthorRef = '' let s:BASH_Company = '' let s:BASH_CopyrightHolder = '' let s:BASH_Email = '' let s:BASH_Project = '' ' let s:BASH_Debugger = 'term' let s:BASH_DoOnNewLine = 'no' let s:BASH_LineEndCommColDefault = 49 let s:BASH_LoadMenus = 'yes' let s:BASH_MenuHeader = 'yes' let s:BASH_Root = 'B&ash.' " the name of the root menu of this plugin let s:BASH_SyntaxCheckOptionsGlob = '' let s:BASH_Template_Directory = s:plugin_dir.'bash-support/templates/' let s:BASH_Template_File = 'bash-file-header' let s:BASH_Template_Frame = 'bash-frame' let s:BASH_Template_Function = 'bash-function-description' let s:BASH_XtermDefaults = '-fa courier -fs 12 -geometry 80x24' let s:BASH_Printheader = "%<%f%h%m%< %=%{strftime('%x %X')} Page %N" let s:BASH_Wrapper = s:plugin_dir.'bash-support/scripts/wrapper.sh' " let s:BASH_FormatDate = '%x' let s:BASH_FormatTime = '%X %Z' let s:BASH_FormatYear = '%Y' " " "------------------------------------------------------------------------------ " Some variables for internal use only "------------------------------------------------------------------------------ let s:BASH_Active = -1 " state variable controlling the Bash-menus let s:BASH_Errorformat = '%f:\ line\ %l:\ %m' let s:BASH_SetCounter = 0 " let s:BASH_Set_Txt = "SetOptionNumber_" let s:BASH_Shopt_Txt = "ShoptOptionNumber_" " " Bash shopt options (GNU Bash-3.2, manual: 2006 September 28) " let s:BASH_ShoptAllowed = "cdable_vars:cdspell:checkhash:checkwinsize:" let s:BASH_ShoptAllowed = s:BASH_ShoptAllowed."cmdhist:dotglob:execfail:expand_aliases:" let s:BASH_ShoptAllowed = s:BASH_ShoptAllowed."extdebug:extglob:extquote:failglob:" let s:BASH_ShoptAllowed = s:BASH_ShoptAllowed."force_fignore:gnu_errfmt:histappend:histreedit:" let s:BASH_ShoptAllowed = s:BASH_ShoptAllowed."histverify:hostcomplete:huponexit:interactive_comments:" let s:BASH_ShoptAllowed = s:BASH_ShoptAllowed."lithist:login_shell:mailwarn:no_empty_cmd_completion:" let s:BASH_ShoptAllowed = s:BASH_ShoptAllowed."nocaseglob:nocasematch:nocasematch:nullglob:progcomp:promptvars:" let s:BASH_ShoptAllowed = s:BASH_ShoptAllowed."restricted_shell:shift_verbose:sourcepath:xpg_echo:" let s:BASH_Builtins = [ \ 'alias', 'bind', 'break', 'builtin', 'caller', 'case', 'cd', \ 'command', 'compgen', 'complete', 'compopt', 'continue', 'declare', 'dirs', 'disown', \ 'echo', 'enable', 'eval', 'exec', 'exit', 'export', 'false', 'function', \ 'getopts', 'hash', 'history', 'jobs', 'kill', 'let', 'local', 'logout', \ 'mapfile', 'popd', 'printf', 'pushd', 'pwd', 'read', 'readarray', 'readonly', \ 'return', 'select', 'shift', 'shopt', 'source', 'suspend', 'test', 'times', \ 'trap', 'type', 'typeset', 'ulimit', 'umask', 'unalias', \ 'unset', 'wait' \ ] " "------------------------------------------------------------------------------ " Look for global variables (if any) {{{1 "------------------------------------------------------------------------------ function! BASH_CheckGlobal ( name ) if exists('g:'.a:name) exe 'let s:'.a:name.' = g:'.a:name endif endfunction " ---------- end of function BASH_CheckGlobal ---------- " call BASH_CheckGlobal("BASH_AuthorName ") call BASH_CheckGlobal("BASH_AuthorRef ") call BASH_CheckGlobal("BASH_BASH ") call BASH_CheckGlobal("BASH_CodeSnippets ") call BASH_CheckGlobal("BASH_Company ") call BASH_CheckGlobal("BASH_CopyrightHolder ") call BASH_CheckGlobal("BASH_Debugger ") call BASH_CheckGlobal("BASH_DoOnNewLine ") call BASH_CheckGlobal("BASH_Email ") call BASH_CheckGlobal("BASH_FormatDate ") call BASH_CheckGlobal("BASH_FormatTime ") call BASH_CheckGlobal("BASH_FormatYear ") call BASH_CheckGlobal("BASH_LineEndCommColDefault ") call BASH_CheckGlobal("BASH_LoadMenus ") call BASH_CheckGlobal("BASH_Man ") call BASH_CheckGlobal("BASH_MenuHeader ") call BASH_CheckGlobal("BASH_OutputGvim ") call BASH_CheckGlobal("BASH_Printheader ") call BASH_CheckGlobal("BASH_Project ") call BASH_CheckGlobal("BASH_Root ") call BASH_CheckGlobal("BASH_SyntaxCheckOptionsGlob") call BASH_CheckGlobal("BASH_Template_Directory ") call BASH_CheckGlobal("BASH_Template_File ") call BASH_CheckGlobal("BASH_Template_Frame ") call BASH_CheckGlobal("BASH_Template_Function ") call BASH_CheckGlobal("BASH_XtermDefaults ") " " set default geometry if not specified " if match( s:BASH_XtermDefaults, "-geometry\\s\\+\\d\\+x\\d\\+" ) < 0 let s:BASH_XtermDefaults = s:BASH_XtermDefaults." -geometry 80x24" endif " " escape the printheader " let s:BASH_Printheader = escape( s:BASH_Printheader, ' %' ) " "------------------------------------------------------------------------------ " BASH Menu Initialization {{{1 "------------------------------------------------------------------------------ function! BASH_InitMenu () " "=============================================================================================== "----- menu Main menu entry ------------------------------------------- {{{2 "=============================================================================================== if !has("gui_running") return endif " "=============================================================================================== "----- Menu : root menu --------------------------------------------------------------------- "=============================================================================================== if s:BASH_MenuHeader == "yes" call BASH_InitMenuHeader() endif " "------------------------------------------------------------------------------- "----- menu Comments {{{2 "------------------------------------------------------------------------------- exe " menu ".s:BASH_Root.'&Comments.end-of-&line\ comment :call BASH_LineEndComment()A' exe "imenu ".s:BASH_Root.'&Comments.end-of-&line\ comment :call BASH_LineEndComment()A' exe "vmenu ".s:BASH_Root.'&Comments.end-of-&line\ comment :call BASH_MultiLineEndComments()A' exe " menu ".s:BASH_Root.'&Comments.ad&just\ end-of-line\ com\. :call BASH_AdjustLineEndComm("a")' exe "imenu ".s:BASH_Root.'&Comments.ad&just\ end-of-line\ com\. :call BASH_AdjustLineEndComm("a")' exe "vmenu ".s:BASH_Root.'&Comments.ad&just\ end-of-line\ com\. :call BASH_AdjustLineEndComm("v")' exe " menu ".s:BASH_Root.'&Comments.&set\ end-of-line\ com\.\ col\. :call BASH_GetLineEndCommCol()' exe "imenu ".s:BASH_Root.'&Comments.&set\ end-of-line\ com\.\ col\. :call BASH_GetLineEndCommCol()' exe " menu ".s:BASH_Root.'&Comments.&frame\ comment :call BASH_CommentTemplates("frame")' exe " menu ".s:BASH_Root.'&Comments.f&unction\ description :call BASH_CommentTemplates("function")' exe " menu ".s:BASH_Root.'&Comments.file\ &header :call BASH_CommentTemplates("header")' exe "imenu ".s:BASH_Root.'&Comments.&frame\ comment :call BASH_CommentTemplates("frame")' exe "imenu ".s:BASH_Root.'&Comments.f&unction\ description :call BASH_CommentTemplates("function")' exe "imenu ".s:BASH_Root.'&Comments.file\ &header :call BASH_CommentTemplates("header")' exe "amenu ".s:BASH_Root.'&Comments.-Sep1- :' exe " menu ".s:BASH_Root."&Comments.toggle\\ &comment :call BASH_CommentToggle()j" exe "imenu ".s:BASH_Root."&Comments.toggle\\ &comment :call BASH_CommentToggle()j" exe "vmenu ".s:BASH_Root."&Comments.toggle\\ &comment :'<,'>call BASH_CommentToggle()j" exe "amenu ".s:BASH_Root.'&Comments.-SEP2- :' exe " menu ".s:BASH_Root.'&Comments.&date a=BASH_InsertDateAndTime("d")' exe "imenu ".s:BASH_Root.'&Comments.&date =BASH_InsertDateAndTime("d")' exe "vmenu ".s:BASH_Root.'&Comments.&date s=BASH_InsertDateAndTime("d")' exe " menu ".s:BASH_Root.'&Comments.date\ &time a=BASH_InsertDateAndTime("dt")' exe "imenu ".s:BASH_Root.'&Comments.date\ &time =BASH_InsertDateAndTime("dt")' exe "vmenu ".s:BASH_Root.'&Comments.date\ &time s=BASH_InsertDateAndTime("dt")' " exe "amenu ".s:BASH_Root.'&Comments.-SEP3- :' " exe " noremenu ".s:BASH_Root.'&Comments.&echo\ "" ^iecho""j' exe " noremenu ".s:BASH_Root.'&Comments.&remove\ echo 0:s/^\s*echo\s\+\"// \| s/\s*\"\s*$// \| :normal ==j' exe "inoremenu ".s:BASH_Root.'&Comments.&echo\ "" ^iecho""j' exe "inoremenu ".s:BASH_Root.'&Comments.&remove\ echo 0:s/^\s*echo\s\+\"// \| s/\s*\"\s*$// \| :normal ==j' " exe "amenu ".s:BASH_Root.'&Comments.-SEP4- :' " "----- Submenu : BASH-Comments : Keywords ---------------------------------------------------------- " if s:BASH_MenuHeader == "yes" exe "amenu ".s:BASH_Root.'&Comments.\#\ \:&KEYWORD\:.Comments-1Bash ' exe "amenu ".s:BASH_Root.'&Comments.\#\ \:&KEYWORD\:.-Sep1- :' endif " exe " menu ".s:BASH_Root.'&Comments.\#\ \:&KEYWORD\:.&BUG $:call BASH_CommentClassified("BUG") kgJA' exe " menu ".s:BASH_Root.'&Comments.\#\ \:&KEYWORD\:.&TODO $:call BASH_CommentClassified("TODO") kgJA' exe " menu ".s:BASH_Root.'&Comments.\#\ \:&KEYWORD\:.T&RICKY $:call BASH_CommentClassified("TRICKY") kgJA' exe " menu ".s:BASH_Root.'&Comments.\#\ \:&KEYWORD\:.&WARNING $:call BASH_CommentClassified("WARNING") kgJA' exe " menu ".s:BASH_Root.'&Comments.\#\ \:&KEYWORD\:.&new\ keyword $:call BASH_CommentClassified("") kgJf:a' " exe "imenu ".s:BASH_Root.'&Comments.\#\ \:&KEYWORD\:.&BUG $:call BASH_CommentClassified("BUG") kgJA' exe "imenu ".s:BASH_Root.'&Comments.\#\ \:&KEYWORD\:.&TODO $:call BASH_CommentClassified("TODO") kgJA' exe "imenu ".s:BASH_Root.'&Comments.\#\ \:&KEYWORD\:.T&RICKY $:call BASH_CommentClassified("TRICKY") kgJA' exe "imenu ".s:BASH_Root.'&Comments.\#\ \:&KEYWORD\:.&WARNING $:call BASH_CommentClassified("WARNING") kgJA' exe "imenu ".s:BASH_Root.'&Comments.\#\ \:&KEYWORD\:.&new\ keyword $:call BASH_CommentClassified("") kgJf:a' " "----- Submenu : BASH-Comments : Tags ---------------------------------------------------------- " if s:BASH_MenuHeader == "yes" exe "amenu ".s:BASH_Root.'&Comments.ta&gs\ (plugin).Comments-2Bash ' exe "amenu ".s:BASH_Root.'&Comments.ta&gs\ (plugin).-Sep1- :' endif " exe "amenu ".s:BASH_Root.'&Comments.ta&gs\ (plugin).&AUTHOR a'.s:BASH_AuthorName."" exe "amenu ".s:BASH_Root.'&Comments.ta&gs\ (plugin).AUTHOR&REF a'.s:BASH_AuthorRef."" exe "amenu ".s:BASH_Root.'&Comments.ta&gs\ (plugin).&COMPANY a'.s:BASH_Company."" exe "amenu ".s:BASH_Root.'&Comments.ta&gs\ (plugin).C&OPYRIGHTHOLDER a'.s:BASH_CopyrightHolder."" exe "amenu ".s:BASH_Root.'&Comments.ta&gs\ (plugin).&EMAIL a'.s:BASH_Email."" exe "amenu ".s:BASH_Root.'&Comments.ta&gs\ (plugin).&PROJECT a'.s:BASH_Project."" exe "imenu ".s:BASH_Root.'&Comments.ta&gs\ (plugin).&AUTHOR a'.s:BASH_AuthorName exe "imenu ".s:BASH_Root.'&Comments.ta&gs\ (plugin).AUTHOR&REF a'.s:BASH_AuthorRef exe "imenu ".s:BASH_Root.'&Comments.ta&gs\ (plugin).&COMPANY a'.s:BASH_Company exe "imenu ".s:BASH_Root.'&Comments.ta&gs\ (plugin).C&OPYRIGHTHOLDER a'.s:BASH_CopyrightHolder exe "imenu ".s:BASH_Root.'&Comments.ta&gs\ (plugin).&EMAIL a'.s:BASH_Email exe "imenu ".s:BASH_Root.'&Comments.ta&gs\ (plugin).&PROJECT a'.s:BASH_Project " exe " menu ".s:BASH_Root.'&Comments.&vim\ modeline :call BASH_CommentVimModeline()' exe "imenu ".s:BASH_Root.'&Comments.&vim\ modeline :call BASH_CommentVimModeline()' " "------------------------------------------------------------------------------- "----- menu Statements {{{2 "------------------------------------------------------------------------------- exe "anoremenu ".s:BASH_Root.'&Statements.&case ocase in);;);;*);;esac # --- end of case ---11kfa' exe "anoremenu ".s:BASH_Root.'&Statements.e&lif :call BASH_FlowControl( "elif _ ", "then", "", "a" )i' exe "anoremenu ".s:BASH_Root.'&Statements.&for\ in :call BASH_FlowControl( "for _ in ", "do", "done", "a" )i' exe "anoremenu ".s:BASH_Root.'&Statements.for\ ((\.\.\.))\ (&1) :call BASH_FlowControl( "for (( COUNTER=0; COUNTER<_0; COUNTER++ ))", "do", "done", "a" )i' exe "anoremenu ".s:BASH_Root.'&Statements.&if :call BASH_FlowControl( "if _ ", "then", "fi", "a" )i' exe "anoremenu ".s:BASH_Root.'&Statements.if-&else :call BASH_FlowControl( "if _ ", "then", "else\nfi", "a" )i' exe "anoremenu ".s:BASH_Root.'&Statements.&select :call BASH_FlowControl( "select _ in ", "do", "done", "a" )i' exe "anoremenu ".s:BASH_Root.'&Statements.un&til :call BASH_FlowControl( "until _ ", "do", "done", "a" )i' exe "anoremenu ".s:BASH_Root.'&Statements.&while :call BASH_FlowControl( "while _ ", "do", "done", "a" )i' exe "inoremenu ".s:BASH_Root.'&Statements.&for\ in :call BASH_FlowControl( "for _ in ", "do", "done", "a" )i' exe "inoremenu ".s:BASH_Root.'&Statements.for\ ((\.\.\.))\ (&1) :call BASH_FlowControl( "for (( COUNTER=0; COUNTER<_0; COUNTER++ ))", "do", "done", "a" )i' exe "inoremenu ".s:BASH_Root.'&Statements.&if :call BASH_FlowControl( "if _ ", "then", "fi", "a" )i' exe "inoremenu ".s:BASH_Root.'&Statements.e&lif :call BASH_FlowControl( "elif _ ", "then", "", "a" )i' exe "inoremenu ".s:BASH_Root.'&Statements.if-&else :call BASH_FlowControl( "if _ ", "then", "else\nfi", "a" )i' exe "inoremenu ".s:BASH_Root.'&Statements.&select :call BASH_FlowControl( "select _ in ", "do", "done", "a" )i' exe "inoremenu ".s:BASH_Root.'&Statements.un&til :call BASH_FlowControl( "until _ ", "do", "done", "a" )i' exe "inoremenu ".s:BASH_Root.'&Statements.&while :call BASH_FlowControl( "while _ ", "do", "done", "a" )i' exe "vnoremenu ".s:BASH_Root.'&Statements.&for\ in :call BASH_FlowControl( "for _ in ", "do", "done", "v" )' exe "vnoremenu ".s:BASH_Root.'&Statements.for\ ((\.\.\.))\ (&1) :call BASH_FlowControl( "for (( COUNTER=0; COUNTER<_0; COUNTER++ ))", "do", "done", "v" )i' exe "vnoremenu ".s:BASH_Root.'&Statements.&if :call BASH_FlowControl( "if _ ", "then", "fi", "v" )' exe "vnoremenu ".s:BASH_Root.'&Statements.if-&else :call BASH_FlowControl( "if _ ", "then", "else\nfi", "v" )' exe "vnoremenu ".s:BASH_Root.'&Statements.&select :call BASH_FlowControl( "select _ in ", "do", "done", "v" )' exe "vnoremenu ".s:BASH_Root.'&Statements.un&til :call BASH_FlowControl( "until _ ", "do", "done", "v" )' exe "vnoremenu ".s:BASH_Root.'&Statements.&while :call BASH_FlowControl( "while _ ", "do", "done", "v" )' " exe "anoremenu ".s:BASH_Root.'&Statements.-SEP3- :' exe "anoremenu ".s:BASH_Root.'&Statements.&break obreak ' exe "anoremenu ".s:BASH_Root.'&Statements.co&ntinue ocontinue ' exe "anoremenu ".s:BASH_Root.'&Statements.e&xit oexit ' exe "anoremenu ".s:BASH_Root.'&Statements.f&unction :call BASH_CodeFunction("a")O' exe "anoremenu ".s:BASH_Root.'&Statements.&return oreturn ' exe "anoremenu ".s:BASH_Root.'&Statements.s&hift oshift ' exe "anoremenu ".s:BASH_Root.'&Statements.&trap otrap ' " exe "inoremenu ".s:BASH_Root.'&Statements.&break obreak ' exe "inoremenu ".s:BASH_Root.'&Statements.co&ntinue ocontinue ' exe "inoremenu ".s:BASH_Root.'&Statements.e&xit oexit ' exe "inoremenu ".s:BASH_Root.'&Statements.f&unction :call BASH_CodeFunction("a")O' exe "inoremenu ".s:BASH_Root.'&Statements.&return oreturn ' exe "inoremenu ".s:BASH_Root.'&Statements.s&hift oshift ' exe "inoremenu ".s:BASH_Root.'&Statements.&trap otrap ' " exe "vnoremenu ".s:BASH_Root.'&Statements.f&unction :call BASH_CodeFunction("v")' " exe "anoremenu ".s:BASH_Root.'&Statements.-SEP1- :' exe "anoremenu ".s:BASH_Root.'&Statements.&$(\.\.\.) a$()' exe "inoremenu ".s:BASH_Root.'&Statements.&$(\.\.\.) $()' exe "vnoremenu ".s:BASH_Root.'&Statements.&$(\.\.\.) s$()P' exe "anoremenu ".s:BASH_Root.'&Statements.$&{\.\.\.} a${}' exe "inoremenu ".s:BASH_Root.'&Statements.$&{\.\.\.} ${}' exe "vnoremenu ".s:BASH_Root.'&Statements.$&{\.\.\.} s${}P' " exe " noremenu ".s:BASH_Root.'&Statements.$&((\.\.\.)) a$(())hi' exe "inoremenu ".s:BASH_Root.'&Statements.$&((\.\.\.)) $(())' exe "vnoremenu ".s:BASH_Root.'&Statements.$&((\.\.\.)) s$(())hP' "" exe " noremenu ".s:BASH_Root.'&Statements.$&[[\.\.\.]] a$[[]]hi' "" exe "inoremenu ".s:BASH_Root.'&Statements.$&[[\.\.\.]] $[[]]' "" exe "vnoremenu ".s:BASH_Root.'&Statements.$&[[\.\.\.]] s$[[]]hP' " exe "anoremenu ".s:BASH_Root.'&Statements.&printf\ \ "%s\\n" oprintf"%s\n" 2hi' exe "inoremenu ".s:BASH_Root.'&Statements.&printf\ \ "%s\\n" printf"%s\n" 2hi' " exe "anoremenu ".s:BASH_Root.'&Statements.ech&o\ \ -e\ "\\n" oecho-e"\n"2hi' exe "inoremenu ".s:BASH_Root.'&Statements.ech&o\ \ -e\ "\\n" echo-e"\n"2hi' exe "vnoremenu ".s:BASH_Root.'&Statements.ech&o\ \ -e\ "\\n" secho-e"\n"2hP' " exe "amenu ".s:BASH_Root.'&Statements.-SEP5- :' exe "anoremenu ".s:BASH_Root.'&Statements.&array\ elem\.s${\.[@]} a${[@]}' exe "inoremenu ".s:BASH_Root.'&Statements.&array\ elem\.s${\.[@]} ${[@]}' exe "vnoremenu ".s:BASH_Root.'&Statements.&array\ elem\.s${\.[@]} s${[@]}P' exe "anoremenu ".s:BASH_Root.'&Statements.arra&y\ (1\ word)${\.[*]} a${[*]}' exe "inoremenu ".s:BASH_Root.'&Statements.arra&y\ (1\ word)${\.[*]} ${[*]}' exe "vnoremenu ".s:BASH_Root.'&Statements.arra&y\ (1\ word)${\.[*]} s${[*]}P' exe "anoremenu ".s:BASH_Root.'&Statements.no\.\ of\ ele&m\.s${#\.[@]} a${#[@]}' exe "inoremenu ".s:BASH_Root.'&Statements.no\.\ of\ ele&m\.s${#\.[@]} ${#[@]}' exe "vnoremenu ".s:BASH_Root.'&Statements.no\.\ of\ ele&m\.s${#\.[@]} s${#[@]}P' exe "anoremenu ".s:BASH_Root.'&Statements.list\ of\ in&dices${!\.[*]} a${![*]}' exe "inoremenu ".s:BASH_Root.'&Statements.list\ of\ in&dices${!\.[*]} ${![*]}' exe "vnoremenu ".s:BASH_Root.'&Statements.list\ of\ in&dices${!\.[*]} s${![*]}P' " if s:BASH_CodeSnippets != "" exe "amenu ".s:BASH_Root.'&Statements.-SEP6- :' exe " menu ".s:BASH_Root.'&Statements.read\ code\ snippet :call BASH_CodeSnippets("r")' exe " menu ".s:BASH_Root.'&Statements.write\ code\ snippet :call BASH_CodeSnippets("w")' exe " menu ".s:BASH_Root.'&Statements.edit\ code\ snippet :call BASH_CodeSnippets("e")' exe "imenu ".s:BASH_Root.'&Statements.read\ code\ snippet :call BASH_CodeSnippets("r")' exe "imenu ".s:BASH_Root.'&Statements.write\ code\ snippet :call BASH_CodeSnippets("w")' exe "imenu ".s:BASH_Root.'&Statements.edit\ code\ snippet :call BASH_CodeSnippets("e")' exe "vmenu ".s:BASH_Root.'&Statements.write\ code\ snippet :call BASH_CodeSnippets("wv")' endif " "------------------------------------------------------------------------------- "----- menu Tests {{{2 "------------------------------------------------------------------------------- exe " noremenu ".s:BASH_Root.'&Tests.file\ &exists-e a[ -e ]' exe " noremenu ".s:BASH_Root.'&Tests.file\ exists\ and\ has\ a\ &size\ greater\ than\ zero-s a[ -s ]' " exe "inoremenu ".s:BASH_Root.'&Tests.file\ &exists-e [ -e ]' exe "inoremenu ".s:BASH_Root.'&Tests.file\ exists\ and\ has\ a\ &size\ greater\ than\ zero-s [ -s ]' " exe "imenu ".s:BASH_Root.'&Tests.-Sep1- :' " "---------- submenu arithmetic tests ----------------------------------------------------------- " exe " noremenu ".s:BASH_Root.'&Tests.&arithmetic\ tests.arg1\ is\ &equal\ to\ arg2-eq a[ -eq ]F-hi' exe " noremenu ".s:BASH_Root.'&Tests.&arithmetic\ tests.arg1\ ¬\ equal\ to\ arg2-ne a[ -ne ]F-hi' exe " noremenu ".s:BASH_Root.'&Tests.&arithmetic\ tests.arg1\ &less\ than\ arg2-lt a[ -lt ]F-hi' exe " noremenu ".s:BASH_Root.'&Tests.&arithmetic\ tests.arg1\ le&ss\ than\ or\ equal\ to\ arg2-le a[ -le ]F-hi' exe " noremenu ".s:BASH_Root.'&Tests.&arithmetic\ tests.arg1\ &greater\ than\ arg2-gt a[ -gt ]F-hi' exe " noremenu ".s:BASH_Root.'&Tests.&arithmetic\ tests.arg1\ g&reater\ than\ or\ equal\ to\ arg2-ge a[ -ge ]F-hi' " exe "inoremenu ".s:BASH_Root.'&Tests.&arithmetic\ tests.arg1\ is\ &equal\ to\ arg2-eq [ -eq ]F-hi' exe "inoremenu ".s:BASH_Root.'&Tests.&arithmetic\ tests.arg1\ ¬\ equal\ to\ arg2-ne [ -ne ]F-hi' exe "inoremenu ".s:BASH_Root.'&Tests.&arithmetic\ tests.arg1\ &less\ than\ arg2-lt [ -lt ]F-hi' exe "inoremenu ".s:BASH_Root.'&Tests.&arithmetic\ tests.arg1\ le&ss\ than\ or\ equal\ to\ arg2-le [ -le ]F-hi' exe "inoremenu ".s:BASH_Root.'&Tests.&arithmetic\ tests.arg1\ &greater\ than\ arg2-gt [ -gt ]F-hi' exe "inoremenu ".s:BASH_Root.'&Tests.&arithmetic\ tests.arg1\ g&reater\ than\ or\ equal\ to\ arg2-ge [ -ge ]F-hi' " "---------- submenu file exists and has permission --------------------------------------------- " exe " noremenu ".s:BASH_Root.'&Tests.file\ exists\ and\ has\ &permission.file\ exists\ and ' exe " noremenu ".s:BASH_Root.'&Tests.file\ exists\ and\ has\ &permission.\ is\ &readable-r a[ -r ]' exe " noremenu ".s:BASH_Root.'&Tests.file\ exists\ and\ has\ &permission.\ is\ &writable-w a[ -w ]' exe " noremenu ".s:BASH_Root.'&Tests.file\ exists\ and\ has\ &permission.\ is\ e&xecutable-x a[ -x ]' exe " noremenu ".s:BASH_Root.'&Tests.file\ exists\ and\ has\ &permission.\ its\ S&UID-bit\ is\ set-u a[ -u ]' exe " noremenu ".s:BASH_Root.'&Tests.file\ exists\ and\ has\ &permission.\ its\ S&GID-bit\ is\ set-g a[ -g ]' exe " noremenu ".s:BASH_Root.'&Tests.file\ exists\ and\ has\ &permission.\ its\ "stic&ky"\ bit\ is\ set-k a[ -k ]' " exe "inoremenu ".s:BASH_Root.'&Tests.file\ exists\ and\ has\ &permission.file\ exists\ and ' exe "inoremenu ".s:BASH_Root.'&Tests.file\ exists\ and\ has\ &permission.\ is\ &readable-r [ -r ]' exe "inoremenu ".s:BASH_Root.'&Tests.file\ exists\ and\ has\ &permission.\ is\ &writable-w [ -w ]' exe "inoremenu ".s:BASH_Root.'&Tests.file\ exists\ and\ has\ &permission.\ is\ e&xecutable-x [ -x ]' exe "inoremenu ".s:BASH_Root.'&Tests.file\ exists\ and\ has\ &permission.\ its\ S&UID-bit\ is\ set-u [ -u ]' exe "inoremenu ".s:BASH_Root.'&Tests.file\ exists\ and\ has\ &permission.\ its\ S&GID-bit\ is\ set-g [ -g ]' exe "inoremenu ".s:BASH_Root.'&Tests.file\ exists\ and\ has\ &permission.\ its\ "stic&ky"\ bit\ is\ set-k [ -k ]' " "---------- submenu file exists and has type ---------------------------------------------------- " exe " noremenu ".s:BASH_Root.'&Tests.file\ exists\ and\ has\ t&ype.file\ exists\ and\ is\ a ' exe " noremenu ".s:BASH_Root.'&Tests.file\ exists\ and\ has\ t&ype.\ &block\ special\ file-b a[ -b ]' exe " noremenu ".s:BASH_Root.'&Tests.file\ exists\ and\ has\ t&ype.\ &character\ special\ file-c a[ -c ]' exe " noremenu ".s:BASH_Root.'&Tests.file\ exists\ and\ has\ t&ype.\ &directory-d a[ -d ]' exe " noremenu ".s:BASH_Root.'&Tests.file\ exists\ and\ has\ t&ype.\ named\ &pipe\ (FIFO)-p a[ -p ]' exe " noremenu ".s:BASH_Root.'&Tests.file\ exists\ and\ has\ t&ype.\ regular\ &file-f a[ -f ]' exe " noremenu ".s:BASH_Root.'&Tests.file\ exists\ and\ has\ t&ype.\ &socket-S a[ -S ]' exe " noremenu ".s:BASH_Root.'&Tests.file\ exists\ and\ has\ t&ype.\ symbolic\ &link-L a[ -L ]' " exe "inoremenu ".s:BASH_Root.'&Tests.file\ exists\ and\ has\ t&ype.file\ exists\ and\ is\ a ' exe "inoremenu ".s:BASH_Root.'&Tests.file\ exists\ and\ has\ t&ype.\ &block\ special\ file-b [ -b ]' exe "inoremenu ".s:BASH_Root.'&Tests.file\ exists\ and\ has\ t&ype.\ &character\ special\ file-c [ -c ]' exe "inoremenu ".s:BASH_Root.'&Tests.file\ exists\ and\ has\ t&ype.\ &directory-d [ -d ]' exe "inoremenu ".s:BASH_Root.'&Tests.file\ exists\ and\ has\ t&ype.\ named\ &pipe\ (FIFO)p- [ -p ]' exe "inoremenu ".s:BASH_Root.'&Tests.file\ exists\ and\ has\ t&ype.\ regular\ &file-f [ -f ]' exe "inoremenu ".s:BASH_Root.'&Tests.file\ exists\ and\ has\ t&ype.\ &socket-S [ -S ]' exe "inoremenu ".s:BASH_Root.'&Tests.file\ exists\ and\ has\ t&ype.\ symbolic\ &link-L [ -L ]' " "---------- submenu string comparison ------------------------------------------------------------ " exe " noremenu ".s:BASH_Root.'&Tests.string\ &comparison.length\ of\ string\ is\ &zero-z a[ -z ]' exe " noremenu ".s:BASH_Root.'&Tests.string\ &comparison.length\ of\ string\ is\ &non-zero-n a[ -n ]' exe " noremenu ".s:BASH_Root.'&Tests.string\ &comparison.strings\ are\ &equal== a[ == ]bhi' exe " noremenu ".s:BASH_Root.'&Tests.string\ &comparison.strings\ are\ n&ot\ equal!= a[ != ]bhi' exe " noremenu ".s:BASH_Root.'&Tests.string\ &comparison.string1\ sorts\ &before\ string2\ lexicograph\.< a[ < ]bhi' exe " noremenu ".s:BASH_Root.'&Tests.string\ &comparison.string1\ sorts\ &after\ string2\ lexicograph\.> a[ > ]bhi' exe " noremenu ".s:BASH_Root.'&Tests.string\ &comparison.string\ matches\ ®exp=~ a[[ =~ ]]2bhi' " exe "inoremenu ".s:BASH_Root.'&Tests.string\ &comparison.length\ of\ string\ is\ &zero-z [ -z ]' exe "inoremenu ".s:BASH_Root.'&Tests.string\ &comparison.length\ of\ string\ is\ &non-zero-n [ -n ]' exe "inoremenu ".s:BASH_Root.'&Tests.string\ &comparison.strings\ are\ &equal== [ == ]bhi' exe "inoremenu ".s:BASH_Root.'&Tests.string\ &comparison.strings\ are\ n&ot\ equal!= [ != ]bhi' exe "inoremenu ".s:BASH_Root.'&Tests.string\ &comparison.string1\ sorts\ &before\ string2\ lexicograph\.< [ < ]bhi' exe "inoremenu ".s:BASH_Root.'&Tests.string\ &comparison.string1\ sorts\ &after\ string2\ lexicograph\.> [ > ]bhi' exe "inoremenu ".s:BASH_Root.'&Tests.string\ &comparison.string\ matches\ ®exp=~ [[ =~ ]]2bhi' " exe " noremenu ".s:BASH_Root.'&Tests.file\ exists\ and\ is\ &owned\ by\ the\ effective\ UID-O a[ -O ]' exe " noremenu ".s:BASH_Root.'&Tests.file\ exists\ and\ is\ owned\ by\ the\ effective\ &GID-G a[ -G ]' exe " noremenu ".s:BASH_Root.'&Tests.file\ exists\ a&nd\ has\ been\ modified\ since\ it\ was\ last\ read-N a[ -N ]' exe " noremenu ".s:BASH_Root.'&Tests.file\ descriptor\ fd\ is\ open\ and\ refers\ to\ a\ &terminal-t a[ -t ]' exe " noremenu ".s:BASH_Root.'&Tests.-Sep3- :' exe " noremenu ".s:BASH_Root.'&Tests.file&1\ is\ newer\ than\ file2\ (modification\ date)-nt a[ -nt ]F-hi' exe " noremenu ".s:BASH_Root.'&Tests.file1\ is\ older\ than\ file&2-ot a[ -ot ]F-hi' exe " noremenu ".s:BASH_Root.'&Tests.file1\ and\ file2\ have\ the\ same\ device\ and\ &inode\ numbers-ef a[ -ef ]F-hi' exe " noremenu ".s:BASH_Root.'&Tests.-Sep4- :' exe " noremenu ".s:BASH_Root.'&Tests.&shell\ option\ optname\ is\ enabled-o a[ -o ]' " exe "inoremenu ".s:BASH_Root.'&Tests.file\ exists\ and\ is\ &owned\ by\ the\ effective\ UID-O [ -O ]' exe "inoremenu ".s:BASH_Root.'&Tests.file\ exists\ and\ is\ owned\ by\ the\ effective\ &GID-G [ -G ]' exe "inoremenu ".s:BASH_Root.'&Tests.file\ exists\ a&nd\ has\ been\ modified\ since\ it\ was\ last\ read-N [ -N ]' exe "inoremenu ".s:BASH_Root.'&Tests.file\ descriptor\ fd\ is\ open\ and\ refers\ to\ a\ &terminal-t [ -t ]' exe "inoremenu ".s:BASH_Root.'&Tests.-Sep3- :' exe "inoremenu ".s:BASH_Root.'&Tests.file&1\ is\ newer\ than\ file2\ (modification\ date)-nt [ -nt ]F-hi' exe "inoremenu ".s:BASH_Root.'&Tests.file1\ is\ older\ than\ file&2-ot [ -ot ]F-hi' exe "inoremenu ".s:BASH_Root.'&Tests.file1\ and\ file2\ have\ the\ same\ device\ and\ &inode\ numbers-ef [ -ef ]F-hi' exe "inoremenu ".s:BASH_Root.'&Tests.-Sep4- :' exe "inoremenu ".s:BASH_Root.'&Tests.&shell\ option\ optname\ is\ enabled-o [ -o ]' " "------------------------------------------------------------------------------- "----- menu Parameter Substitution {{{2 "------------------------------------------------------------------------------- exe " noremenu ".s:BASH_Root.'&ParamSub.s&ubstitution\ ${\ } a${}' exe " noremenu ".s:BASH_Root.'&ParamSub.use\ &default\ value${\ :-\ } a${:-}' exe " noremenu ".s:BASH_Root.'&ParamSub.&assign\ default\ value${\ :=\ } a${:=}' exe " noremenu ".s:BASH_Root.'&ParamSub.display\ &error\ if\ null\ or\ unset${\ :?\ } a${:?}' exe " noremenu ".s:BASH_Root.'&ParamSub.use\ alternate\ &value${\ :+\ } a${:+}' exe " noremenu ".s:BASH_Root.'&ParamSub.&substring\ expansion${\ :\ :\ } a${::}' exe " noremenu ".s:BASH_Root.'&ParamSub.list\ of\ var\.s\ &beginning\ with\ prefix${!\ *} a${!*}' exe " noremenu ".s:BASH_Root.'&ParamSub.indirect\ parameter\ expansion${!\ } a${!}' exe " noremenu ".s:BASH_Root.'&ParamSub.-Sep1- :' exe " noremenu ".s:BASH_Root.'&ParamSub.¶meter\ length\ in\ characters${#\ } a${#}' exe " noremenu ".s:BASH_Root.'&ParamSub.match\ beginning;\ del\.\ &shortest\ part${\ #\ } a${#}' exe " noremenu ".s:BASH_Root.'&ParamSub.match\ beginning;\ del\.\ &longest\ part${\ ##\ } a${##}' exe " noremenu ".s:BASH_Root.'&ParamSub.match\ end;\ delete\ s&hortest\ part${\ %\ } a${%}' exe " noremenu ".s:BASH_Root.'&ParamSub.match\ end;\ delete\ l&ongest\ part${\ %%\ } a${%%}' exe " noremenu ".s:BASH_Root.'&ParamSub.&replace\ first\ match${\ /\ /\ } a${/ / }F{a' exe " noremenu ".s:BASH_Root.'&ParamSub.replace\ all\ &matches${\ //\ /\ } a${// / }F{a' exe " noremenu ".s:BASH_Root.'&ParamSub.lowercase\ to\ uppercase${\ ^\ } a${^}' exe " noremenu ".s:BASH_Root.'&ParamSub.each\ lowercase\ to\ uppercase${\ ^^\ } a${^^}' exe " noremenu ".s:BASH_Root.'&ParamSub.uppercase\ to\ lowercase${\ ,\ } a${,}' exe " noremenu ".s:BASH_Root.'&ParamSub.each\ upperrcase\ to\ lowercase${\ ,,\ } a${,,}' exe "vnoremenu ".s:BASH_Root.'&ParamSub.s&ubstitution\ ${\ } s${}Pl' " exe "inoremenu ".s:BASH_Root.'&ParamSub.s&ubstitution\ ${\ } ${}' exe "inoremenu ".s:BASH_Root.'&ParamSub.use\ &default\ value${\ :-\ } ${:-}' exe "inoremenu ".s:BASH_Root.'&ParamSub.&assign\ default\ value${\ :=\ } ${:=}' exe "inoremenu ".s:BASH_Root.'&ParamSub.display\ &error\ if\ null\ or\ unset${\ :?\ } ${:?}' exe "inoremenu ".s:BASH_Root.'&ParamSub.use\ alternate\ &value${\ :+\ } ${:+}' exe "inoremenu ".s:BASH_Root.'&ParamSub.&substring\ expansion${\ :\ :\ } ${::}' exe "inoremenu ".s:BASH_Root.'&ParamSub.list\ of\ var\.s\ &beginning\ with\ prefix${!\ *} ${!*}' exe "inoremenu ".s:BASH_Root.'&ParamSub.indirect\ parameter\ expansion${!\.} ${!}' exe "inoremenu ".s:BASH_Root.'&ParamSub.-Sep1- :' exe "inoremenu ".s:BASH_Root.'&ParamSub.¶meter\ length\ in\ characters${#\ } ${#}' exe "inoremenu ".s:BASH_Root.'&ParamSub.match\ beginning;\ del\.\ &shortest\ part${\ #\ } ${#}' exe "inoremenu ".s:BASH_Root.'&ParamSub.match\ beginning;\ del\.\ &longest\ part${\ ##\ } ${##}' exe "inoremenu ".s:BASH_Root.'&ParamSub.match\ end;\ delete\ s&hortest\ part${\ %\ } ${%}' exe "inoremenu ".s:BASH_Root.'&ParamSub.match\ end;\ delete\ l&ongest\ part${\ %%\ } ${%%}' exe "inoremenu ".s:BASH_Root.'&ParamSub.&replace\ first\ match${\ /\ /\ } ${/ / }F{a' exe "inoremenu ".s:BASH_Root.'&ParamSub.replace\ all\ &matches${\ //\ /\ } ${// / }F{a' exe "inoremenu ".s:BASH_Root.'&ParamSub.lowercase\ to\ uppercase${\ ^\ } ${^}' exe "inoremenu ".s:BASH_Root.'&ParamSub.each\ lowercase\ to\ uppercase${\ ^^\ } ${^^}' exe "inoremenu ".s:BASH_Root.'&ParamSub.uppercase\ to\ lowercase${\ ,\ } ${,}' exe "inoremenu ".s:BASH_Root.'&ParamSub.each\ upperrcase\ to\ lowercase${\ ,,\ } ${,,}' " "------------------------------------------------------------------------------- "----- menu Special Variables {{{2 "------------------------------------------------------------------------------- exe " noremenu ".s:BASH_Root.'Spec&Vars.&number\ of\ posit\.\ param\.${#} a${#}' exe " noremenu ".s:BASH_Root.'Spec&Vars.&all\ posit\.\ param\.\ (quoted\ spaces)${*} a${*}' exe " noremenu ".s:BASH_Root.'Spec&Vars.all\ posit\.\ param\.\ (&unquoted\ spaces)${@} a${@}' exe " noremenu ".s:BASH_Root.'Spec&Vars.n&umber\ of\ posit\.\ parameters${#@} a${#@}' exe " noremenu ".s:BASH_Root.'Spec&Vars.&return\ code\ of\ last\ command${?} a${?}' exe " noremenu ".s:BASH_Root.'Spec&Vars.&PID\ of\ this\ shell${$} a${$}' exe " noremenu ".s:BASH_Root.'Spec&Vars.&flags\ set${-} a${-}' exe " noremenu ".s:BASH_Root.'Spec&Vars.&last\ argument\ of\ prev\.\ command${_} a${_}' exe " noremenu ".s:BASH_Root.'Spec&Vars.PID\ of\ last\ &background\ command${!} a${!}' " exe "inoremenu ".s:BASH_Root.'Spec&Vars.&number\ of\ posit\.\ param\.${#} ${#}' exe "inoremenu ".s:BASH_Root.'Spec&Vars.&all\ posit\.\ param\.\ (quoted\ spaces)${*} ${*}' exe "inoremenu ".s:BASH_Root.'Spec&Vars.all\ posit\.\ param\.\ (&unquoted\ spaces)${@} ${@}' exe "inoremenu ".s:BASH_Root.'Spec&Vars.n&umber\ of\ posit\.\ parameters${#@} a${#@}' exe "inoremenu ".s:BASH_Root.'Spec&Vars.&return\ code\ of\ last\ command${?} ${?}' exe "inoremenu ".s:BASH_Root.'Spec&Vars.&PID\ of\ this\ shell${$} ${$}' exe "inoremenu ".s:BASH_Root.'Spec&Vars.&flags\ set${-} ${-}' exe "inoremenu ".s:BASH_Root.'Spec&Vars.&last\ argument\ of\ prev\.\ command${_} a${_}' exe "inoremenu ".s:BASH_Root.'Spec&Vars.PID\ of\ last\ &background\ command${!} ${!}' " "------------------------------------------------------------------------------- "----- menu Environment Variables {{{2 "------------------------------------------------------------------------------- " call BASH_EnvirMenus ( s:BASH_Root.'E&nviron.&BASH\ \.\.\.\ BASH_VERSION', s:BashEnvironmentVariables[0:12] ) " call BASH_EnvirMenus ( s:BASH_Root.'E&nviron.&CDPATH\ \.\.\.\ FUNCNAME', s:BashEnvironmentVariables[13:26] ) " call BASH_EnvirMenus ( s:BASH_Root.'E&nviron.&GLOBIGNORE\ \.\.\.\ LANG', s:BashEnvironmentVariables[27:43] ) " call BASH_EnvirMenus ( s:BASH_Root.'E&nviron.&LC_ALL\ \.\.\.\ OSTYPE', s:BashEnvironmentVariables[44:59] ) " call BASH_EnvirMenus ( s:BASH_Root.'E&nviron.&PATH\ \.\.\.\ UID', s:BashEnvironmentVariables[60:78] ) " "------------------------------------------------------------------------------- "----- menu Builtins a-l {{{2 "------------------------------------------------------------------------------- call BASH_BuiltinMenus ( s:BASH_Root.'&Builtins.Builtins\ \ &a-f', s:BashBuiltins[0:18] ) call BASH_BuiltinMenus ( s:BASH_Root.'&Builtins.Builtins\ \ &g-r', s:BashBuiltins[19:35] ) call BASH_BuiltinMenus ( s:BASH_Root.'&Builtins.Builtins\ \ &s-w', s:BashBuiltins[36:49] ) " " "------------------------------------------------------------------------------- "----- menu set {{{2 "------------------------------------------------------------------------------- " exe "amenu ".s:BASH_Root.'s&et.&allexport-a oset -o allexport ' exe "amenu ".s:BASH_Root.'s&et.&braceexpand-B oset -o braceexpand' exe "amenu ".s:BASH_Root.'s&et.emac&s oset -o emacs ' exe "amenu ".s:BASH_Root.'s&et.&errexit-e oset -o errexit ' exe "amenu ".s:BASH_Root.'s&et.e&rrtrace-E oset -o errtrace ' exe "amenu ".s:BASH_Root.'s&et.func&trace-T oset -o functrace ' exe "amenu ".s:BASH_Root.'s&et.&hashall-h oset -o hashall ' exe "amenu ".s:BASH_Root.'s&et.histexpand\ (&1)-H oset -o histexpand ' exe "amenu ".s:BASH_Root.'s&et.hist&ory oset -o history ' exe "amenu ".s:BASH_Root.'s&et.i&gnoreeof oset -o ignoreeof ' exe "amenu ".s:BASH_Root.'s&et.&keyword-k oset -o keyword ' exe "amenu ".s:BASH_Root.'s&et.&monitor-m oset -o monitor ' exe "amenu ".s:BASH_Root.'s&et.no&clobber-C oset -o noclobber ' exe "amenu ".s:BASH_Root.'s&et.&noexec-n oset -o noexec ' exe "amenu ".s:BASH_Root.'s&et.nog&lob-f oset -o noglob ' exe "amenu ".s:BASH_Root.'s&et.notif&y-b oset -o notify ' exe "amenu ".s:BASH_Root.'s&et.no&unset-u oset -o nounset ' exe "amenu ".s:BASH_Root.'s&et.onecm&d-t oset -o onecmd ' exe "amenu ".s:BASH_Root.'s&et.physical\ (&2)-P oset -o physical ' exe "amenu ".s:BASH_Root.'s&et.pipe&fail oset -o pipefail ' exe "amenu ".s:BASH_Root.'s&et.posix\ (&3) oset -o posix ' exe "amenu ".s:BASH_Root.'s&et.&privileged-p oset -o privileged ' exe "amenu ".s:BASH_Root.'s&et.&verbose-v oset -o verbose ' exe "amenu ".s:BASH_Root.'s&et.v&i oset -o vi ' exe "amenu ".s:BASH_Root.'s&et.&xtrace-x oset -o xtrace ' " exe "vmenu ".s:BASH_Root.'s&et.&allexport-a :call BASH_set("allexport ")' exe "vmenu ".s:BASH_Root.'s&et.&braceexpand-B :call BASH_set("braceexpand")' exe "vmenu ".s:BASH_Root.'s&et.emac&s :call BASH_set("emacs ")' exe "vmenu ".s:BASH_Root.'s&et.&errexit-e :call BASH_set("errexit ")' exe "vmenu ".s:BASH_Root.'s&et.e&rrtrace-E :call BASH_set("errtrace ")' exe "vmenu ".s:BASH_Root.'s&et.func&trace-T :call BASH_set("functrace ")' exe "vmenu ".s:BASH_Root.'s&et.&hashall-h :call BASH_set("hashall ")' exe "vmenu ".s:BASH_Root.'s&et.histexpand\ (&1)-H :call BASH_set("histexpand ")' exe "vmenu ".s:BASH_Root.'s&et.hist&ory :call BASH_set("history ")' exe "vmenu ".s:BASH_Root.'s&et.i&gnoreeof :call BASH_set("ignoreeof ")' exe "vmenu ".s:BASH_Root.'s&et.&keyword-k :call BASH_set("keyword ")' exe "vmenu ".s:BASH_Root.'s&et.&monitor-m :call BASH_set("monitor ")' exe "vmenu ".s:BASH_Root.'s&et.no&clobber-C :call BASH_set("noclobber ")' exe "vmenu ".s:BASH_Root.'s&et.&noexec-n :call BASH_set("noexec ")' exe "vmenu ".s:BASH_Root.'s&et.nog&lob-f :call BASH_set("noglob ")' exe "vmenu ".s:BASH_Root.'s&et.notif&y-b :call BASH_set("notify ")' exe "vmenu ".s:BASH_Root.'s&et.no&unset-u :call BASH_set("nounset ")' exe "vmenu ".s:BASH_Root.'s&et.onecm&d-t :call BASH_set("onecmd ")' exe "vmenu ".s:BASH_Root.'s&et.physical\ (&2)-P :call BASH_set("physical ")' exe "vmenu ".s:BASH_Root.'s&et.pipe&fail :call BASH_set("pipefail ")' exe "vmenu ".s:BASH_Root.'s&et.posix\ (&3) :call BASH_set("posix ")' exe "vmenu ".s:BASH_Root.'s&et.&privileged-p :call BASH_set("privileged ")' exe "vmenu ".s:BASH_Root.'s&et.&verbose-v :call BASH_set("verbose ")' exe "vmenu ".s:BASH_Root.'s&et.v&i :call BASH_set("vi ")' exe "vmenu ".s:BASH_Root.'s&et.&xtrace-x :call BASH_set("xtrace ")' " "------------------------------------------------------------------------------- "----- menu shopt {{{2 "------------------------------------------------------------------------------- call BASH_ShoptMenus ( s:BASH_Root.'sh&opt.shopt\ \ &a-g', s:BashShopt[0:17] ) call BASH_ShoptMenus ( s:BASH_Root.'sh&opt.shopt\ \ &h-x', s:BashShopt[18:36] ) " "------------------------------------------------------------------------------ "----- menu Regex {{{2 "------------------------------------------------------------------------------ " " exe "anoremenu ".s:BASH_Root.'Rege&x.zero\ or\ more\ \ \ &*(\ \|\ ) a*(\|)' exe "anoremenu ".s:BASH_Root.'Rege&x.one\ or\ more\ \ \ \ &+(\ \|\ ) a+(\|)' exe "anoremenu ".s:BASH_Root.'Rege&x.zero\ or\ one\ \ \ \ \ &?(\ \|\ ) a?(\|)' exe "anoremenu ".s:BASH_Root.'Rege&x.exactly\ one\ \ \ \ \ &@(\ \|\ ) a@(\|)' exe "anoremenu ".s:BASH_Root.'Rege&x.anyth\.\ except\ \ \ &!(\ \|\ ) a!(\|)' " exe "inoremenu ".s:BASH_Root.'Rege&x.zero\ or\ more\ \ \ &*(\ \|\ ) *(\|)' exe "inoremenu ".s:BASH_Root.'Rege&x.one\ or\ more\ \ \ \ &+(\ \|\ ) +(\|)' exe "inoremenu ".s:BASH_Root.'Rege&x.zero\ or\ one\ \ \ \ \ &?(\ \|\ ) ?(\|)' exe "inoremenu ".s:BASH_Root.'Rege&x.exactly\ one\ \ \ \ \ &@(\ \|\ ) @(\|)' exe "inoremenu ".s:BASH_Root.'Rege&x.anyth\.\ except\ \ \ &!(\ \|\ ) !(\|)' " exe "vnoremenu ".s:BASH_Root.'Rege&x.zero\ or\ more\ \ \ &*(\ \|\ ) s*(\|)hPla' exe "vnoremenu ".s:BASH_Root.'Rege&x.one\ or\ more\ \ \ \ &+(\ \|\ ) s+(\|)hPla' exe "vnoremenu ".s:BASH_Root.'Rege&x.zero\ or\ one\ \ \ \ \ &?(\ \|\ ) s?(\|)hPla' exe "vnoremenu ".s:BASH_Root.'Rege&x.exactly\ one\ \ \ \ \ &@(\ \|\ ) s@(\|)hPla' exe "vnoremenu ".s:BASH_Root.'Rege&x.anyth\.\ except\ \ \ &!(\ \|\ ) s!(\|)hPla' " exe "amenu ".s:BASH_Root.'Rege&x.-Sep1- :' " exe " noremenu ".s:BASH_Root.'Rege&x.[:&alnum:] a[:alnum:]' exe " noremenu ".s:BASH_Root.'Rege&x.[:alp&ha:] a[:alpha:]' exe " noremenu ".s:BASH_Root.'Rege&x.[:asc&ii:] a[:ascii:]' exe " noremenu ".s:BASH_Root.'Rege&x.[:&cntrl:] a[:cntrl:]' exe " noremenu ".s:BASH_Root.'Rege&x.[:&digit:] a[:digit:]' exe " noremenu ".s:BASH_Root.'Rege&x.[:&graph:] a[:graph:]' exe " noremenu ".s:BASH_Root.'Rege&x.[:&lower:] a[:lower:]' exe " noremenu ".s:BASH_Root.'Rege&x.[:&print:] a[:print:]' exe " noremenu ".s:BASH_Root.'Rege&x.[:pu&nct:] a[:punct:]' exe " noremenu ".s:BASH_Root.'Rege&x.[:&space:] a[:space:]' exe " noremenu ".s:BASH_Root.'Rege&x.[:&upper:] a[:upper:]' exe " noremenu ".s:BASH_Root.'Rege&x.[:&word:] a[:word:]' exe " noremenu ".s:BASH_Root.'Rege&x.[:&xdigit:] a[:xdigit:]' " exe "inoremenu ".s:BASH_Root.'Rege&x.[:&alnum:] [:alnum:]' exe "inoremenu ".s:BASH_Root.'Rege&x.[:alp&ha:] [:alpha:]' exe "inoremenu ".s:BASH_Root.'Rege&x.[:asc&ii:] [:ascii:]' exe "inoremenu ".s:BASH_Root.'Rege&x.[:&cntrl:] [:cntrl:]' exe "inoremenu ".s:BASH_Root.'Rege&x.[:&digit:] [:digit:]' exe "inoremenu ".s:BASH_Root.'Rege&x.[:&graph:] [:graph:]' exe "inoremenu ".s:BASH_Root.'Rege&x.[:&lower:] [:lower:]' exe "inoremenu ".s:BASH_Root.'Rege&x.[:&print:] [:print:]' exe "inoremenu ".s:BASH_Root.'Rege&x.[:pu&nct:] [:punct:]' exe "inoremenu ".s:BASH_Root.'Rege&x.[:&space:] [:space:]' exe "inoremenu ".s:BASH_Root.'Rege&x.[:&upper:] [:upper:]' exe "inoremenu ".s:BASH_Root.'Rege&x.[:&word:] [:word:]' exe "inoremenu ".s:BASH_Root.'Rege&x.[:&xdigit:] [:xdigit:]' " exe " noremenu ".s:BASH_Root.'Rege&x.&[\ \ \ ] a[]' exe "inoremenu ".s:BASH_Root.'Rege&x.&[\ \ \ ] []' exe "vnoremenu ".s:BASH_Root.'Rege&x.&[\ \ \ ] s[]P' " exe "amenu ".s:BASH_Root.'Rege&x.-Sep2- :' " exe "anoremenu ".s:BASH_Root.'Rege&x.${BASH_REMATCH[&0]} a${BASH_REMATCH[0]}' exe "anoremenu ".s:BASH_Root.'Rege&x.${BASH_REMATCH[&1]} a${BASH_REMATCH[1]}' exe "anoremenu ".s:BASH_Root.'Rege&x.${BASH_REMATCH[&2]} a${BASH_REMATCH[2]}' exe "anoremenu ".s:BASH_Root.'Rege&x.${BASH_REMATCH[&3]} a${BASH_REMATCH[3]}' " exe "inoremenu ".s:BASH_Root.'Rege&x.${BASH_REMATCH[&0]} a${BASH_REMATCH[0]}' exe "inoremenu ".s:BASH_Root.'Rege&x.${BASH_REMATCH[&1]} a${BASH_REMATCH[1]}' exe "inoremenu ".s:BASH_Root.'Rege&x.${BASH_REMATCH[&2]} a${BASH_REMATCH[2]}' exe "inoremenu ".s:BASH_Root.'Rege&x.${BASH_REMATCH[&3]} a${BASH_REMATCH[3]}' " " "------------------------------------------------------------------------------- "----- menu I/O redirection {{{2 "------------------------------------------------------------------------------- " exe " menu ".s:BASH_Root.'&I/O-Redir.take\ STDIN\ from\ file< a<' exe " menu ".s:BASH_Root.'&I/O-Redir.direct\ STDOUT\ to\ file> a>' exe " menu ".s:BASH_Root.'&I/O-Redir.direct\ STDOUT\ to\ file;\ append>> a>>' " exe " menu ".s:BASH_Root.'&I/O-Redir.direct\ file\ descr\.\ n\ to\ filen> a>2hi' exe " menu ".s:BASH_Root.'&I/O-Redir.direct\ file\ descr\.\ n\ to\ file;\ appendn>> a>>3hi' exe " menu ".s:BASH_Root.'&I/O-Redir.take\ file\ descr\.\ n\ from\ filen< a<2hi' " exe " menu ".s:BASH_Root.'&I/O-Redir.duplicate\ STDOUT\ to\ file\ descr\.\ nn>& a>& 2hi' exe " menu ".s:BASH_Root.'&I/O-Redir.duplicate\ STDIN\ from\ file\ descr\.\ nn<& a<& 2hi' exe " menu ".s:BASH_Root.'&I/O-Redir.direct\ STDOUT\ and\ STDERR\ to\ file&> a&> ' " exe " menu ".s:BASH_Root.'&I/O-Redir.close\ STDIN<&- a<&- ' exe " menu ".s:BASH_Root.'&I/O-Redir.close\ STDOUT>&- a>&- ' exe " menu ".s:BASH_Root.'&I/O-Redir.close\ input\ from\ file\ descr\.\ nn<&- a<&- 3hi' exe " menu ".s:BASH_Root.'&I/O-Redir.close\ output\ from\ file\ descr\.\ nn>&- a>&- 3hi' exe " menu ".s:BASH_Root.'&I/O-Redir.append\ STDOUT\ and\ STDERR&>> a&>> ' " exe "imenu ".s:BASH_Root.'&I/O-Redir.take\ STDIN\ from\ file< <' exe "imenu ".s:BASH_Root.'&I/O-Redir.direct\ STDOUT\ to\ file> >' exe "imenu ".s:BASH_Root.'&I/O-Redir.direct\ STDOUT\ to\ file;\ append>> >>' " exe "imenu ".s:BASH_Root.'&I/O-Redir.direct\ file\ descr\.\ n\ to\ filen> >2hi' exe "imenu ".s:BASH_Root.'&I/O-Redir.direct\ file\ descr\.\ n\ to\ file;\ appendn>> >>3hi' exe "imenu ".s:BASH_Root.'&I/O-Redir.take\ file\ descr\.\ n\ from\ filen< <2hi' " exe "imenu ".s:BASH_Root.'&I/O-Redir.duplicate\ STDOUT\ to\ file\ descr\.\ nn>& >& ' exe "imenu ".s:BASH_Root.'&I/O-Redir.duplicate\ STDIN\ from\ file\ descr\.\ nn<& <& ' exe "imenu ".s:BASH_Root.'&I/O-Redir.direct\ STDOUT\ and\ STDERR\ to\ file&> &> ' " exe "imenu ".s:BASH_Root.'&I/O-Redir.close\ STDIN<&- <&- ' exe "imenu ".s:BASH_Root.'&I/O-Redir.close\ STDOUT>&- >&- ' exe "imenu ".s:BASH_Root.'&I/O-Redir.close\ input\ from\ file\ descr\.\ nn<&- <&- 3hi' exe "imenu ".s:BASH_Root.'&I/O-Redir.close\ output\ from\ file\ descr\.\ nn>&- >&- 3hi' exe "imenu ".s:BASH_Root.'&I/O-Redir.append\ STDOUT\ and\ STDERR&>> &>> ' " " exe " menu ".s:BASH_Root.'&I/O-Redir.here-document<<-label a<<-EOFEOF# ===== end of here-document =====2ki' exe "imenu ".s:BASH_Root.'&I/O-Redir.here-document<<-label <<-EOFEOF# ===== end of here-document =====2ki' exe "vmenu ".s:BASH_Root.'&I/O-Redir.here-document<<-label S<<-EOFEOF# ===== end of here-document =====kPk^i' " "------------------------------------------------------------------------------ "----- menu Run {{{2 "------------------------------------------------------------------------------ " run the script from the local directory " ( the one in the current buffer ; other versions may exist elsewhere ! ) " exe " menu ".s:BASH_Root.'&Run.save\ +\ &run\ script :call BASH_Run("n")' exe "imenu ".s:BASH_Root.'&Run.save\ +\ &run\ script :call BASH_Run("n")' if !s:MSWIN exe "vmenu ".s:BASH_Root.'&Run.save\ +\ &run\ script :call BASH_Run("v")' endif " " set execution right only for the user ( may be user root ! ) " exe " menu ".s:BASH_Root.'&Run.cmd\.\ line\ &arg\. :call BASH_CmdLineArguments()' exe "imenu ".s:BASH_Root.'&Run.cmd\.\ line\ &arg\. :call BASH_CmdLineArguments()' if !s:MSWIN exe " menu ".s:BASH_Root.'&Run.start\ &debugger :call BASH_Debugger()' exe "imenu ".s:BASH_Root.'&Run.start\ &debugger :call BASH_Debugger()' exe " menu ".s:BASH_Root.'&Run.make\ script\ &executable :call BASH_MakeScriptExecutable()' exe "imenu ".s:BASH_Root.'&Run.make\ script\ &executable :call BASH_MakeScriptExecutable()' exe " menu ".s:BASH_Root.'&Run.save\ +\ &check\ syntax :call BASH_SyntaxCheck()' exe "imenu ".s:BASH_Root.'&Run.save\ +\ &check\ syntax :call BASH_SyntaxCheck()' exe " menu ".s:BASH_Root.'&Run.syntax\ check\ o&ptions :call BASH_SyntaxCheckOptionsLocal()' exe "imenu ".s:BASH_Root.'&Run.syntax\ check\ o&ptions :call BASH_SyntaxCheckOptionsLocal()' endif " exe "amenu ".s:BASH_Root.'&Run.-Sep1- :' " if s:MSWIN exe " menu ".s:BASH_Root.'&Run.&hardcopy\ to\ printer\.ps :call BASH_Hardcopy("n")' exe "imenu ".s:BASH_Root.'&Run.&hardcopy\ to\ printer\.ps :call BASH_Hardcopy("n")' exe "vmenu ".s:BASH_Root.'&Run.&hardcopy\ to\ printer\.ps :call BASH_Hardcopy("v")' else exe " menu ".s:BASH_Root.'&Run.&hardcopy\ to\ FILENAME\.ps :call BASH_Hardcopy("n")' exe "imenu ".s:BASH_Root.'&Run.&hardcopy\ to\ FILENAME\.ps :call BASH_Hardcopy("n")' exe "vmenu ".s:BASH_Root.'&Run.&hardcopy\ to\ FILENAME\.ps :call BASH_Hardcopy("v")' endif exe " menu ".s:BASH_Root.'&Run.-SEP2- :' exe " menu ".s:BASH_Root.'&Run.plugin\ &settings :call BASH_Settings()' exe "imenu ".s:BASH_Root.'&Run.plugin\ &settings :call BASH_Settings()' " exe "imenu ".s:BASH_Root.'&Run.-SEP3- :' " if !s:MSWIN exe " menu ".s:BASH_Root.'&Run.x&term\ size :call BASH_XtermSize()' exe "imenu ".s:BASH_Root.'&Run.x&term\ size :call BASH_XtermSize()' endif " if s:MSWIN if s:BASH_OutputGvim == "buffer" exe " menu ".s:BASH_Root.'&Run.&output:\ BUFFER->term :call BASH_Toggle_Gvim_Xterm_MS()' exe "imenu ".s:BASH_Root.'&Run.&output:\ BUFFER->term :call BASH_Toggle_Gvim_Xterm_MS()' else exe " menu ".s:BASH_Root.'&Run.&output:\ TERM->buffer :call BASH_Toggle_Gvim_Xterm_MS()' exe "imenu ".s:BASH_Root.'&Run.&output:\ TERM->buffer :call BASH_Toggle_Gvim_Xterm_MS()' endif else if s:BASH_OutputGvim == "vim" exe " menu ".s:BASH_Root.'&Run.&output:\ VIM->buffer->xterm :call BASH_Toggle_Gvim_Xterm()' exe "imenu ".s:BASH_Root.'&Run.&output:\ VIM->buffer->xterm :call BASH_Toggle_Gvim_Xterm()' else if s:BASH_OutputGvim == "buffer" exe " menu ".s:BASH_Root.'&Run.&output:\ BUFFER->xterm->vim :call BASH_Toggle_Gvim_Xterm()' exe "imenu ".s:BASH_Root.'&Run.&output:\ BUFFER->xterm->vim :call BASH_Toggle_Gvim_Xterm()' else exe " menu ".s:BASH_Root.'&Run.&output:\ XTERM->vim->buffer :call BASH_Toggle_Gvim_Xterm()' exe "imenu ".s:BASH_Root.'&Run.&output:\ XTERM->vim->buffer :call BASH_Toggle_Gvim_Xterm()' endif endif endif " "=============================================================================================== "----- menu help {{{2 "=============================================================================================== " if s:BASH_Root != "" " exe " menu ".s:BASH_Root.'&Help.&help\ (Bash\ builtins) :call BASH_help("h")' exe "imenu ".s:BASH_Root.'&Help.&help\ (Bash\ builtins) :call BASH_help("h")' " exe " menu ".s:BASH_Root.'&Help.&manual\ (utilities) :call BASH_help("m")' exe "imenu ".s:BASH_Root.'&Help.&manual\ (utilities) :call BASH_help("m")' " exe " menu ".s:BASH_Root.'&Help.bash-&support :call BASH_HelpBASHsupport()' exe "imenu ".s:BASH_Root.'&Help.bash-&support :call BASH_HelpBASHsupport()' endif " endfunction " ---------- end of function BASH_InitMenu ---------- "------------------------------------------------------------------------------ " BASH Menu Header Initialization {{{1 "------------------------------------------------------------------------------ function! BASH_InitMenuHeader () if s:BASH_Root != "" exe "amenu ".s:BASH_Root.'Bash ' exe "amenu ".s:BASH_Root.'-Sep0- :' endif exe "amenu ".s:BASH_Root.'&Comments.CommentsBash ' exe "amenu ".s:BASH_Root.'&Comments.-Sep0- :' exe "amenu ".s:BASH_Root.'&Statements.StatementsBash ' exe "amenu ".s:BASH_Root.'&Statements.-Sep0- :' exe "amenu ".s:BASH_Root.'&Tests.Tests-0Bash ' exe "amenu ".s:BASH_Root.'&Tests.-Sep0- :' exe "amenu ".s:BASH_Root.'&Tests.&arithmetic\ tests.Tests-1Bash ' exe "amenu ".s:BASH_Root.'&Tests.&arithmetic\ tests.-Sep0- :' exe "amenu ".s:BASH_Root.'&Tests.file\ exists\ and\ has\ &permission.Tests-2Bash ' exe "amenu ".s:BASH_Root.'&Tests.file\ exists\ and\ has\ &permission.-Sep0- :' exe "amenu ".s:BASH_Root.'&Tests.file\ exists\ and\ has\ t&ype.Tests-3Bash ' exe "amenu ".s:BASH_Root.'&Tests.file\ exists\ and\ has\ t&ype.-Sep0- :' exe "amenu ".s:BASH_Root.'&Tests.string\ &comparison.Tests-4Bash ' exe "amenu ".s:BASH_Root.'&Tests.string\ &comparison.-Sep0- :' exe "amenu ".s:BASH_Root.'&ParamSub.ParamSubBash ' exe "amenu ".s:BASH_Root.'&ParamSub.-Sep0- :' exe "amenu ".s:BASH_Root.'Spec&Vars.SpecVarsBash ' exe "amenu ".s:BASH_Root.'Spec&Vars.-Sep0- :' exe "amenu ".s:BASH_Root.'E&nviron.EnvironBash ' exe "amenu ".s:BASH_Root.'E&nviron.-Sep0- :' exe "amenu ".s:BASH_Root.'E&nviron.&BASH\ \.\.\.\ BASH_VERSION.Environ-1Bash ' exe "amenu ".s:BASH_Root.'E&nviron.&BASH\ \.\.\.\ BASH_VERSION.-Sep0- :' exe "amenu ".s:BASH_Root.'E&nviron.&CDPATH\ \.\.\.\ FUNCNAME.Environ-2Bash ' exe "amenu ".s:BASH_Root.'E&nviron.&CDPATH\ \.\.\.\ FUNCNAME.-Sep0- :' exe "amenu ".s:BASH_Root.'E&nviron.&GLOBIGNORE\ \.\.\.\ LANG.Environ-3Bash ' exe "amenu ".s:BASH_Root.'E&nviron.&GLOBIGNORE\ \.\.\.\ LANG.-Sep0- :' exe "amenu ".s:BASH_Root.'E&nviron.&LC_ALL\ \.\.\.\ OSTYPE.Environ-4Bash ' exe "amenu ".s:BASH_Root.'E&nviron.&LC_ALL\ \.\.\.\ OSTYPE.-Sep0- :' exe "amenu ".s:BASH_Root.'E&nviron.&PATH\ \.\.\.\ UID.Environ-5Bash ' exe "amenu ".s:BASH_Root.'E&nviron.&PATH\ \.\.\.\ UID.-Sep0- :' exe "amenu ".s:BASH_Root.'&Builtins.Builtins\ \ &a-f.Builtins\ 1Bash ' exe "amenu ".s:BASH_Root.'&Builtins.Builtins\ \ &a-f.-Sep0- :' exe "amenu ".s:BASH_Root.'&Builtins.Builtins\ \ &g-r.Builtins\ 2Bash ' exe "amenu ".s:BASH_Root.'&Builtins.Builtins\ \ &g-r.-Sep0- :' exe "amenu ".s:BASH_Root.'&Builtins.Builtins\ \ &s-w.Builtins\ 3Bash ' exe "amenu ".s:BASH_Root.'&Builtins.Builtins\ \ &s-w.-Sep0- :' exe "amenu ".s:BASH_Root.'s&et.setBash ' exe "amenu ".s:BASH_Root.'s&et.-Sep0- :' exe "amenu ".s:BASH_Root.'sh&opt.shopt\ \ &a-g.shopt\ 1Bash ' exe "amenu ".s:BASH_Root.'sh&opt.shopt\ \ &a-g.-Sep0- :' exe "amenu ".s:BASH_Root.'sh&opt.shopt\ \ &h-x.shopt\ 2Bash ' exe "amenu ".s:BASH_Root.'sh&opt.shopt\ \ &h-x.-Sep0- :' exe "amenu ".s:BASH_Root.'Rege&x.Regexbash ' exe "amenu ".s:BASH_Root.'Rege&x.-Sep0- :' exe "amenu ".s:BASH_Root.'&I/O-Redir.I/O-RedirBash ' exe "amenu ".s:BASH_Root.'&I/O-Redir.-Sep0- :' exe "amenu ".s:BASH_Root.'&Run.RunBash ' exe "amenu ".s:BASH_Root.'&Run.-Sep0- :' exe "amenu ".s:BASH_Root.'&Help.HelpBash ' exe "amenu ".s:BASH_Root.'&Help.-Sep0- :' endfunction " ---------- end of function BASH_InitMenuHeader ---------- let s:BashEnvironmentVariables = [ \ '&BASH', 'BASH&PID', 'BASH_ARG&C', 'BASH_ARG&V', 'BASH_C&OMMAND', \ 'BASH_&ENV', 'BASH_E&XECUTION_STRING', 'BASH_&LINENO', 'BASH_&REMATCH', \ 'BASH_&SOURCE', 'BASH_S&UBSHELL', 'BASH_VERS&INFO', 'BASH_VERSIO&N', \ '&CDPATH', 'C&OLUMNS', 'CO&MPREPLY', 'COM&P_CWORD', \ 'COMP_&LINE', 'COMP_POI&NT', 'COMP_WORD&BREAKS', 'COMP_&WORDS', \ '&DIRSTACK', '&EMAC&S', '&EUID', '&FCEDIT', \ 'F&IGNORE', 'F&UNCNAME', '&GLOBIGNORE', 'GRO&UPS', \ '&HISTCMD', 'HI&STCONTROL', 'HIS&TFILE', 'HIST&FILESIZE', \ 'HISTIG&NORE', 'HISTSI&ZE', 'HISTTI&MEFORMAT', 'H&OME', \ 'HOSTFIL&E', 'HOSTN&AME', 'HOSTT&YPE', '&IFS', \ 'IGNO&REEOF', 'INPUTR&C', '&LANG', '&LC_ALL', \ 'LC_&COLLATE', 'LC_C&TYPE', 'LC_M&ESSAGES', 'LC_&NUMERIC', \ 'L&INENO', 'LINE&S', '&MACHTYPE', 'M&AIL', \ 'MAILCHEC&K', 'MAIL&PATH', '&OLDPWD', 'OPTAR&G', \ 'OPTER&R', 'OPTIN&D', 'OST&YPE', '&PATH', \ 'P&IPESTATUS', 'P&OSIXLY_CORRECT', 'PPI&D', 'PROMPT_&COMMAND', \ 'PS&1', 'PS&2', 'PS&3', 'PS&4', \ 'P&WD', '&RANDOM', 'REPL&Y', '&SECONDS', \ 'S&HELL', 'SH&ELLOPTS', 'SH&LVL', '&TIMEFORMAT', \ 'T&MOUT', '&UID', \ ] let s:BashBuiltins = [ \ '&alias', '&bind', 'b&uiltin', '&caller', 'c&d', \ 'c&ommand', 'co&mpgen', 'com&plete', 'comp&opt', 'd&eclare', 'di&rs', \ 'diso&wn', 'ec&ho', 'e&nable', 'e&val', 'e&xec', 'ex&it', \ 'expor&t', '&false', \ '&getopts', '&hash', 'h&istory', '&jobs', \ '&kill', '&let', 'l&ocal', 'logout', '&mapfile', '&popd', \ 'print&f', 'p&ushd', 'p&wd', '&read', 'read&array', 'readonl&y', \ 'retur&n', \ '&shift', 's&hopt', 's&ource', 'susp&end', '&test', \ 't&imes', 't&rap', 't&ype', 'ty&peset', '&ulimit', 'u&mask', \ 'un&alias', 'u&nset', '&wait', \ ] let s:BashShopt = [ \ 'autocd', 'cdable_vars', 'cdspell', 'checkhash', \ 'checkjobs', 'checkwinsize', 'cmdhist', \ 'dirspell', 'dotglob', 'execfail', 'expand_aliases', \ 'extdebug', 'extglob', 'extquote', 'failglob', \ 'force_fignore', 'globstar', 'gnu_errfmt', 'histappend', 'histreedit', \ 'histverify', 'hostcomplete', 'huponexit', 'interactive_comments', \ 'lithist', 'login_shell', 'mailwarn', 'no_empty_cmd_completion', \ 'nocaseglob', 'nocasematch', 'nullglob', 'progcomp', \ 'promptvars', 'restricted_shell', 'shift_verbose', 'sourcepath', \ 'xpg_echo', \ ] "------------------------------------------------------------------------------ " BASH_EnvirMenus: generate the menu entries for environmnent variables {{{1 "------------------------------------------------------------------------------ function! BASH_EnvirMenus ( menupath, liblist ) for item in a:liblist let replacement = substitute( item, '[&\\]*', '','g' ) exe " noremenu ".a:menupath.'.'.item.' a${'.replacement.'}' exe "inoremenu ".a:menupath.'.'.item.' ${'.replacement.'}' endfor endfunction " ---------- end of function BASH_EnvirMenus ---------- "------------------------------------------------------------------------------ " BASH_BuiltinMenus: generate the menu entries for environmnent variables {{{1 "------------------------------------------------------------------------------ function! BASH_BuiltinMenus ( menupath, liblist ) for item in a:liblist let replacement = substitute( item, '[&\\]*', '','g' ) exe " noremenu ".a:menupath.'.'.item.' a'.replacement.' ' exe "inoremenu ".a:menupath.'.'.item.' '.replacement.' ' endfor endfunction " ---------- end of function BASH_BuiltinMenus ---------- "------------------------------------------------------------------------------ " BASH_ShoptMenus: generate the menu entries for environmnent variables {{{1 "------------------------------------------------------------------------------ function! BASH_ShoptMenus ( menupath, liblist ) for item in a:liblist let replacement = substitute( item, '[&\\]*', '','g' ) exe " noremenu ".a:menupath.'.'.item.' oshopt -s '.replacement exe "inoremenu ".a:menupath.'.'.item.' shopt -s '.replacement exe "vnoremenu ".a:menupath.'.'.item.' :call BASH_shopt("'.replacement.'")' endfor endfunction " ---------- end of function BASH_ShoptMenus ---------- " "------------------------------------------------------------------------------ " BASH_Input : Input after a highlighted prompt {{{1 "------------------------------------------------------------------------------ function! BASH_Input ( prompt, text, completion ) echohl Search " highlight prompt call inputsave() " preserve typeahead if a:completion == '' let retval=input( a:prompt, a:text ) else let retval=input( a:prompt, a:text, a:completion ) endif call inputrestore() " restore typeahead echohl None " reset highlighting return retval endfunction " ---------- end of function BASH_Input ---------- " "------------------------------------------------------------------------------ " BASH_AdjustLineEndComm: adjust line-end comments {{{1 "------------------------------------------------------------------------------ " " patterns to ignore when adjusting line-end comments (incomplete): let s:AlignRegex = [ \ '\${\?#' , \ '\${[^#]\+##\?.\+}' , \ '"[^"]*"' , \ "'[^']*'" , \ "`[^`]*`" , \ ] function! BASH_AdjustLineEndComm ( mode ) range " if !exists("b:BASH_LineEndCommentColumn") let b:BASH_LineEndCommentColumn = s:BASH_LineEndCommColDefault endif let save_cursor = getpos(".") let save_expandtab = &expandtab exe ":set expandtab" if a:mode == 'v' let pos0 = line("'<") let pos1 = line("'>") else let pos0 = line(".") let pos1 = pos0 end let linenumber = pos0 exe ":".pos0 while linenumber <= pos1 let line= getline(".") let idx1 = 1 + match( line, '\s*#.*$', 0 ) let idx2 = 1 + match( line, '#.*$', 0 ) " comment with leading whitespaces left unchanged if match( line, '^\s*#' ) == 0 let idx1 = 0 let idx2 = 0 endif for regex in s:AlignRegex if match( line, regex ) > -1 let start = matchend( line, regex ) let idx1 = 1 + match( line, '\s*#.*$', start ) let idx2 = 1 + match( line, '#.*$', start ) break endif endfor let ln = line(".") call setpos(".", [ 0, ln, idx1, 0 ] ) let vpos1 = virtcol(".") call setpos(".", [ 0, ln, idx2, 0 ] ) let vpos2 = virtcol(".") if ! ( vpos2 == b:BASH_LineEndCommentColumn \ || vpos1 > b:BASH_LineEndCommentColumn \ || idx2 == 0 ) exe ":.,.retab" " insert some spaces if vpos2 < b:BASH_LineEndCommentColumn let diff = b:BASH_LineEndCommentColumn-vpos2 call setpos(".", [ 0, ln, vpos2, 0 ] ) let @" = ' ' exe "normal ".diff."P" end " remove some spaces if vpos1 < b:BASH_LineEndCommentColumn && vpos2 > b:BASH_LineEndCommentColumn let diff = vpos2 - b:BASH_LineEndCommentColumn call setpos(".", [ 0, ln, b:BASH_LineEndCommentColumn, 0 ] ) exe "normal ".diff."x" end end let linenumber=linenumber+1 normal j endwhile " restore tab expansion settings and cursor position let &expandtab = save_expandtab call setpos('.', save_cursor) endfunction " ---------- end of function BASH_AdjustLineEndComm ---------- " "------------------------------------------------------------------------------ " Comments : get line-end comment position {{{1 "------------------------------------------------------------------------------ function! BASH_GetLineEndCommCol () let actcol = virtcol(".") if actcol+1 == virtcol("$") let b:BASH_LineEndCommentColumn = '' while match( b:BASH_LineEndCommentColumn, '^\s*\d\+\s*$' ) < 0 let b:BASH_LineEndCommentColumn = BASH_Input( 'start line-end comment at virtual column : ', actcol, '' ) endwhile else let b:BASH_LineEndCommentColumn = virtcol(".") endif echomsg "line end comments will start at column ".b:BASH_LineEndCommentColumn endfunction " ---------- end of function BASH_GetLineEndCommCol ---------- " "------------------------------------------------------------------------------ " Comments : single line-end comment {{{1 "------------------------------------------------------------------------------ function! BASH_LineEndComment () if !exists("b:BASH_LineEndCommentColumn") let b:BASH_LineEndCommentColumn = s:BASH_LineEndCommColDefault endif " ----- trim whitespaces ----- exe "s/\s\*$//" let linelength= virtcol("$") - 1 if linelength < b:BASH_LineEndCommentColumn let diff = b:BASH_LineEndCommentColumn -1 -linelength exe "normal ".diff."A " endif " append at least one blank if linelength >= b:BASH_LineEndCommentColumn exe "normal A " endif exe "normal A# " endfunction " ---------- end of function BASH_LineEndComment ---------- " "------------------------------------------------------------------------------ " Comments : multi line-end comments {{{1 "------------------------------------------------------------------------------ function! BASH_MultiLineEndComments () if !exists("b:BASH_LineEndCommentColumn") let b:BASH_LineEndCommentColumn = s:BASH_LineEndCommColDefault endif " let pos0 = line("'<") let pos1 = line("'>") " ----- trim whitespaces ----- exe "'<,'>s/\s\*$//" " ----- find the longest line ----- let maxlength = 0 let linenumber = pos0 normal '< while linenumber <= pos1 if getline(".") !~ "^\\s*$" && maxlength=0 " do we have a tag ? let frst=match(line,a:tag,start) let last=matchend(line,a:tag,start) if frst!=-1 let part1=strpart(line,0,frst) let part2=strpart(line,last) let line=part1.a:replacement.part2 " " next search starts after the replacement to suppress recursion " let start=strlen(part1)+strlen(a:replacement) endif endwhile call setline( linenumber, line ) let linenumber=linenumber+1 endwhile endfunction " ---------- end of function Bash_SubstituteTag ---------- " "------------------------------------------------------------------------------ " Comments : Insert Template Files {{{1 "------------------------------------------------------------------------------ function! BASH_CommentTemplates (arg) "---------------------------------------------------------------------- " BASH templates "---------------------------------------------------------------------- if a:arg=='frame' let templatefile=s:BASH_Template_Directory.s:BASH_Template_Frame endif if a:arg=='function' let templatefile=s:BASH_Template_Directory.s:BASH_Template_Function endif if a:arg=='header' let templatefile=s:BASH_Template_Directory.s:BASH_Template_File endif if filereadable(templatefile) let length= line("$") let pos1 = line(".")+1 let l:old_cpoptions = &cpoptions " Prevent the alternate buffer from being set to this files setlocal cpoptions-=a if a:arg=='header' :goto 1 let pos1 = 1 exe '0read '.templatefile else exe 'read '.templatefile endif let &cpoptions = l:old_cpoptions " restore previous options let length= line("$")-length let pos2 = pos1+length-1 "---------------------------------------------------------------------- " frame blocks will be indented "---------------------------------------------------------------------- if a:arg=='frame' let length = length-1 silent exe "normal =".length."+" let length = length+1 endif "---------------------------------------------------------------------- " substitute keywords "---------------------------------------------------------------------- " call BASH_SubstituteTag( pos1, pos2, '|FILENAME|', expand("%:t") ) call BASH_SubstituteTag( pos1, pos2, '|DATE|', BASH_InsertDateAndTime('d') ) call BASH_SubstituteTag( pos1, pos2, '|DATETIME|', BASH_InsertDateAndTime('dt')) call BASH_SubstituteTag( pos1, pos2, '|TIME|', BASH_InsertDateAndTime('t') ) call BASH_SubstituteTag( pos1, pos2, '|YEAR|', BASH_InsertDateAndTime('y') ) call BASH_SubstituteTag( pos1, pos2, '|AUTHOR|', s:BASH_AuthorName ) call BASH_SubstituteTag( pos1, pos2, '|EMAIL|', s:BASH_Email ) call BASH_SubstituteTag( pos1, pos2, '|AUTHORREF|', s:BASH_AuthorRef ) call BASH_SubstituteTag( pos1, pos2, '|PROJECT|', s:BASH_Project ) call BASH_SubstituteTag( pos1, pos2, '|COMPANY|', s:BASH_Company ) call BASH_SubstituteTag( pos1, pos2, '|COPYRIGHTHOLDER|', s:BASH_CopyrightHolder) " " now the cursor " exe ':'.pos1 normal 0 let linenumber=search('|CURSOR|') if linenumber >=pos1 && linenumber<=pos2 let pos1=match( getline(linenumber) ,"|CURSOR|") if matchend( getline(linenumber) ,"|CURSOR|") == match( getline(linenumber) ,"$" ) silent! s/|CURSOR|// " this is an append like A :startinsert! else silent s/|CURSOR|// call cursor(linenumber,pos1+1) " this is an insert like i :startinsert endif endif else echohl WarningMsg | echo 'template file '.templatefile.' does not exist or is not readable'| echohl None endif return endfunction " ---------- end of function BASH_CommentTemplates ---------- " "------------------------------------------------------------------------------ " Comments : classified comments {{{1 "------------------------------------------------------------------------------ function! BASH_CommentClassified (class) put = '# :'.a:class.':'.BASH_InsertDateAndTime('d').':'.s:BASH_AuthorRef.': ' endfunction " "------------------------------------------------------------------------------ " Comments : vim modeline {{{1 "------------------------------------------------------------------------------ function! BASH_CommentVimModeline () put = '# vim: set tabstop='.&tabstop.' shiftwidth='.&shiftwidth.': ' endfunction " ---------- end of function BASH_CommentVimModeline ---------- " "------------------------------------------------------------------------------- " Statements : flow control {{{1 "------------------------------------------------------------------------------- function! BASH_FlowControl ( part1, part2, part3, mode ) if s:BASH_DoOnNewLine=='yes' let splt = "\n" else let splt = "; " end let startposition = line(".")+1 "------------------------------------------------------------------------------- " normal mode, insert mode "------------------------------------------------------------------------------- if a:mode=='a' let zz = a:part1.splt.a:part2."\n".a:part3 put =zz let lines = line(".")-startposition+1 exe ":".startposition end "------------------------------------------------------------------------------- " visual mode "------------------------------------------------------------------------------- if a:mode=='v' let lines = line("'>")-line("'<")+1 let zz = a:part1.splt.a:part2 normal '< put! =zz let zz = a:part3 normal '> put =zz if a:part3 =~ 'else' let lines = lines+1 end if s:BASH_DoOnNewLine=='yes' let lines = lines+3 :'<-2 else let lines = lines+2 :'<-1 end end exe "normal ".lines."==" normal f_x endfunction " ---------- end of function BASH_FlowControl ---------- " "------------------------------------------------------------------------------ " Statements : function {{{1 "------------------------------------------------------------------------------ function! BASH_CodeFunction ( mode ) let identifier=BASH_Input('function name : ', '', '' ) if identifier != '' " if a:mode == "a" let zz= "function ".identifier." ()\n{\n}" let zz= zz." # ---------- end of function ".identifier." ----------" put =zz endif " if a:mode == "v" let zz= "function ".identifier." ()\n{\n" normal '< put! =zz let zz= "} # ---------- end of function ".identifier." ----------" normal '> put =zz normal gv= endif " endif endfunction " ---------- end of function BASH_CodeFunction ---------- " "------------------------------------------------------------------------------ " BASH_help : builtin completion {{{1 "------------------------------------------------------------------------------ function! BASH_BuiltinComplete ( ArgLead, CmdLine, CursorPos ) " " show all builtins " if a:ArgLead == '' return s:BASH_Builtins endif " " show builtins beginning with a:ArgLead " let expansions = [] for item in s:BASH_Builtins if match( item, '\<'.a:ArgLead.'\w*' ) == 0 call add( expansions, item ) endif endfor return expansions endfun " "------------------------------------------------------------------------------ " BASH_help : lookup word under the cursor or ask {{{1 "------------------------------------------------------------------------------ let s:BASH_DocBufferName = "BASH_HELP" let s:BASH_DocHelpBufferNumber = -1 " function! BASH_help( type ) let cuc = getline(".")[col(".") - 1] " character under the cursor let item = expand("") " word under the cursor if item == "" || match( item, cuc ) == -1 if a:type == 'm' let item=BASH_Input('[tab compl. on] name of command line utility : ', '', 'shellcmd' ) else let item=BASH_Input('[tab compl. on] name of bash builtin : ', '', 'customlist,BASH_BuiltinComplete' ) endif endif if item == "" return endif "------------------------------------------------------------------------------ " replace buffer content with bash help text "------------------------------------------------------------------------------ " " jump to an already open bash help window or create one " if bufloaded(s:BASH_DocBufferName) != 0 && bufwinnr(s:BASH_DocHelpBufferNumber) != -1 exe bufwinnr(s:BASH_DocHelpBufferNumber) . "wincmd w" " buffer number may have changed, e.g. after a 'save as' if bufnr("%") != s:BASH_DocHelpBufferNumber let s:BASH_DocHelpBufferNumber=bufnr(s:BASH_OutputBufferName) exe ":bn ".s:BASH_DocHelpBufferNumber endif else exe ":new ".s:BASH_DocBufferName let s:BASH_DocHelpBufferNumber=bufnr("%") setlocal buftype=nofile setlocal noswapfile setlocal bufhidden=delete setlocal filetype=sh " allows repeated use of setlocal syntax=OFF endif setlocal modifiable " " BASH BUILTINS " if a:type == 'h' silent exe ":%!help ".item endif " " UTILITIES " if a:type == 'm' " " Is there more than one manual ? " let manpages = system( s:BASH_Man.' -k '.item ) if v:shell_error echomsg "Shell command '".s:BASH_Man." -k ".item."' failed." :close return endif let catalogs = split( manpages, '\n', ) let manual = {} " " Select manuals where the name exactly matches " for line in catalogs if line =~ '^'.item.'\s\+(' let itempart = split( line, '\s\+' ) let catalog = itempart[1][1:-2] let manual[catalog] = catalog endif endfor " " Build a selection list if there are more than one manual " let catalog = "" if len(keys(manual)) > 1 for key in keys(manual) echo ' '.item.' '.key endfor let defaultcatalog = '' if has_key( manual, '1' ) let defaultcatalog = '1' else if has_key( manual, '8' ) let defaultcatalog = '8' endif endif let catalog = input( 'select manual section ( cancels) : ', defaultcatalog ) if ! has_key( manual, catalog ) :close :redraw echomsg "no appropriate manual section '".catalog."'" return endif endif set filetype=man silent exe ":%!".s:BASH_Man.' '.catalog.' '.item endif setlocal nomodifiable endfunction " ---------- end of function BASH_help ---------- " "------------------------------------------------------------------------------ " Run : Syntax Check, check if local options does exist {{{1 "------------------------------------------------------------------------------ " function! BASH_SyntaxCheckOptions( options ) let startpos=0 while startpos < strlen( a:options ) " match option switch ' -O ' or ' +O ' let startpos = matchend ( a:options, '\s*[+-]O\s\+', startpos ) " match option name let optionname = matchstr ( a:options, '\h\w*\s*', startpos ) " remove trailing whitespaces let optionname = substitute( optionname, '\s\+$', "", "" ) " check name let found = match ( s:BASH_ShoptAllowed, optionname.':' ) if found < 0 redraw echohl WarningMsg | echo ' no such shopt name : "'.optionname.'" ' | echohl None return 1 endif " increment start position for next search let startpos = matchend ( a:options, '\h\w*\s*', startpos ) endwhile return 0 endfunction " ---------- end of function BASH_SyntaxCheckOptions---------- " "------------------------------------------------------------------------------ " Run : Syntax Check, local options {{{1 "------------------------------------------------------------------------------ " function! BASH_SyntaxCheckOptionsLocal () let filename = expand("%") if filename == "" redraw echohl WarningMsg | echo " no file name or not a shell file " | echohl None return endif let prompt = 'syntax check options for "'.filename.'" : ' if exists("b:BASH_SyntaxCheckOptionsLocal") let b:BASH_SyntaxCheckOptionsLocal= BASH_Input( prompt, b:BASH_SyntaxCheckOptionsLocal, '' ) else let b:BASH_SyntaxCheckOptionsLocal= BASH_Input( prompt , "", '' ) endif if BASH_SyntaxCheckOptions( b:BASH_SyntaxCheckOptionsLocal ) != 0 let b:BASH_SyntaxCheckOptionsLocal = "" endif endfunction " ---------- end of function BASH_SyntaxCheckOptionsLocal ---------- " "------------------------------------------------------------------------------ " Run : syntax check {{{1 "------------------------------------------------------------------------------ function! BASH_SyntaxCheck () exe ":cclose" let l:currentbuffer=bufname("%") exe ":update" let makeprg_saved = &makeprg exe ":setlocal makeprg=".s:BASH_BASH " " check global syntax check options / reset in case of an error if BASH_SyntaxCheckOptions( s:BASH_SyntaxCheckOptionsGlob ) != 0 let s:BASH_SyntaxCheckOptionsGlob = "" endif " let options=s:BASH_SyntaxCheckOptionsGlob if exists("b:BASH_SyntaxCheckOptionsLocal") let options=options." ".b:BASH_SyntaxCheckOptionsLocal endif " " match the Bash error messages (quickfix commands) " errorformat will be reset by function BASH_Handle() " ignore any lines that didn't match one of the patterns " exe ':setlocal errorformat='.s:BASH_Errorformat exe ":make -n ".options." -- ./% " exe ":botright cwindow" exe ':setlocal errorformat=' exe ":setlocal makeprg=".makeprg_saved " " message in case of success " if l:currentbuffer == bufname("%") redraw echohl Search | echo l:currentbuffer." : Syntax is OK" | echohl None nohlsearch " delete unwanted highlighting (Vim bug?) endif endfunction " ---------- end of function BASH_SyntaxCheck ---------- " "------------------------------------------------------------------------------ " Run : debugger {{{1 "------------------------------------------------------------------------------ function! BASH_Debugger () if !executable("bashdb") echohl Search echo ' bashdb is not executable or not installed! ' echohl None return endif " silent exe ":update" let l:arguments = exists("b:BASH_CmdLineArgs") ? " ".b:BASH_CmdLineArgs : "" let Sou = escape( expand("%"), s:escfilename ) " " if has("gui_running") || &term == "xterm" " " debugger is ' bash --debugger ...' " if s:BASH_Debugger == "term" " let command = "!xterm ".s:BASH_XtermDefaults.' -e '.s:BASH_BASH.' --debugger ./'.Sou.l:arguments.' &' let command = "!xterm ".s:BASH_XtermDefaults.' -e bashdb ./'.Sou.l:arguments.' &' silent exe command endif " " debugger is 'ddd' " if s:BASH_Debugger == "ddd" if !executable("ddd") echohl WarningMsg echo "The debugger 'ddd' does not exist or is not executable!" echohl None return else silent exe '!ddd ./'.Sou.l:arguments.' &' endif endif else silent exe '!'.s:BASH_BASH.' --debugger ./'.Sou.l:arguments endif endfunction " ---------- end of function BASH_Debugger ---------- " "---------------------------------------------------------------------- " Run : toggle output destination (Linux/Unix) {{{1 "---------------------------------------------------------------------- function! BASH_Toggle_Gvim_Xterm () if has("gui_running") if s:BASH_OutputGvim == "vim" exe "aunmenu ".s:BASH_Root.'&Run.&output:\ VIM->buffer->xterm' exe " menu ".s:BASH_Root.'&Run.&output:\ BUFFER->xterm->vim :call BASH_Toggle_Gvim_Xterm()' exe "imenu ".s:BASH_Root.'&Run.&output:\ BUFFER->xterm->vim :call BASH_Toggle_Gvim_Xterm()' let s:BASH_OutputGvim = "buffer" else if s:BASH_OutputGvim == "buffer" exe "aunmenu ".s:BASH_Root.'&Run.&output:\ BUFFER->xterm->vim' exe " menu ".s:BASH_Root.'&Run.&output:\ XTERM->vim->buffer :call BASH_Toggle_Gvim_Xterm()' exe "imenu ".s:BASH_Root.'&Run.&output:\ XTERM->vim->buffer :call BASH_Toggle_Gvim_Xterm()' let s:BASH_OutputGvim = "xterm" else " ---------- output : xterm -> gvim exe "aunmenu ".s:BASH_Root.'&Run.&output:\ XTERM->vim->buffer' exe " menu ".s:BASH_Root.'&Run.&output:\ VIM->buffer->xterm :call BASH_Toggle_Gvim_Xterm()' exe "imenu ".s:BASH_Root.'&Run.&output:\ VIM->buffer->xterm :call BASH_Toggle_Gvim_Xterm()' let s:BASH_OutputGvim = "vim" endif endif else if s:BASH_OutputGvim == "vim" let s:BASH_OutputGvim = "buffer" else let s:BASH_OutputGvim = "vim" endif endif endfunction " ---------- end of function BASH_Toggle_Gvim_Xterm ---------- " "---------------------------------------------------------------------- " Run : toggle output destination (Windows) {{{1 "---------------------------------------------------------------------- function! BASH_Toggle_Gvim_Xterm_MS () if has("gui_running") if s:BASH_OutputGvim == "buffer" exe "aunmenu ".s:BASH_Root.'&Run.&output:\ BUFFER->term' exe " menu ".s:BASH_Root.'&Run.&output:\ TERM->buffer :call BASH_Toggle_Gvim_Xterm_MS()' exe "imenu ".s:BASH_Root.'&Run.&output:\ TERM->buffer :call BASH_Toggle_Gvim_Xterm_MS()' let s:BASH_OutputGvim = "xterm" else exe "aunmenu ".s:BASH_Root.'&Run.&output:\ TERM->buffer' exe " menu ".s:BASH_Root.'&Run.&output:\ BUFFER->term :call BASH_Toggle_Gvim_Xterm_MS()' exe "imenu ".s:BASH_Root.'&Run.&output:\ BUFFER->term :call BASH_Toggle_Gvim_Xterm_MS()' let s:BASH_OutputGvim = "buffer" endif endif endfunction " ---------- end of function BASH_Toggle_Gvim_Xterm_MS ---------- " "------------------------------------------------------------------------------ " Run : make script executable {{{1 "------------------------------------------------------------------------------ function! BASH_MakeScriptExecutable () let filename = escape( expand("%"), s:escfilename ) silent exe "!chmod u+x ".filename redraw if v:shell_error echohl WarningMsg echo 'Could not make "'.filename.'" executable !' else echohl Search echo 'Made "'.filename.'" executable.' endif echohl None endfunction " ---------- end of function BASH_MakeScriptExecutable ---------- " "------------------------------------------------------------------------------ " Run : run {{{1 "------------------------------------------------------------------------------ " let s:BASH_OutputBufferName = "Bash-Output" let s:BASH_OutputBufferNumber = -1 " function! BASH_Run ( mode ) silent exe ':cclose' " let l:currentdir = getcwd() let l:arguments = exists("b:BASH_CmdLineArgs") ? " ".b:BASH_CmdLineArgs : "" let l:currentbuffer = bufname("%") let l:fullname = l:currentdir."/".l:currentbuffer let l:fullname = escape( l:fullname, s:escfilename ) " silent exe ":update" " if a:mode=="v" let tmpfile = tempname() silent exe ":'<,'>write ".tmpfile endif " "------------------------------------------------------------------------------ " Run : run from the vim command line "------------------------------------------------------------------------------ " if s:BASH_OutputGvim == "vim" " " ----- visual mode ---------- " if a:mode=="v" exe ":!$".s:BASH_BASH." < ".tmpfile." -s ".l:arguments call delete(tmpfile) return endif " " ----- normal mode ---------- " let makeprg_saved = &makeprg exe ":setlocal makeprg=".s:BASH_BASH exe ':setlocal errorformat='.s:BASH_Errorformat " if a:mode=="n" exe ":make "l:fullname.l:arguments echomsg ":make "l:fullname.l:arguments endif " exe ":setlocal makeprg=".makeprg_saved exe ':setlocal errorformat=' exe ":botright cwindow" if l:currentbuffer != bufname("%") && a:mode=="n" let tmpfile_error = tempname() let pattern = '^||.*\n\?' setlocal modifiable " remove the regular script output (appears as comment) if search(pattern) != 0 silent exe ':%s/'.pattern.'//' endif " read the buffer back to have it parsed and used as the new error list silent exe ':write! '.tmpfile_error silent exe ':cgetfile '.tmpfile_error setlocal nomodifiable silent exe ':cc' call delete(tmpfile_error) endif " endif " "------------------------------------------------------------------------------ " Run : redirect output to an output buffer "------------------------------------------------------------------------------ if s:BASH_OutputGvim == "buffer" let l:currentbuffernr = bufnr("%") let l:currentdir = getcwd() if l:currentbuffer == bufname("%") " if bufloaded(s:BASH_OutputBufferName) != 0 && bufwinnr(s:BASH_OutputBufferNumber)!=-1 exe bufwinnr(s:BASH_OutputBufferNumber) . "wincmd w" " buffer number may have changed, e.g. after a 'save as' if bufnr("%") != s:BASH_OutputBufferNumber let s:BASH_OutputBufferNumber = bufnr(s:BASH_OutputBufferName) exe ":bn ".s:BASH_OutputBufferNumber endif else silent exe ":new ".s:BASH_OutputBufferName let s:BASH_OutputBufferNumber=bufnr("%") setlocal noswapfile setlocal buftype=nofile setlocal syntax=none setlocal bufhidden=delete setlocal tabstop=8 endif " " run script " setlocal modifiable if a:mode=="n" silent exe ":%!".s:BASH_BASH." ".l:fullname.l:arguments endif " if a:mode=="v" silent exe ":%!".s:BASH_BASH." < ".tmpfile." -s ".l:arguments endif setlocal nomodifiable " " stdout is empty / not empty " if line("$")==1 && col("$")==1 silent exe ":bdelete" else if winheight(winnr()) >= line("$") exe bufwinnr(l:currentbuffernr) . "wincmd w" endif endif " endif endif " "------------------------------------------------------------------------------ " Run : run in a detached xterm "------------------------------------------------------------------------------ if s:BASH_OutputGvim == "xterm" " if s:MSWIN exe ":!".s:BASH_BASH." ".l:fullname.l:arguments else if a:mode=="n" silent exe "!xterm -title ".l:fullname." ".s:BASH_XtermDefaults \ .' -e '.s:BASH_Wrapper.' '.l:fullname.l:arguments endif " if a:mode=="v" let titlestring = l:fullname.'\ lines\ \ '.line("'<").'\ -\ '.line("'>") silent exe ":!xterm -title ".titlestring." ".s:BASH_XtermDefaults \ ." -e ".s:BASH_Wrapper.' '.tmpfile.l:arguments endif endif " endif " if a:mode=="v" call delete(tmpfile) endif " endfunction " ---------- end of function BASH_Run ---------- " "------------------------------------------------------------------------------ " Run : xterm geometry {{{1 "------------------------------------------------------------------------------ function! BASH_XtermSize () let regex = '-geometry\s\+\d\+x\d\+' let geom = matchstr( s:BASH_XtermDefaults, regex ) let geom = matchstr( geom, '\d\+x\d\+' ) let geom = substitute( geom, 'x', ' ', "" ) let answer= BASH_Input(" xterm size (COLUMNS LINES) : ", geom, '' ) while match(answer, '^\s*\d\+\s\+\d\+\s*$' ) < 0 let answer= BASH_Input(" + xterm size (COLUMNS LINES) : ", geom, '' ) endwhile let answer = substitute( answer, '^\s\+', "", "" ) " remove leading whitespaces let answer = substitute( answer, '\s\+$', "", "" ) " remove trailing whitespaces let answer = substitute( answer, '\s\+', "x", "" ) " replace inner whitespaces let s:BASH_XtermDefaults = substitute( s:BASH_XtermDefaults, regex, "-geometry ".answer , "" ) endfunction " ---------- end of function BASH_XtermDefaults ---------- " " "------------------------------------------------------------------------------ " set : option {{{1 "------------------------------------------------------------------------------ function! BASH_set (arg) let s:BASH_SetCounter = 0 let save_line = line(".") let actual_line = 0 " " search for the maximum option number (if any) normal gg while actual_line < search( s:BASH_Set_Txt."\\d\\+" ) let actual_line = line(".") let actual_opt = matchstr( getline(actual_line), s:BASH_Set_Txt."\\d\\+" ) let actual_opt = strpart( actual_opt, strlen(s:BASH_Set_Txt),strlen(actual_opt)-strlen(s:BASH_Set_Txt)) if s:BASH_SetCounter < actual_opt let s:BASH_SetCounter = actual_opt endif endwhile let s:BASH_SetCounter = s:BASH_SetCounter+1 silent exe ":".save_line " " insert option let zz= "set -o ".a:arg." # ".s:BASH_Set_Txt.s:BASH_SetCounter normal '< put! =zz let zz= "set +o ".a:arg." # ".s:BASH_Set_Txt.s:BASH_SetCounter normal '> put =zz let s:BASH_SetCounter = s:BASH_SetCounter+1 endfunction " ---------- end of function BASH_set ---------- " "------------------------------------------------------------------------------ " shopt : option {{{1 "------------------------------------------------------------------------------ function! BASH_shopt (arg) let s:BASH_SetCounter = 0 let save_line = line(".") let actual_line = 0 " " search for the maximum option number (if any) normal gg while actual_line < search( s:BASH_Shopt_Txt."\\d\\+" ) let actual_line = line(".") let actual_opt = matchstr( getline(actual_line), s:BASH_Shopt_Txt."\\d\\+" ) let actual_opt = strpart( actual_opt, strlen(s:BASH_Shopt_Txt),strlen(actual_opt)-strlen(s:BASH_Shopt_Txt)) if s:BASH_SetCounter < actual_opt let s:BASH_SetCounter = actual_opt endif endwhile let s:BASH_SetCounter = s:BASH_SetCounter+1 silent exe ":".save_line " " insert option let zz= "shopt -s ".a:arg." # ".s:BASH_Shopt_Txt.s:BASH_SetCounter."\n" normal '< put! =zz let zz= "shopt -u ".a:arg." # ".s:BASH_Shopt_Txt.s:BASH_SetCounter normal '> put =zz let s:BASH_SetCounter = s:BASH_SetCounter+1 endfunction " ---------- end of function BASH_shopt ---------- " "------------------------------------------------------------------------------ " Run : Command line arguments {{{1 "------------------------------------------------------------------------------ function! BASH_CmdLineArguments () let filename = expand("%") if filename == "" redraw echohl WarningMsg | echo " no file name " | echohl None return endif let prompt = 'command line arguments for "'.filename.'" : ' if exists("b:BASH_CmdLineArgs") let b:BASH_CmdLineArgs= BASH_Input( prompt, b:BASH_CmdLineArgs , 'file' ) else let b:BASH_CmdLineArgs= BASH_Input( prompt , "", 'file' ) endif endfunction " ---------- end of function BASH_CmdLineArguments ---------- " "------------------------------------------------------------------------------ " Bash-Idioms : read / edit code snippet {{{1 "------------------------------------------------------------------------------ function! BASH_CodeSnippets(arg1) if isdirectory(s:BASH_CodeSnippets) " " read snippet file, put content below current line " if a:arg1 == "r" if has("gui_running") let l:snippetfile=browse(0,"read a code snippet",s:BASH_CodeSnippets,"") else let l:snippetfile=input("read snippet ", s:BASH_CodeSnippets, "file" ) end if filereadable(l:snippetfile) let linesread= line("$") " " Prevent the alternate buffer from being set to this files let l:old_cpoptions = &cpoptions setlocal cpoptions-=a :execute "read ".l:snippetfile let &cpoptions = l:old_cpoptions " restore previous options " let linesread= line("$")-linesread-1 if linesread>=0 && match( l:snippetfile, '\.\(ni\|noindent\)$' ) < 0 silent exe "normal =".linesread."+" endif endif endif " " update current buffer / split window / edit snippet file " if a:arg1 == "e" if has("gui_running") let l:snippetfile=browse(0,"edit a code snippet",s:BASH_CodeSnippets,"") else let l:snippetfile=input("edit snippet ", s:BASH_CodeSnippets, "file" ) end if l:snippetfile != "" :execute "update! | split | edit ".l:snippetfile endif endif " " write whole buffer or marked area into snippet file " if a:arg1 == "w" || a:arg1 == "wv" if has("gui_running") let l:snippetfile=browse(0,"write a code snippet",s:BASH_CodeSnippets,"") else let l:snippetfile=input("write snippet ", s:BASH_CodeSnippets, "file" ) end if l:snippetfile != "" if filereadable(l:snippetfile) if confirm("File exists ! Overwrite ? ", "&Cancel\n&No\n&Yes") != 3 return endif endif if a:arg1 == "w" :execute ":write! ".l:snippetfile else :execute ":*write! ".l:snippetfile end endif endif else echo "code snippet directory ".s:BASH_CodeSnippets." does not exist (please create it)" endif endfunction " ---------- end of function BASH_CodeSnippets ---------- " "------------------------------------------------------------------------------ " Run : hardcopy {{{1 "------------------------------------------------------------------------------ function! BASH_Hardcopy (arg1) let Sou = expand("%") " name of the file in the current buffer if Sou == "" redraw echohl WarningMsg | echo " no file name " | echohl None return endif let old_printheader=&printheader exe ':set printheader='.s:BASH_Printheader " ----- normal mode ---------------- if a:arg1=="n" silent exe "hardcopy > ".Sou.".ps" if !s:MSWIN echo "file \"".Sou."\" printed to \"".Sou.".ps\"" endif endif " ----- visual mode ---------------- if a:arg1=="v" silent exe "*hardcopy > ".Sou.".ps" if !s:MSWIN echo "file \"".Sou."\" (lines ".line("'<")."-".line("'>").") printed to \"".Sou.".ps\"" endif endif exe ':set printheader='.escape( old_printheader, ' %' ) endfunction " ---------- end of function BASH_Hardcopy ---------- " "------------------------------------------------------------------------------ " Run : settings {{{1 "------------------------------------------------------------------------------ function! BASH_Settings () let txt = " Bash-Support settings\n\n" let txt = txt." author name : \"".s:BASH_AuthorName."\"\n" let txt = txt." initials : \"".s:BASH_AuthorRef."\"\n" let txt = txt." autho email : \"".s:BASH_Email."\"\n" let txt = txt." company : \"".s:BASH_Company."\"\n" let txt = txt." project : \"".s:BASH_Project."\"\n" let txt = txt." copyright holder : \"".s:BASH_CopyrightHolder."\"\n" let txt = txt." code snippet directory : ".s:BASH_CodeSnippets."\n" let txt = txt." template directory : ".s:BASH_Template_Directory."\n" let txt = txt."glob. syntax check options : ".s:BASH_SyntaxCheckOptionsGlob."\n" if exists("b:BASH_SyntaxCheckOptionsLocal") let txt = txt." buf. syntax check options : ".b:BASH_SyntaxCheckOptionsLocal."\n" endif if g:BASH_Dictionary_File != "" let ausgabe= substitute( g:BASH_Dictionary_File, ",", ",\n + ", "g" ) let txt = txt." dictionary file(s) : ".ausgabe."\n" endif let txt = txt." current output dest. : ".s:BASH_OutputGvim."\n" if !s:MSWIN let txt = txt.' xterm defaults : '.s:BASH_XtermDefaults."\n" endif let txt = txt."\n" let txt = txt." Additional hot keys\n\n" let txt = txt." Shift-F1 : help for builtin under the cursor \n" let txt = txt." Ctrl-F9 : update file, run script \n" let txt = txt." Alt-F9 : update file, run syntax check \n" let txt = txt." Shift-F9 : edit command line arguments \n" let txt = txt." F9 : debug script \n" let txt = txt."___________________________________________________________________________\n" let txt = txt." Bash-Support, Version ".g:BASH_Version." / Dr.-Ing. Fritz Mehner / mehner@fh-swf.de\n\n" echo txt endfunction " ---------- end of function BASH_Settings ---------- " "------------------------------------------------------------------------------ " Run : help bashsupport {{{1 "------------------------------------------------------------------------------ function! BASH_HelpBASHsupport () try :help bashsupport catch exe ':helptags '.s:plugin_dir.'doc' :help bashsupport endtry endfunction " ---------- end of function BASH_HelpBASHsupport ---------- "------------------------------------------------------------------------------ " date and time {{{1 "------------------------------------------------------------------------------ function! BASH_InsertDateAndTime ( format ) if a:format == 'd' return strftime( s:BASH_FormatDate ) end if a:format == 't' return strftime( s:BASH_FormatTime ) end if a:format == 'dt' return strftime( s:BASH_FormatDate ).' '.strftime( s:BASH_FormatTime ) end if a:format == 'y' return strftime( s:BASH_FormatYear ) end endfunction " ---------- end of function BASH_InsertDateAndTime ---------- " "------------------------------------------------------------------------------ " BASH_CreateGuiMenus {{{1 "------------------------------------------------------------------------------ let s:BASH_MenuVisible = 0 " state : 0 = not visible / 1 = visible " function! BASH_CreateGuiMenus () if s:BASH_MenuVisible != 1 aunmenu &Tools.Load\ Bash\ Support amenu 40.1000 &Tools.-SEP100- : amenu 40.1021 &Tools.Unload\ Bash\ Support :call BASH_RemoveGuiMenus() call BASH_InitMenu() let s:BASH_MenuVisible = 1 endif endfunction " ---------- end of function BASH_CreateGuiMenus ---------- "------------------------------------------------------------------------------ " BASH_ToolMenu {{{1 "------------------------------------------------------------------------------ function! BASH_ToolMenu () amenu 40.1000 &Tools.-SEP100- : amenu 40.1021 &Tools.Load\ Bash\ Support :call BASH_CreateGuiMenus() endfunction " ---------- end of function BASH_ToolMenu ---------- "------------------------------------------------------------------------------ " BASH_RemoveGuiMenus {{{1 "------------------------------------------------------------------------------ function! BASH_RemoveGuiMenus () if s:BASH_MenuVisible == 1 if s:BASH_Root == "" aunmenu Comments aunmenu Statements aunmenu Tests aunmenu ParamSub aunmenu SpecVars aunmenu Environ aunmenu Builtins aunmenu set aunmenu shopt aunmenu I/O-Redir aunmenu Run aunmenu Help else exe "aunmenu ".s:BASH_Root endif " aunmenu &Tools.Unload\ Bash\ Support call BASH_ToolMenu() " let s:BASH_MenuVisible = 0 endif endfunction " ---------- end of function BASH_RemoveGuiMenus ---------- " "------------------------------------------------------------------------------ " show / hide the menus {{{1 " define key mappings (gVim only) "------------------------------------------------------------------------------ " if has("gui_running") " call BASH_ToolMenu() " if s:BASH_LoadMenus == 'yes' call BASH_CreateGuiMenus() endif " nmap lbs :call BASH_CreateGuiMenus() nmap ubs :call BASH_RemoveGuiMenus() " endif " "------------------------------------------------------------------------------ " Automated header insertion {{{1 "------------------------------------------------------------------------------ " if has("autocmd") " " Bash-script : insert header, write file, make it executable " autocmd BufNewFile *.sh call BASH_CommentTemplates('header') | :w! " endif " has("autocmd") " "------------------------------------------------------------------------------ " Avoid a wrong syntax highlighting for $(..) and $((..)) "------------------------------------------------------------------------------ " let is_bash = 1 " "------------------------------------------------------------------------------ " vim: tabstop=2 shiftwidth=2 foldmethod=marker