zsh-users
 help / color / mirror / code / Atom feed
From: zzapper <zsh@rayninfo.co.uk>
To: Zsh-Users List <zsh-users@zsh.org>
Subject: automatically turn previous command into an alias
Date: Tue, 30 Aug 2022 09:02:40 +0100	[thread overview]
Message-ID: <e2a884e0-42f2-8108-dd97-f17eb15843d0@rayninfo.co.uk> (raw)

[-- Attachment #1: Type: text/plain, Size: 396 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 1547 bytes --]

             reply	other threads:[~2022-08-30  8:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-30  8:02 zzapper [this message]
2022-08-30 13:04 ` Eric Cook
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=e2a884e0-42f2-8108-dd97-f17eb15843d0@rayninfo.co.uk \
    --to=zsh@rayninfo.co.uk \
    --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).