Skip to main content

Questions tagged [history-expansion]

The tag has no usage guidance.

7 votes
2 answers
1k views

Echoing "!" inside a string does some weird things [duplicate]

If I type in this: echo "Hello, World!" I don't know the name of it, but it prompts me for the next line. You know the PS2 thing. Or if you type echo \ and press Enter. Why? Well I know ...
Bog's user avatar
  • 1,034
0 votes
0 answers
145 views

set histchars not working in zsh

Consider the following commands for overriding the history expansion characters (which I got from Learning Shell Scripting with ZSH book): % set histchars='@^#' % ls *.txt file1.txt file2.txt % @@ ...
Attilio's user avatar
  • 365
0 votes
0 answers
242 views

History not working in bash

When I type at the bash prompt !5 ... I simply get !5: command not found ... as the response. Any ideas about what I am doing wrong? Anything I should check?
Kiwiheretic's user avatar
2 votes
1 answer
136 views

How to create alias with a caret^ command?

I have a workflow that first check git diff for specific file and then add it to stage. git diff .. ^diff^add I want to give these command a alias but this one doesn't work alias da="^diff^add&...
gary's user avatar
  • 23
2 votes
1 answer
217 views

fill in from previous command arguments

Can I make the right-arrow key fill in an argument-at-a-time from the previous command line? $ mogrify -resize 50% file.jpg $ pressing right arrow now should fill in mogrify, pressing right arrow ...
minseong's user avatar
  • 837
1 vote
1 answer
165 views

Is there a way to match history entries on multiple words/tokens of the command, when performing history expansion?

I'm working with a command-line tool that provides a number of subcommands that all use the same binary, e.g. tool foo, tool bar, etc, and as I work, these commands are placed into my Bash shell ...
nanofarad's user avatar
  • 743
4 votes
0 answers
268 views

Zsh: Is it possible to disable history expansion inside double quotes?

Is it possible to disable history expansion inside double quotes? I do not want history expansion to be completely disabled, as I still use it, but I see no reason to expand the history inside a ...
HappyFace's user avatar
  • 1,620
5 votes
4 answers
936 views

bash - get 1st argument of current command I am editing via history, or similar? [duplicate]

Often I'm writing a command in a bash prompt, where I want to get previous arguments, in the CURRENT line I'm typing out, and put in other places in the command. A simple example, would be if I want ...
Brad Parks's user avatar
  • 1,689
0 votes
0 answers
71 views

What does `echo ${!a}` do and why? [duplicate]

The following bash script prints out c, but I'm not sure why. a=b b=c echo ${!a} I believe that !a will be converted to the last command which began with a, so in this case that would be a=b. This ...
Abraham Murciano Benzadon's user avatar
0 votes
0 answers
20 views

history expansion without execution? [duplicate]

!924 will execute that line from history. Is there a syntax where I can simply pull that line from history to the current line so I can edit it: i.e.: like using the up arrow with a built in search ...
kevcoder's user avatar
  • 485
0 votes
1 answer
327 views

How to commit *nix command line history so it's available to other sessions?

What I have seen is, command line history from one session (pts) is not available to other open sessions (pts). Is it possible to explicitly commit the history of a session, so that it's available ...
samshers's user avatar
  • 688
0 votes
0 answers
104 views

history manipulation in tcsh, substitute every match

I know everybody will tell me that I should switch from using tcsh to bash or something else, but hysteresis is a powerful force, so I'm not going to. Most of the time I find tcsh perfectly ...
Leo Simon's user avatar
  • 453
3 votes
1 answer
136 views

How to refer to a command beginning with $?

Assume that the history list contains the command e='echo a b c' and then $e. How to refer to the command $e using the history expansion feature of bash?
tmpbin's user avatar
  • 783
1 vote
2 answers
215 views

View History Expansion On History

I am having to to rewrite history expansion commands, instead of calling it from history. For Example, I have to change 35 to 36, 37, 38.... in the following command. $ print -P '\033[35mThis is the ...
Ahmad Ismail's user avatar
  • 2,728
-2 votes
1 answer
5k views

How can I use passwords with bash special characters on the command line? [duplicate]

I have a command line that takes a password . The password starts with characters '!1'. E.g. '!1x9y377s' . If I execute a command with that password, then history expansion occurs and the first two ...
Brent Fisher's user avatar

15 30 50 per page