Rename fn

This commit is contained in:
2025-02-10 17:49:34 +02:00
parent cc91e15034
commit a63ea3c5e7
3 changed files with 12 additions and 12 deletions
@@ -1,9 +1,9 @@
#!/usr/bin/env bash
# set_overwrite_alias - A Bash function to alias a command while preserving the original.
# set_alias_with_backup - A Bash function to alias a command while preserving the original.
#
# Usage:
# set_overwrite_alias <new_command> <alias_name>
# set_alias_with_backup <new_command> <alias_name>
#
# Parameters:
# new_command: The command to alias to (e.g., "bat").
@@ -17,8 +17,8 @@
#
# Example:
# To alias "bat" as "cat" and preserve the original "cat" as "cat_", run:
# set_overwrite_alias bat cat
set_overwrite_alias() {
# set_alias_with_backup bat cat
set_alias_with_backup() {
local new_cmd="$1"
local alias_name="$2"
@@ -28,12 +28,12 @@ set_overwrite_alias() {
fi
# Check that the new command exists.
if type "$new_cmd" >/dev/null 2>&1; then
if type "$new_cmd" >/dev/null 2>&1;then
# Define a backup alias by appending an underscore (e.g., "cat_" for "cat")
local backup_alias="${alias_name}_"
# If the backup alias isn't already set, create it pointing to the original command.
if ! command -v "$backup_alias" &>/dev/null; then
if ! type "$backup_alias" >/dev/null 2>&1; then
alias "$backup_alias"="$(which "$alias_name")"
fi
+5 -5
View File
@@ -127,11 +127,11 @@ if type eza >/dev/null 2>&1; then
alias lX='ll --sort=ext'
fi
set_overwrite_alias bat cat
set_overwrite_alias doggo dig
set_overwrite_alias duf df
set_overwrite_alias gping ping
set_overwrite_alias dust du
set_alias_with_backup bat cat
set_alias_with_backup doggo dig
set_alias_with_backup duf df
set_alias_with_backup gping ping
set_alias_with_backup dust du
##### Mac OS Specific #####
if [ "$(uname)" = "Darwin" ]; then
+1 -1
View File
@@ -51,7 +51,7 @@ setopt no_beep # Don't beep on command input error
# Include functions
fpath+=~/Git/dotfiles/functions
autoload extract
autoload set_overwrite_alias
autoload set_alias_with_backup
[ -f $ZDOTDIR/.zshrc.local ] && source $ZDOTDIR/.zshrc.local
[ -f ~/.config/.aliases ] && source ~/.config/.aliases