Questions tagged [history-expansion]
The history-expansion tag has no usage guidance.
56
questions
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 ...
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
% @@
...
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?
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&...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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?
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 ...
-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 ...