Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ctags for shell scripts without extensions

I'm working on a Bash script that is designed to be run 'as a tool' so has a name without an extension and a #!/usr/bin/bash line at the top.

My script has a number of functions, so it would be nice if I could use Vim's tagging support to jump around the code, but I can't get ctags to tag the file. ctags mytool produces a tags file that is blank except for the comment section at the top.

If I rename my file to mytool.sh, ctags mytool.sh works perfectly.

Is there a way to force ctags to tag a file without an extension? I've tried a number of options that I found in the ctags manual that seem to relate to file extensions, but without joy.

like image 353
David Waller Avatar asked Jul 31 '12 12:07

David Waller


People also ask

How do I add Ctags?

To install Exuberant Ctags: Go to the following website and download the latest package labeled Source and binary for Windows: http://ctags.sourceforge.net. If the latest binary package is not available for download, go to the Download section and download the binary package for the previous version of Ctags.

What is Ctags in vim?

Ctags is a tool that generates a tag file of names found in source files. In Moodle, it can be used to index PHP functions, variables, classes and so on. These tags allow definitions to be quickly and easily located by a text editor such as vim.

What is the purpose of the Unix program Ctags?

Ctags is a tool that makes it easy to navigate large source code projects. It provides some of the features that you may be used to using in Eclipse or other IDEs, such as the ability to jump from the current source file to definitions of functions and structures in other files.


2 Answers

If you're using "Exuberant Ctags", you can use the --language-force option:

ctags --language-force=sh mytool

This is documented explicitly in the man page.

like image 196
larsks Avatar answered Oct 02 '22 20:10

larsks


I use the below command to create the tags file on all files in my entire shell source directory tree

ctags -R --language-force=sh
like image 33
olagu Avatar answered Oct 02 '22 20:10

olagu