Go To Declaration

BashSupport Pro helps you to quickly navigate in shell scripts.

Place the text cursor on an element in a shell script and choose NavigateGoTo to navigate to the declaration (JetBrains help pages).

BashSupport Pro lets you navigate to the declarations of these elements:

Function Calls
It navigates to the definition of the function.
Variable References
It navigates to the definition of the variable. For example, it navigates to export myVar if you invoke it for $myVar.
Variable Declarations
It navigates to the closest, earlier declaration of a variable declaration.
For example, for myVar=1; myVar=2; export myVar, it will navigate to myVar=2 if you call it for the exported definition. When you invoke the action again, then it will navigate to myVar=1.
See below for a setting to configure this behaviour.

Settings

By default, Go To Declaration navigates to the closest re-declaration of a variable. This should be the most useful implementation to navigate within complex shell scripts. If you don’t like this, then the setting Prefer the closest definition for Go To Declaration lets you change the behaviour. To do this, disable the checkbox in the settings at SettingsLanguages & FrameworksBashSupport Pro .

Local Scope

BashSupport Pro supports the local variable scope. local allows to restrict the visibility of variables to the current function. It’s only available for Bash scripts, i.e. it’s not available in POSIX scripts.

Go To supports local scope. If you call it within a function, then it’ll only navigate to the local declarations. If you call it outside of a function, then it’ll ignore variables, which were declared as local.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
myVar=1

myFunction() {
    # will NOT navigate to the global declaration
    local myVar="local value" 
    
    # navigates to the local definition above
    printf "$myVar"
}

# navigates to myVar=1, skips the local declaration
echo $myVar 

Unset

BashSupport Pro supports the unset command. unset allows you to make a variable unavailable to all following commands. The plugin considers variables, which have been unset as a new variable.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
a=1
echo $a
# 'Go To Declaration' on a
# navigates to a=1
# Rename will rename this a and previous occurrences 
unset a

# $a is unresolved here, 
# because it was unset 
echo $a

# 'Go To Declaration' on a 
# will not navigate to previous declarations
# because it was unset.
# Rename will only rename this a and the line below
a=2
echo $a

Scratch Files

BashSupport Pro allows you to navigate in scratch files. The complete feature–set is available, but limited to the current file.

Injected Code

BashSupport Pro allows you to navigate in code with language injection. The complete feature–set is available, but limited to the code block. Navigation between multiple blocks is not yet supported.