Tips tagged history


8

Tip #768   Stream shell commands to Twitter

When I read the tip yesterday (Twitter from the terminal), I thought it would be fun to set something up to tweet all the commands I enter. After a bit of playing around I have come up with the following:

First you'll need to create a script, it doesn't matter what you call it, just remember the name and path to it for later.

Read more »

7

Tip #534   Adding times to the history

Typically when one types the history command, it displays the command number and the command. For auditing purposes it would be helpful to display the timestamp as well. To do so we need to set the environmental variable HISTTIMEFORMAT.

HISTTIMEFORMAT supports format strings of strftime.

Some important format strings:

%T Replaced by the time ( %H : %M : %S )
%F Equivalent to %Y - %m - %d

Read more »

12

Tip #247   See your favorite commands

Use the following to see the commands you use most often based on your shell history:

Read more »

-9

Tip #233   Remove numbers from history

Use the following command to give a history listing without the numbers for easier copy and pasting:

Read more »

20

Tip #194   Fix the previous command

If, like me, you often make mistakes on the command line, try using the history shortcut '^^' to repeat the last command with changes.

For example:

Read more »

17

Tip #180   Permanent bash history

Often I find myself using Ctrl-R in Bash to get an old command, only to find that too many days have passed and it's no longer in the .bash_history file.

It is possible to increase the number of lines in the history file, but there can always be a moment when you'll need a long command from many months ago. The solution below uses the PROMPT_COMMAND variable, a command that bash executes before showing each prompt. Here are the two lines to add to your profile:

Read more »

1

Tip #179   Disable bash history

Disable history for a particular account in bash with:

(in home dir)

Read more »

199

Tip #24  

Don't search history by grepping ~/.bash_history, or repeatedly hitting the up arrow, instead use CTRL+r (or '/' in vi-mode) for search-as-you type. You can immediately run the command by pressing Enter. Read more »

16

Tip #25  

Instead of adding a prefix to the previous command with 'Up-arrow Home prefix Space' try 'prefix !!' to repeat the last command with 'prefix ' before it.
You can also use '!-n' to use commands other than the most recent. Read more »

311

Tip #26  

Running a second command with the same arguments as the previous command, use '!*' to repeat all arguments or '!:2' to use the second argument. '!$' uses the final argument.

Read more »