Skip to content

Commit

Permalink
style: Improve documentation for Shell Scripts
Browse files Browse the repository at this point in the history
Added comments to define base environment variables in `.zprofile`
and categorized aliases in aliasrc. Adjusted an IP address for one
alias. Expanded comments in shell libraries to indicate work in
progress and improved function documentation style for readability.
  • Loading branch information
mdsanima committed Jun 16, 2024
1 parent f0bf34b commit 258a3ab
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 21 deletions.
3 changes: 3 additions & 0 deletions .zprofile
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# Defined base environment variables for the zsh shell terminal.

# Default
export EDITOR="nvim"
export ZDOTDIR="$HOME/.config/zsh"
7 changes: 5 additions & 2 deletions config/aliasrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Aliases definition
# Defined base aliases for the zsh shell terminal.

# Hosts
alias rpi0="ssh [email protected]"
alias rpi1="ssh [email protected]"
alias rpi2="ssh [email protected]"
Expand All @@ -8,12 +9,14 @@ alias rpi4="ssh [email protected]"
alias rpi5="ssh [email protected]"
alias rpi6="ssh [email protected]"
alias rpi7="ssh [email protected]"
alias rpi8="ssh [email protected].111"
alias rpi8="ssh [email protected].11"
alias jet1="ssh [email protected]"
alias jet2="ssh [email protected]"
alias macb="ssh [email protected]"

# Kubernetes
alias k="kubectl"

# Editor
alias vi="nvim"
alias vim="nvim"
8 changes: 1 addition & 7 deletions lib/mdsanima-shell/libcolor.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# Copyright (c) 2024 MDSANIMA DEV. All rights reserved.
# Licensed under the MIT license.

# Library for color palette definition.
# Library for color palette definition. This is still work in progress.

#-------------------------------------------------------------------------------
# Global main default color names
#-------------------------------------------------------------------------------
readonly WHITE=15
readonly BLACK=16
readonly LIGHT=252
Expand Down Expand Up @@ -41,9 +39,7 @@ readonly NEUTRAL=240
readonly BASIC=242
readonly STONE=244

#-------------------------------------------------------------------------------
# Global base integer color names
#-------------------------------------------------------------------------------
readonly INT_WHITE=${WHITE}
readonly INT_BLACK=${BLACK}
readonly INT_LIGHT=${LIGHT}
Expand Down Expand Up @@ -79,9 +75,7 @@ readonly INT_NEUTRAL=${NEUTRAL}
readonly INT_BASIC=${BASIC}
readonly INT_STONE=${STONE}

#-------------------------------------------------------------------------------
# Global base hexadecimal color names
#-------------------------------------------------------------------------------
readonly HEX_WHITE="#ffffff"
readonly HEX_BLACK="#000000"
readonly HEX_LIGHT="#cad1d9"
Expand Down
10 changes: 5 additions & 5 deletions lib/mdsanima-shell/libconvert.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# Copyright (c) 2024 MDSANIMA DEV. All rights reserved.
# Licensed under the MIT license.

# Library for converting functions.
# Library for converting functions. This is still work in progress.

#-------------------------------------------------------------------------------
# This function converting HEX color code to RGB values. The returned values are
# separated by semicolon and will be used in another function.
# --------------------------------------------------------------------------------------------------
# This function is for converting HEX color code to RGB values. The returned values are separated
# by semicolon and will be used in another function.
#
# Arguments:
# <hex_color> The hexadecimal color code string, required
#
# Usage:
# convert::hex_to_rgb <hex_color>
# convert::hex_to_rgb "#ff0000"
#-------------------------------------------------------------------------------
# --------------------------------------------------------------------------------------------------
function convert::hex_to_rgb() {
local hex_color="$1"
local awk_cmd='{print strtonum("0x" $0)}'
Expand Down
2 changes: 1 addition & 1 deletion lib/mdsanima-shell/libevent.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) 2024 MDSANIMA DEV. All rights reserved.
# Licensed under the MIT license.

# Library for event logging functions.
# Library for event logging functions. This is still work in progress.

function event::debug() {
print::color -fg ${BLACK} -bg ${GRAY} -b " DEBUG "
Expand Down
10 changes: 5 additions & 5 deletions lib/mdsanima-shell/libprint.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Copyright (c) 2024 MDSANIMA DEV. All rights reserved.
# Licensed under the MIT license.

# Library for printing functions.
# Library for printing functions. This is still work in progress.

#-------------------------------------------------------------------------------
# This function provides a simple way to print text with colors on the terminal
# bash script outputs. The color mode may be number, name or HEX code.
#---------------------------------------------------------------------------------------------------
# This function provides a simple way to print the text with colors on the terminal bash script
# outputs. The color mode may be number, name or HEX code.
#
# Arguments:
# -fg <color> Foreground color mode, optional, default to none
Expand All @@ -22,7 +22,7 @@
# print::color -fg ${BLACK} -bg ${INT_RED} "Black text on red background"
# print::color -fg ${HEX_YELLOW} -i "Italic yellow text"
# print::color -fg "#f97316" -b "Bold orange text"
#-------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------
function print::color() {
local fg_color
local bg_color
Expand Down
2 changes: 1 addition & 1 deletion lib/mdsanima-shell/libutil.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) 2024 MDSANIMA DEV. All rights reserved.
# Licensed under the MIT license.

# Library for utility functions.
# Library for utility functions. This is still work in progress.

readonly clean_line_seq="\r\e[0K"

Expand Down

0 comments on commit 258a3ab

Please sign in to comment.