Skip to content

Commit e1542ec

Browse files
committed
Stylistic fixes
1 parent 89637ef commit e1542ec

6 files changed

Lines changed: 74 additions & 74 deletions

File tree

git-project-initializer/git_project_init.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
# Dependencies: curl git realpath
1212
#
13-
# Description: The script creates a boilerplate Git project by creating the
13+
# Description: This script sets up a boilerplate Git project by creating the
1414
# recommended directories, adding file templates, and initializing the Git
1515
# repository.
1616
#
@@ -44,7 +44,7 @@ declare -a VALID_LICENSES=(artistic-v2.0 bsd-2 bsd-3 epl-v1.0 gnu-agpl-v3.0
4444
gnu-lgpl-v2.1 gnu-lgpl-v3.0 mit mpl-v2.0 unlicense)
4545

4646
#######################################
47-
# Function to handle and validate run options.
47+
# Handles and validates run options.
4848
# Arguments:
4949
# Script positional arguments.
5050
# Returns:
@@ -115,7 +115,7 @@ EOF
115115
}
116116

117117
#######################################
118-
# Check if a value exists in an array.
118+
# Checks if a value exists in an array.
119119
# Arguments:
120120
# $1 - Value to search for.
121121
# $@ - Array elements.
@@ -133,7 +133,7 @@ in_array() {
133133
}
134134

135135
#######################################
136-
# Check project_dir, refuse root or home
136+
# Checks project_dir, refuses root or home
137137
# directory.
138138
# Returns:
139139
# Exit status.
@@ -152,7 +152,7 @@ chk_dir() {
152152
}
153153

154154
#######################################
155-
# Check if commands are available on the
155+
# Checks if commands are available on the
156156
# system.
157157
# Arguments:
158158
# Commands to be checked.
@@ -172,7 +172,7 @@ chk_deps() {
172172
}
173173

174174
#######################################
175-
# Create project directory with error
175+
# Creates project directory, with error
176176
# handling if it already exists.
177177
# Returns:
178178
# Exit status.
@@ -194,7 +194,7 @@ crt_dir() {
194194
}
195195

196196
#######################################
197-
# Download template files with error handling.
197+
# Downloads template files with error handling.
198198
#######################################
199199
dwl_templates() {
200200
curl -sSLo COPYING.md \
@@ -209,7 +209,7 @@ dwl_templates() {
209209
}
210210

211211
#######################################
212-
# Create the .gitignore file.
212+
# Creates the .gitignore file.
213213
#######################################
214214
crt_gitignore() {
215215
cat > .gitignore << EOF
@@ -224,8 +224,8 @@ EOF
224224
}
225225

226226
#######################################
227-
# Perform initial git commands with error
228-
# handling. Only commit if repository is not
227+
# Performs initial git commands with error
228+
# handling. Only commits if repository is not
229229
# empty.
230230
#######################################
231231
git_steps() {

rclone-automount/rclone_automount.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ set -euo pipefail
3939
CONFIG_FILE="${HOME}/.config/rclone/automount.conf"
4040

4141
#######################################
42-
# Function to handle and validate run options.
42+
# Handles and validates run options.
4343
# Arguments:
4444
# Script positional arguments.
4545
# Returns:
@@ -229,7 +229,7 @@ chk_dir() {
229229
command_loop() {
230230
# Declare local variables.
231231
local mount_path log_path
232-
local -i i=0 success_count=0 skip_count=0 fail_count=0
232+
local -i i success_count=0 skip_count=0 fail_count=0
233233

234234
for ((i=0; i<${#REMOTES[@]}; i++)); do
235235
# Create mount and log paths.
@@ -239,12 +239,12 @@ command_loop() {
239239
# Validate mount dirs.
240240
if mountpoint -q "${mount_path}" 2>/dev/null ; then
241241
echo "⚠️ ${MOUNTS[$i]} already mounted, skipping"
242-
skip_count=$((skip_count + 1))
242+
((fail_count++))
243243
continue
244-
elif [[ -d "$mount_path" \
245-
&& -n "$(ls -A "$mount_path" 2>/dev/null)" ]]; then
246-
err "Mount dir not empty: $mount_path"
247-
fail_count=$((fail_count + 1))
244+
elif [[ -d "${mount_path}" \
245+
&& -n "$(ls -A "${mount_path}" 2>/dev/null)" ]]; then
246+
err "Mount dir not empty: ${mount_path}"
247+
((fail_count++))
248248
continue
249249
fi
250250

@@ -260,8 +260,8 @@ command_loop() {
260260
# Build and execute command.
261261
if rclone mount \
262262
"${REMOTES[$i]}" \
263-
"$mount_path" \
264-
--log-file "$log_path" \
263+
"${mount_path}" \
264+
--log-file "${log_path}" \
265265
"${args[@]}"; then
266266
echo "${MOUNTS[$i]} mounted successfully."
267267
((success_count++))

script-autostart/script_autostart.sh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
# https://github.com/OperaVaria/useful-bash-scripts
99
# Version 1.0.0
1010
#
11-
# This small command line utility helps the user to easily set up a script to
12-
# automatically run at login.
11+
# Dependencies: realpath
12+
#
13+
# Description: This small command line utility helps the user to easily set up
14+
# a script to run automatically at login.
1315
#
1416
# Tested on: CachyOS (rolling), GNU bash, 5.3.9(1)-release
1517
#
@@ -33,7 +35,7 @@
3335
set -euo pipefail
3436

3537
#######################################
36-
# Function to handle and validate run options.
38+
# Handles and validates run options.
3739
# Arguments:
3840
# Script positional arguments.
3941
# Returns:
@@ -122,7 +124,7 @@ val_script() {
122124
}
123125

124126
#######################################
125-
# Set script file executable if it is not.
127+
# Makes script file executable.
126128
# Prompt only in interactive mode.
127129
# Returns:
128130
# Exit status.
@@ -137,24 +139,22 @@ set_exec() {
137139

138140
#######################################
139141
# Creates a .desktop file in the user
140-
# autostart directory. Prompts if file
141-
# already exists, tries to create autostart
142-
# directory if absent.
143-
# Error handling included.
142+
# autostart directory. Tries to create autostart
143+
# directory, if absent. Prompts if file
144+
# already exists. Error handling included.
144145
# Returns:
145146
# Exit status.
146147
#######################################
147148
crt_autostart() {
148149
local autostart_dir script_name desktop_file
149150
autostart_dir="${HOME}/.config/autostart"
150151
script_name=$(basename "${script}")
151-
desktop_file="${autostart_dir}/${script_name}.desktop"
152-
if [[ -e "${desktop_file}" ]]; then
153-
conf_prompt "⚠️ Autostart entry already exists. Overwrite?" || return 1
154-
fi
152+
desktop_file="${autostart_dir}/${script_name}.desktop"
155153
if ! mkdir -p "${autostart_dir}"; then
156154
echo "❌ Failed to create autostart directory" >&2
157155
return 1
156+
elif [[ -e "${desktop_file}" ]]; then
157+
conf_prompt "⚠️ Autostart entry already exists. Overwrite?" || return 1
158158
fi
159159
if ! cat > "${desktop_file}" <<EOF
160160
[Desktop Entry]

smart-cleanup/smart_cleanup_arch.sh

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ set -euo pipefail
4040
readonly NORMAL_DAY_LIMIT=14 AGGRESSIVE_DAY_LIMIT=7
4141

4242
#######################################
43-
# Function to handle and validate run options.
43+
# Handles and validates run options.
4444
# Arguments:
4545
# Script positional arguments.
4646
# Returns:
@@ -91,9 +91,9 @@ EOF
9191
}
9292

9393
#######################################
94-
# Display initial warning and set
94+
# Displays initial warning and sets
9595
# variables in accordance with
96-
# aggressiveness.
96+
# aggressiveness option.
9797
# Returns:
9898
# Exit status.
9999
#######################################
@@ -112,7 +112,7 @@ set_aggress() {
112112
}
113113

114114
#######################################
115-
# Function to clean ~/.cache directory.
115+
# Cleans the ~/.cache directory.
116116
# Deletes empty directories and files
117117
# older than global limit.
118118
# Returns:
@@ -131,7 +131,7 @@ cln_cache() {
131131
}
132132

133133
#######################################
134-
# Function to empty the Trash directory.
134+
# Empties the Trash directory.
135135
# Returns:
136136
# Exit status.
137137
#######################################
@@ -147,7 +147,7 @@ cln_trash() {
147147
}
148148

149149
#######################################
150-
# Function to clean the /tmp directory.
150+
# Cleans the /tmp directory.
151151
# Deletes empty directories and files
152152
# older than global limit.
153153
# Returns:
@@ -162,8 +162,7 @@ cln_tmp() {
162162
}
163163

164164
#######################################
165-
# Function to clean log files older than
166-
# global limit.
165+
# Cleans log files older than global limit.
167166
# Returns:
168167
# Exit status.
169168
#######################################
@@ -175,10 +174,9 @@ cln_logs() {
175174
}
176175

177176
#######################################
178-
# Function to vacuum journals.
179-
# Checks for dependencies, tracks space
180-
# freed if helper function dependency
181-
# is available (bc).
177+
# Vacuums journals. Checks for dependencies,
178+
# tracks space freed if helper function
179+
# dependency is available (bc).
182180
# Returns:
183181
# Exit status.
184182
#######################################
@@ -206,6 +204,7 @@ vac_journals() {
206204
#######################################
207205
# Helper function to convert journalctl
208206
# disk usage output to byte value.
207+
# Echos value in bytes.
209208
# Returns:
210209
# Exit status.
211210
#######################################
@@ -247,7 +246,7 @@ journalctl_bytes() {
247246
}
248247

249248
#######################################
250-
# Function to clean pacman cache.
249+
# Cleans pacman cache.
251250
# Normal mode leaves most recent three
252251
# cached, aggressive removes all.
253252
# Checks for dependencies.
@@ -270,7 +269,7 @@ cln_paccache() {
270269
}
271270

272271
#######################################
273-
# Function to remove orphaned packages.
272+
# Removes orphaned packages.
274273
# Checks for dependencies.
275274
# Returns:
276275
# Exit status.
@@ -295,7 +294,7 @@ cln_orph() {
295294
}
296295

297296
#######################################
298-
# Function to iterate over cleaning functions.
297+
# Iterates over cleaning functions and data arrays.
299298
# Displays prompts in normal mode. Tracks freed
300299
# space when possible (exception: vac_journals,
301300
# cln_orph).
@@ -363,7 +362,7 @@ conf_prompt() {
363362
}
364363

365364
#######################################
366-
# Check if commands are available on the
365+
# Checks if commands are available on the
367366
# system.
368367
# Arguments:
369368
# Commands to be checked.
@@ -383,7 +382,7 @@ chk_deps() {
383382
}
384383

385384
#######################################
386-
# Function to check the size of the target.
385+
# Checks the size of the target.
387386
# Echos value in bytes.
388387
# Arguments:
389388
# Target path.
@@ -402,7 +401,7 @@ size_of() {
402401
}
403402

404403
#######################################
405-
# Calculate and track space freed,
404+
# Calculates and tracks space freed,
406405
# including total value in MBs.
407406
# Arguments:
408407
# Size before in bytes.

0 commit comments

Comments
 (0)