You're viewing a comment by libdave and its responses.

April 22, 2010, 12:01

One of my favorites: to edit any env variable

print -s "PATH=$PATH"

then edit the last command (zsh with vi keybindings): ESC-

Comment Responses

April 22, 2010, 12:08

Almost forgot the follow up function to make it easier:
foo()
{
eval "print -s ${1?no variable}=\'\$$1\'"
}

then do this:
X='xyzzy plugh'

foo X

then edit your history

April 22, 2010, 23:06

Hmm.. Can you explain this a bit more? I don't understand it.

May 19, 2010, 13:21

What he's doing is first he sets PATH to itself (eval PATH=$PATH), which leaves him with something like
PATH=/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin
in his history. Then he just uses the editor to modify this and run it again, thus setting PATH to the modified value.

Reply To This Comment

(why do I need your e-mail?)

(Your twitter name, if you have one. (I'm @pkrumins, btw.))

Type the first letter of your name: (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.