From cc91e150346f762a173555125470de11d714f850 Mon Sep 17 00:00:00 2001 From: Georgi Gardev Date: Mon, 10 Feb 2025 16:30:49 +0200 Subject: [PATCH] update comment --- functions/set_overwrite_alias | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/functions/set_overwrite_alias b/functions/set_overwrite_alias index 0fd5284..eb14e9e 100644 --- a/functions/set_overwrite_alias +++ b/functions/set_overwrite_alias @@ -1,8 +1,26 @@ #!/usr/bin/env bash +# set_overwrite_alias - A Bash function to alias a command while preserving the original. +# +# Usage: +# set_overwrite_alias +# +# Parameters: +# new_command: The command to alias to (e.g., "bat"). +# alias_name: The alias name to override (e.g., "cat"). +# +# Behavior: +# - Checks if the new command exists. +# - If it exists and the backup alias (alias_name with an underscore appended) isn't set, +# it creates a backup alias pointing to the original command. +# - Sets the alias (alias_name) to use the new command. +# +# Example: +# To alias "bat" as "cat" and preserve the original "cat" as "cat_", run: +# set_overwrite_alias bat cat set_overwrite_alias() { - local new_cmd="$1" # e.g., "bat" - local alias_name="$2" # e.g., "cat" + local new_cmd="$1" + local alias_name="$2" if [ -z "$new_cmd" ] || [ -z "$alias_name" ]; then echo "Usage: set_overwrite_alias "