zsh-users
 help / color / mirror / code / Atom feed
From: Eric Cook <llua@gmx.com>
To: zsh-users@zsh.org
Subject: Re: automatically turn previous command into an alias
Date: Tue, 30 Aug 2022 09:04:39 -0400	[thread overview]
Message-ID: <d5401f18-927b-99a4-5cef-470edaf4385a@gmx.com> (raw)
In-Reply-To: <e2a884e0-42f2-8108-dd97-f17eb15843d0@rayninfo.co.uk>

On 8/30/22 04:02, zzapper wrote:
> Hi
>
> # 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'
>
>>  ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head
>
>>  mkal psq
>
>>  psq
>
> PID PPID CMD %MEM %CPU
>
> 3393 2374 /usr/lib/firefox/firefox 10.0 3.6 119165
>
> 3364 /usr/lib/thunderbird/thunde 7.2 30.4
>
> .. etc
>
>
> any improvements, easier way etc
>

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


  reply	other threads:[~2022-08-30 13:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-30  8:02 zzapper
2022-08-30 13:04 ` Eric Cook [this message]
2022-08-30 13:26   ` zzapper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d5401f18-927b-99a4-5cef-470edaf4385a@gmx.com \
    --to=llua@gmx.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).