My fasting journey

We are capable of creating such wonderful things but when we are deprived of certain needs, we run the risk of reverting to our animal nature — ignoring our purpose, ignoring the needs of others…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Quickly save previous shell commands to a script

I wish I had discovered this long ago. With the power of Vim or other editors, it’s a breeze to compose complex, multi-line, or repetitive commands using your favourite editing tool. Writing and quitting in your editor fills in that command at your shell prompt.

Today came the logical leap to using this trick as a rapid way to save previous commands to a script. After finding the previous command in your history (or using ctrl-r for reverse search), in Vim it’s simply a case of ctrl-x-e followed by :w filename.sh to save as a script. A quick save this way is great for making a note of a command you want to make sure you have for the future, especially when it’s a complex command from trial and error that you don’t want to rebuild.

Append to the file (:w >> filename.sh in Vim) to build up your script from commands in your live session. Appending in this way is great when there’s a lot of trial and error in getting a series of commands right, and you want to save just the ones that work correctly as you achieve them.

If you want to go back further in time, or pick and choose multiple commands from your history to put into a script in a single go, then another trick is to pipe in your shell history to your editor:

(Replacing x with the number of lines of history you want to go back). Then delete the history numbering (:%s/^\s*\d\+\s*//g will do it in Vim) and the lines you don’t want; then save to file.

Finally, no need to fret that you’ll lose those long, complex, or multiline commands, or do finger gymnastics to edit them!

Add a comment

Related posts:

IVXX

I just release a new song titled: “Too Late” you can watch the visuals bellow:. “IVXX” is published by IVXXMUSICMGMT.

Where can i get help installing script johnedwardsproperties mortgage calculator?

Ok I heard back from my hosting co. they said … yes .. go ahead and edit the file…what they didnt say was the file doesent exist until I make it.. I followed your instructions and copied the code…

How do car dealers calculate interest rates?

What other numbers are they using to come up with the monthly payment. Its not as simple as the loan amount multiplied by the interest rate devided by the # of months Answer : I would recommend one…