Introduction

BashSupport Pro supports the source command and follows sourced files.

Source Command Support

If you use the command with relative paths, then the plugin will automatically follow these files.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## a.bash

# Call 'Go To Declaration' on the filename to open it.
# BashSupport Pro uses declarations in lib.bash for:
#  code completion
# - go to declaration
# - find usages
# - rename
# - quick documentation

source ./lib.bash

# Renaming 'myFunc' here
# also renames it in lib.bash 
myFunc
1
2
3
4
5
6
7
## lib.bash, sourced by a.bash

# Renaming 'myFunc' here
# also renames it in a.bash 
myFunc() {
    echo hello world
}

Shellcheck Support

If you’re using dynamic values with the source command, then BashSupport Pro needs help to locate the file.

For example, code like this is commonly used:

1
. "${_basedir}/included-file.sh"

$_basedir is only known at runtime and BashSupport Pro needs help here.

Define a shellcheck source directive to tell BashSupport Pro where to find the sourced file:

1
2
3
4
# hint for BashSupport Pro where to find the file
# 'Go To Declaration' on the filename opens it
# shellcheck source=./lib/included-file.sh
. "${_basedir}/included-file.sh"

Now Go To, Find Usages, Rename, etc. will also take care of the elements in the sourced file.

Go To Declaration

BashSupport Pro supports two scenarios:

  1. The declaration is in a sourced file
  2. The declaration is in a file, which sources the current file

Code Completion

Code completion works across multiple files.

Rename Refactoring

Rename works across multiple files. Everything, which is located by Find Usages is also renamed by this refactoring.