Created
July 21, 2025 14:28
-
-
Save Rudxain/c8a9f9c91e8a43490a0c5df29c107de6 to your computer and use it in GitHub Desktop.
Function that renames a shell alias. Doesn't handle quotes properly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
realias() { | |
if [ $# -ne 2 ]; then | |
echo "Usage: realias old_alias new_alias" | |
return 1 | |
fi | |
local o | |
o="$(alias -- "$1")" || { | |
printf %s "$o" | |
return 1 | |
} | |
unalias -- "$1" | |
alias -- "$2"="$(printf %s "$o" | sed -E "s/^alias $1=['\"](.*)['\"]$/\1/")" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment