Macro system and more shell variable features #52

Open
opened 2026-07-28 19:07:52 -06:00 by parker_macdonald · 0 comments

I've had an epiphany.

rash macros that end in an exclamation point.

$ define my_macro echo hi
$ my_macro!

Here's the best part: a predefined macro ! that expands to the last command.

$ mkdir /new/
access denied lol
$ sudo !!

the ! macro will expand to something like {LAST_CMD}

Which brings me to the next part of this ticket.

Shell variable arrays (and more builtin variables)

$ setvar my_array '[1, 2, 3, 4]'
$ echo {my_array}
1 2 3 4

But here's the kicker, each element of the array gets added as a unique argument.

$ setvar my_ls '["ls", "--color"]'
$ {my_ls} /example/
files
with
colors

More builtin shell variables:

  • LAST_CMD: array of strings corresponding to the arguments in the last command
  • HOST: system hostname
  • USER: user's username
  • UID: current user's id (number)
  • PID: pid of rash (number)
  • maybe more?
I've had an epiphany. rash macros that end in an exclamation point. ``` $ define my_macro echo hi $ my_macro! ``` Here's the best part: a predefined macro `!` that expands to the last command. ``` $ mkdir /new/ access denied lol $ sudo !! ``` the `!` macro will expand to something like `{LAST_CMD}` Which brings me to the next part of this ticket. Shell variable arrays (and more builtin variables) ``` $ setvar my_array '[1, 2, 3, 4]' $ echo {my_array} 1 2 3 4 ``` But here's the kicker, each element of the array gets added as a unique argument. ``` $ setvar my_ls '["ls", "--color"]' $ {my_ls} /example/ files with colors ``` More builtin shell variables: - LAST_CMD: array of strings corresponding to the arguments in the last command - HOST: system hostname - USER: user's username - UID: current user's id (number) - PID: pid of rash (number) - maybe more?
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
parker_macdonald/rash#52
No description provided.