Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Other Things Gentoo
  • Search

efficient use of the history command from terminal prompt

Still need help with Gentoo, and your question doesn't fit in the above forums? Here is your last bastion of hope.
Post Reply
Advanced search
14 posts • Page 1 of 1
Author
Message
mikefot
l33t
l33t
Posts: 709
Joined: Wed Nov 19, 2014 5:34 pm

efficient use of the history command from terminal prompt

  • Quote

Post by mikefot » Sat May 02, 2020 4:29 pm

Dear All,

I am interested to try to improve my practical skills and efficiency a bit when running commands from the terminal
when running gentoo.

Supposing you have a list of commands that you regularly run one after the other in gentoo.

If you wanted to have a convenient way to repeatedly run them consecutively in the same order you could
put them in a file and make it executable and then run a job either interactively or in background mode that would then run
each command in sequence for you.

But you could also (as I do) use the history command to list those commands in sequence showing the last time you issued them all
one after the other yourself by hand.

What I do is to use the exclamation mark symbol and the number of each command and then submit that to the terminal
by hand iteratively increasing the integer number by plus one as I go along.

E.g.

Code: Select all

chump# !5
chump# !6
chump# !7
chump# !8
etc.

It works quite well I find.

OUt of interest, is there a command which would run them one after another something like this:

Code: Select all

champ# !5-8
where what was implied was to execute the above sequence of commands one after the other ie commands 5 through 8 in the history list?

Suggestions welcome.

Regards

Michael Fothergill
Top
Hu
Administrator
Administrator
Posts: 24395
Joined: Tue Mar 06, 2007 5:38 am

  • Quote

Post by Hu » Sat May 02, 2020 5:33 pm

You could separate the history expansions with semicolons instead of newlines.

Code: Select all

$ !4; !5; !6
You could use && if you want to stop early on error.
Top
mikefot
l33t
l33t
Posts: 709
Joined: Wed Nov 19, 2014 5:34 pm

  • Quote

Post by mikefot » Sat May 02, 2020 5:48 pm

Many thanks for your response and suggestion.

I tried your recommendation out with a series of commands that allows me to
create a chroot environment for gentoo running on top of a debian install I have on
my laptop.

It worked.

I assume I could repeat this as the collective set of commands would be listed as one command entry in the history listing.

I will check this.

I think this can save me a lot of time and reduce errors.

Regards

MF
Top
dmpogo
Advocate
Advocate
Posts: 3714
Joined: Thu Sep 02, 2004 9:21 pm
Location: Canada

  • Quote

Post by dmpogo » Sat May 02, 2020 10:38 pm

My most common history use is to do

!beginning of a command

say

!pdf usually to runs pdflatex file.tex which I am currently working on, or !eclean usually means eclean -d distfiles etc. There is a danger to get a wrong one, of course, but I do know my workflow usually.
Top
Hu
Administrator
Administrator
Posts: 24395
Joined: Tue Mar 06, 2007 5:38 am

  • Quote

Post by Hu » Sat May 02, 2020 11:18 pm

If you are unsure what you will get, you can direct the shell to expand without executing by using history-expand-line, which is bound to Meta ^ (you may need to type Escape, Shift+6 to get this). If you routinely want to do this, use shopt -s histverify, so that pressing enter rewrites the command line to be what you would run, and pressing enter again runs it.
Top
dmpogo
Advocate
Advocate
Posts: 3714
Joined: Thu Sep 02, 2004 9:21 pm
Location: Canada

  • Quote

Post by dmpogo » Sun May 03, 2020 7:07 am

Hu wrote:If you are unsure what you will get, you can direct the shell to expand without executing by using history-expand-line, which is bound to Meta ^ (you may need to type Escape, Shift+6 to get this). If you routinely want to do this, use shopt -s histverify, so that pressing enter rewrites the command line to be what you would run, and pressing enter again runs it.
Nice tip, thanks !
Top
Jaglover
Watchman
Watchman
User avatar
Posts: 8291
Joined: Sun May 29, 2005 1:57 am
Location: Saint Amant, Acadiana

  • Quote

Post by Jaglover » Sun May 03, 2020 10:47 am

I'm so used to type the first letter or two and then PgUp that everything else seems too complicated.
My Gentoo installation notes.
Please learn how to denote units correctly!
Top
Banana
Administrator
Administrator
User avatar
Posts: 2388
Joined: Fri May 21, 2004 12:02 pm
Location: Germany
Contact:
Contact Banana
Website

  • Quote

Post by Banana » Sun May 03, 2020 3:49 pm

Jaglover wrote:I'm so used to type the first letter or two and then PgUp that everything else seems too complicated.
+1
Forum Guidelines

PFL - Portage file list - find which package a file or command belongs to.
My delta-labs.org snippets do expire
Top
mike155
Advocate
Advocate
Posts: 4438
Joined: Fri Sep 17, 2010 11:33 pm
Location: Frankfurt, Germany

  • Quote

Post by mike155 » Sun May 03, 2020 4:38 pm

I'm so used to press the 'cursor up/down' keys a couple of times that everything else seems too complicated. Even the PgUp/PgDown keys are too far away... :)
Top
Banana
Administrator
Administrator
User avatar
Posts: 2388
Joined: Fri May 21, 2004 12:02 pm
Location: Germany
Contact:
Contact Banana
Website

  • Quote

Post by Banana » Sun May 03, 2020 6:39 pm

ok, what's next?
Typing to complicated? :-)
Forum Guidelines

PFL - Portage file list - find which package a file or command belongs to.
My delta-labs.org snippets do expire
Top
Jaglover
Watchman
Watchman
User avatar
Posts: 8291
Joined: Sun May 29, 2005 1:57 am
Location: Saint Amant, Acadiana

  • Quote

Post by Jaglover » Sun May 03, 2020 6:55 pm

Methinks Amazon has this Alexa thing? How about porting it. You tell Amazon what you want and they type it in for you. They will also record and store everything you do, all for your convenience. :twisted:
My Gentoo installation notes.
Please learn how to denote units correctly!
Top
mv
Watchman
Watchman
User avatar
Posts: 6795
Joined: Wed Apr 20, 2005 12:12 pm

  • Quote

Post by mv » Sun May 03, 2020 7:31 pm

zsh-autosuggestions
Top
Makersmarx
n00b
n00b
User avatar
Posts: 58
Joined: Sat Feb 16, 2019 12:32 am
Location: Costa Rica

  • Quote

Post by Makersmarx » Sun May 03, 2020 7:40 pm

mike155 wrote:I'm so used to press the 'cursor up/down' keys a couple of times that everything else seems too complicated. Even the PgUp/PgDown keys are too far away... :)

Agree with this or just ctl + R as I am easy to please
Pura Vida
Top
mikefot
l33t
l33t
Posts: 709
Joined: Wed Nov 19, 2014 5:34 pm

  • Quote

Post by mikefot » Mon May 04, 2020 11:15 am

Many thanks for all the feedback and suggestions on this.

When I ran the command with the list of individual commands separated by semi colons the history
algorithm strung them all together in one long expression with semi colons in between like a wrapped around daisy chain.

It works a treat.

I have rerun it several times after booting into the debian OS that I put gentoo on inthe chroot environment.

I recommend it.

The Alexa suggestion sounds good. I am sure you could have some fun with that.....

Cheers

MF
Top
Post Reply

14 posts • Page 1 of 1

Return to “Other Things Gentoo”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic