Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: automatically turn previous command into an alias




On 30/08/2022 14:04, Eric Cook wrote:
On 8/30/22 04:02, zzapper wrote:

# automatically turn previous command into an alias

 alias mkal='_f(){_al=$(history -n -1 -1 | sed "s#\\\\n##" ); alias $1="$_al" ; alias -L "$1"};_f'



any improvements, easier way etc


aliases_suck() {
  aliases[${1:?no name given}]=$history[$((HISTCMD-1))]
  alias -L $1
}

I really like your elegant solution. My lingering preference for aliases is that they are so easy to tab expand and tweek


zzapper





Messages sorted by: Reverse Date, Date, Thread, Author