-
Notifications
You must be signed in to change notification settings - Fork 3
Guideline for aliases
linux-shell-base edited this page Dec 3, 2017
·
16 revisions
Guideline for aliases and short-functions in Shell.
- is categorized.
- has a description.
Alias and short-function files are created in the following format:
# ======= #. SECTION NAME =====================================
#[Subsection name]
alias a1Name='alias start... ...a1 end' # a1Name: description
alias a2Name='alias start... ...a2 end' # a2Name: description
alias a3Name='alias start... ...a3 end' # a3Name: description
f1Name() { f1 line 1 start... ...f1 line 1 end; } # f1Name: description
f2Name() { f2 line 1 start... ...f2 line 1 end \
f2 line 2 start... ...f2 line 2 end; } # f2Name: description
- All aliases and short-functions are placed under a section and subsection.
- The equals character ("=") line always ends at column 65.
- An alias is no more than one line and has a maximum length of 100 characters (discluding the description).
- A short function is no more than two lines and each has a maximum length of 80 characters (discluding the description). (Note: A short-function is changed to a one-liner 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.
- The comment specifier ("#") starts on column 82 or one space after an alias longer than 80 characters.
- A description is all lowercase letters with the exception of names and acronymns.
For an example, see aliases-linux-output_only-single-value.bash.
- A variable name uses acronyms whenever possible.
- A non-global variable inside a function is declared local.
All other code style rules are up to the contributor.