Skip to content

Guideline for aliases

adrianbartyczak edited this page Mar 15, 2019 · 16 revisions

Guideline for aliases and short-functions in Gnu-linux-shell-use.

  1. Format
  2. Code style

Format

Aliases and short-functions files are created in the following format:

alias a1Name='alias start...                           ...a1 end'                # a1Name: description
alias a2Name='alias start...                                          ...a2 end' # a2Name: description
alias a3Name='alias start...                                                              ...a3 end' # a3Name: description
sf1Name() { sf1 line 1 start...                             ...sf1 line 1 end; } # sf1Name: description
sf2Name() { sf2 line 1 start...                              ...sf2 line 1 end \
  sf2 line 2 start...                            ...sf2 line 2 end; }            # sf2Name: description
  • The comment specifier ("#") starts on column 82 or one space after an alias longer than 80 characters.
  • All descriptions are all lowercase with the exception of names and acronymns.

For an example, see name-matching-file-finding.aliases.

Code style

General

Lines and indentation
  • An alias is no more than one line and a maximum length of 100 characters (discluding the description).
  • A short function is no more than two lines and a maximum length of 80 characters (discluding the description) on each line. (Note: A short-function is changed placed in a script or function script if it is more than 2 lines).
  • A short-function is continued on the next line with the last space-separated word that exceeds the 80 character limit.
  • A continued line is indented 2 spaces.
Variables
  • A variable name uses acronyms whenever possible.

Bash

Variables
  • A non-global variable inside a function is declared local.

All other code style rules are up to the developer.