Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions core/help.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ function show_main_help() {
function show_modules() {
for module_file in "${AK_ROOT}/modules/"*.sh; do
if [[ -f "$module_file" ]]; then
local category=$(grep -m 1 "# CATEGORY:" "$module_file" | sed 's/# CATEGORY: //')
local module_name=$(basename "$module_file" | sed -E 's/^[0-9]+_//' | sed 's/\.sh$//')
local category
category=$(grep -m 1 "# CATEGORY:" "$module_file" | sed 's/# CATEGORY: //')
local module_name
module_name=$(basename "$module_file" | sed -E 's/^[0-9]+_//' | sed 's/\.sh$//')
printf " %-15s - %s\n" "$module_name" "${category:-Uncategorized}"
fi
done
Expand All @@ -64,10 +66,12 @@ function show_module_help() {
local found=0

for module_file in "${AK_ROOT}/modules/"*.sh; do
local module_name=$(basename "$module_file" | sed -E 's/^[0-9]+_//' | sed 's/\.sh$//')
local module_name
module_name=$(basename "$module_file" | sed -E 's/^[0-9]+_//' | sed 's/\.sh$//')
if [[ "$module_name" == "$target_module" ]]; then
found=1
local category=$(grep -m 1 "# CATEGORY:" "$module_file" | sed 's/# CATEGORY: //')
local category
category=$(grep -m 1 "# CATEGORY:" "$module_file" | sed 's/# CATEGORY: //')
print_color "cyan" "📦 Module: $module_name ($category)"
echo "---------------------------------------------------"

Expand Down Expand Up @@ -113,10 +117,12 @@ function search_aliases() {

local found=0
for module_file in "${AK_ROOT}/modules/"*.sh; do
local module_name=$(basename "$module_file" | sed -E 's/^[0-9]+_//' | sed 's/\.sh$//')
local module_name
module_name=$(basename "$module_file" | sed -E 's/^[0-9]+_//' | sed 's/\.sh$//')

# We need to extract blocks of alias info.
local results=$(awk -v term="$term" '
local results
results=$(awk -v term="$term" '
/^## / {
cmd = substr($0, 4)
getline
Expand Down Expand Up @@ -167,6 +173,7 @@ case "$COMMAND" in
show_modules
;;
reload)
# shellcheck source=/dev/null
source ~/.bashrc
print_color "green" "✔ Aliaskit reloaded directly."
;;
Expand Down
5 changes: 4 additions & 1 deletion core/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

# core/init.sh - Initializes aliaskit, loads configs, and sources enabled modules

export AK_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
AK_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
export AK_ROOT
export AK_CONFIG="${HOME}/.aliaskit.conf"

# Copy default config if it doesn't exist
Expand All @@ -15,6 +16,7 @@ fi

# Load configs
if [[ -f "$AK_CONFIG" ]]; then
# shellcheck source=/dev/null
source "$AK_CONFIG"
fi

Expand All @@ -26,6 +28,7 @@ for module_file in "${AK_ROOT}/modules/"*.sh; do

# Check if module is enabled (defaults to true if not explicitly set to false)
if [[ "${!var_name}" != "false" ]]; then
# shellcheck source=/dev/null
source "$module_file"
fi
fi
Expand Down
6 changes: 4 additions & 2 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ check_and_update() {
# We will do a quick check against remote
git fetch origin main &>/dev/null || git fetch origin master &>/dev/null

local LOCAL=$(git rev-parse HEAD 2>/dev/null)
local REMOTE=$(git rev-parse @{u} 2>/dev/null)
local LOCAL
LOCAL=$(git rev-parse HEAD 2>/dev/null)
local REMOTE
REMOTE=$(git rev-parse "@{u}" 2>/dev/null)

if [[ -z "$LOCAL" || -z "$REMOTE" ]]; then
[[ $AUTO_MODE -eq 0 ]] && echo "Cannot check for updates. Are you in a git repository with an upstream set?"
Expand Down
Loading