3 # Copyright (C) 2013-2014 CEA/DEN, EDF R&D, OPEN CASCADE
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License, or (at your option) any later version.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 # Bash completion support for salome command.
24 # How to use this file?
25 # 1. If you have a root access, copy the file to /etc/bash_completion.d/
26 # 2. If you do not have root access or want to make a user-speficic installation:
27 # 2.1. Copy this file to somewhere (e.g. ~/.salome-completion.sh).
28 # 2.2. Add the following line to your .bashrc:
29 # source ~/.salome-completion.sh
32 _salome_long_options()
35 --show-desktop|--splash|--catch-exceptions|--shutdown-servers|--foreground)
42 COMPREPLY=( $( compgen -W "$options" -- "$2" ) )
45 # Function used to compute the completion
48 # COMP_WORDS is an array that contains all command line elements (the script and its arguments)
49 # COMP_CWORD is the index of current element in command line
50 # COMPREPLY is an array of strings that are the proposals as returned by auto-completion
51 local cur prev command options
53 _get_comp_words_by_ref -n = cur prev
54 commands='start shell connect killall info help coffee'
57 # If cursor is at index 1
58 # Complete with commands
60 # Find current command
61 # If word under cursor starts with '-'
62 # Complete options regarding current command
64 if [[ $COMP_CWORD -eq 1 ]] ; then
65 COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) )
66 elif [[ "$cur" == --*=* ]]; then
68 _salome_long_options "$prev" "$cur"
69 elif [[ "$cur" == -* ]]; then
70 command=${COMP_WORDS[1]}
71 if [[ "$cur" == -* ]]; then
74 options='-t --terminal -g --gui -d --show-desktop= -o --hide-desktop -b --batch -l --logger -f --log-file= -r --resources= -x --xterm -m --modules= -e --embedded= -s --standalone= -p --portkill -k --killall -i --interp= -z --splash= -c --catch-exceptions= --print-port --nosave-config --pinter --ns-port-log= --test= --play= --gdb-session --ddd-session --valgrind-session --shutdown-servers= --foreground= --wake-up-session --server-launch-mode= --port= --siman --siman-study= --siman-scenario= --siman-user= --version -h --help'
77 options='-h --help -p --port= -m --machine='
80 COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
86 # The-F option gives the name of the function that calculates the completion; moreover it tells the complete command that it must seek the results in the COMPREPLY variable.
87 complete -o bashdefault -o default -o nospace -F _salome salome 2>/dev/null \
88 || complete -o default -o nospace -F _salome salome
90 # The following are necessary only for Cygwin, and only are needed
91 # when the user has tab-completed the executable name and consequently
92 # included the '.exe' suffix.
94 if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
95 complete -o bashdefault -o default -o nospace -F _salome salome.exe 2>/dev/null \
96 || complete -o default -o nospace -F _salome salome.exe