Skip to content

Instantly share code, notes, and snippets.

@Khazbs
Created March 26, 2025 12:43
Show Gist options
  • Save Khazbs/f23731fd82311a1472d0f58abed836d6 to your computer and use it in GitHub Desktop.
Save Khazbs/f23731fd82311a1472d0f58abed836d6 to your computer and use it in GitHub Desktop.
AKA for ZSH
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.zsh_aliases, instead of adding them here directly.
if [ -f ~/.zsh_aliases ]; then
. ~/.zsh_aliases
fi
# Write new alias to ~/.zsh_aliases and source that file.
aka()
{
local alias_regex='[A-Za-z_0-9]*'
if
[[ $# = 1 && $1 =~ ($alias_regex)=(.*) ]]
then
printf "%s\n" "alias ${match[1]}=\"${match[2]}\"" >> ~/.zsh_aliases
. ~/.zsh_aliases
else
echo "Usage: aka ALIAS_NAME=ALIAS_COMMAND"
return 1
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment