5

From time to time I see similar framing for comments in bash scripts:

#!/bin/bash
#===================================================================================
#
# FILE: stale-links.sh
#
# USAGE: stale-links.sh [-d] [-l] [-oD logfile] [-h] [starting directories]
#
# DESCRIPTION: List and/or delete all stale links in directory trees.
# The default starting directory is the current directory.
# Don’t descend directories on other filesystems.
#===================================================================================

Is there any program to generate such a decoration for comments or do people usually create it manually?

P.S. After some search, I found similar threads:
How can I create a message box from the command line?
bash script , echo output in box

t7e
  • 323
  • If you mention which text editor you're using, it might get you better-focused answers. – MDeBusk Jun 20 '22 at 01:50
  • 3
    Please think about defining usage and help functions instead at the beginning of your scripts. They carry the same information, look a little less fancy, but it's a good convention to print a usage message on wrong arguments and a description at -h option. Having this information twice in the functions and in the block header may lead to one of them not getting updated on changes. – Philippos Jun 20 '22 at 05:44
  • 1
    In [tag:vim] you can do: i # Esc 60 a = Esc – glenn jackman Jun 20 '22 at 13:12
  • ...and once you've created a line that way, you can keep using yy + pp to duplicate it. – steve Jun 20 '22 at 20:12

2 Answers2

6

I really like Thomas Jensen's boxes. It does a lot more than just the comment boxes you describe, and more than just for shell scripts. It's a command-line utility and it also integrates with several text editors, including my personal favorite.

MDeBusk
  • 361
  • Thanks for the hint. It looks like the only program in the Internet I managed to find for this purpose. Are there any similar alternatives? – t7e Jun 20 '22 at 19:48
  • 1
    @t7e I've never seen anything else like it. There's always Tim Pope's commentary if you prefer plugins. – MDeBusk Jun 20 '22 at 20:26
0

If all you want is the informative header at the top of your scripts, you could do it without a plugin or external utility. Create a bash_script_template.sh that looks something like this:

#!/bin/bash

############################################################

Filename : x

Author : x

Created : x

Last edit : x

Purpose : x

Reference : x

Depends : x

Arguments : x

Known bugs : x

To do : x

############################################################

GNU All-Permissive License {{{

#############################################################

Copyright © 2022 my_name

Copying and distribution of this file, with or without

modification, are permitted in any medium without

royalty, provided the copyright notice and this notice

are preserved.

This file is offered as-is, without any warranty.

#############################################################

End license }}}

When you want to write a new script, copy the template to a new filename or read it into the top of an empty buffer.

MDeBusk
  • 361