Questions tagged [line-editor]
The line editor in shells and other command line programs
100
questions
1
vote
2
answers
147
views
bindkey commands run in .zshrc seem ignored when in tmux
I have some bindkey commands in my .zshrc file which behave as desired.
I start tmux; the same .zshrc is run, including the bindkeys but they don't function.
But then if I manually type them on the ...
1
vote
2
answers
637
views
How to prevent zsh path completion magic until I press TAB?
I have a hobby server with a significant numbr of USB hard drives. I have aggressive power management enabled, and a short spin-down timeout, as these drives are basically meant to be cold storage ...
2
votes
1
answer
460
views
history-search-end doesn't work
My ~/.zshrc:
setopt histignoredups
autoload -U history-search-end
zle -N history-beginning-search-backward-end history-search-end
zle -N history-beginning-search-forward-end history-search-end
bindkey ...
3
votes
1
answer
38
views
How to execute ctrl+r query as-is instead of a match?
Sometimes when I reverse-search cmd in a shell I don't find a correct match and just want to execute search query as it is.
Is there a way in bash/zsh and friends to execute it without discarding ...
1
vote
2
answers
257
views
How do I figure out what just broke my zsh shell beginning-of-line and end-of-line bindings?
I am on macOS/darwin using a "default settings" zsh environment (no "oh-my-zsh" or any of that).
Some developer tool I just installed apparently broke some keybinds that I use ...
2
votes
4
answers
857
views
Use substitution to delete everything up to a point on a line
I want to use a global substitution in Vim to delete everything up to https.
Before
The website is https://website.com
The website is https://website.com
The website is https://website.com
After
...
1
vote
1
answer
110
views
Run line editing for user input (script command)
I used the script program to record an interactive session:
$ script
$ echo<-<-<-<-printf "hello\n"
$ exit
The sequence <- is representing the backspace character.
I want the ...
1
vote
1
answer
825
views
What is the difference between `set -o emacs` vs `bindkey -e`?
From what I have seen, both set -o emacs and bindkey -e are used to modify the behavior of your terminal line editor to emulate emacs whereas set -o vi and bindkey -v are used to emulate vi ...
1
vote
1
answer
459
views
Physical buffer in terminal is getting misaligned with display in oh-my-zsh configuration
I have been experiencing an unusual problem in the oh-my-zsh configuration in which the cursor gets out of sync with the text. (I normally work using screen in konsole.
For instance on a new terminal ...
0
votes
1
answer
440
views
zsh with vi-mode: How to keep a command line for future use without executing
It happens quite often to me, that while entering a complex command I realize that I need to enter some other commands first.
Being a vi user, I'd love to 0 D, enter a different command and later ...
3
votes
2
answers
533
views
edit-and-execute-command interrupted by SIGTSTP
I've been using bash's edit-and-execute-command function:
edit-and-execute-command (C-x C-e)
Invoke an editor on the current command line, and execute the result as shell commands. Bash ...
1
vote
2
answers
1k
views
How to insert Line break regex
I have a file which contains one line like this
test1.CSV test2.CSV test3.CSV test4.CSV...
I want to put a line break after each .CSV file name like so
test1.CSV
test2.CSV
test3.CSV
test4.CSV
...
4
votes
2
answers
3k
views
Alt + . (dot) shows &, instead of a previous argument
I (ab)use Alt + . to recover the last argument in a previous command (I'm using ZSH): for example,
$ convert img.png img.pdf
$ llpp (alt + .) # which produces llpp img.pdf
but sometimes I review a ...
4
votes
4
answers
728
views
Zsh refer to last element of current argument list and expand it
Suppose I do something like:
ln a_file_with_a_long_filename.pdf ~/path/to/a/new/hardlink/a_file_with_a_long_filename_slightly_modified.pdf
Is there a way to refer to and expand ...
1
vote
2
answers
824
views
CLI: Editing binary strings
There's a nice CLI binutils utility for interpreting binary files, and outputting legible strings, in a cat-like fashion. It's called strings.
If you try to cat a binary file, you'll see a bunch of ...
1
vote
1
answer
93
views
Changing to ancestor directory without typing all the dots and slashes
In zsh, how do I refer to the grandparent directory with ... rather than
../.., and so forth? I used to have this in oh-my-zsh and prezto.
PS. Ideally, M-3 . should yield ../../...
7
votes
2
answers
1k
views
zsh line editor: Can I navigate and edit by argument?
I have a common situation in the shell when a command is attempted
command "/some/complex/and terrible/path" -vf --various --flags --and -- things --config-file="/some other/annoyingly/...
0
votes
1
answer
160
views
zsh command line editing problems when reverse-searching the history fixed by ctrl-l [closed]
In zsh, using oh-my-zsh and the robby-russell theme, under Fedora Core 23, I noticed that when I reverse-searched for commands in the command history and tried to edit the results, the display would ...
3
votes
1
answer
234
views
Is it possible to do live text-replace in shell?
I run zsh on my machine. I was wondering if I can do text-replace in shell. For example fn[SPACE/TAB]should be replaced with function. On OSX there is the option of keyboard-shortcuts but they don't ...
3
votes
1
answer
1k
views
Non-anchored history substring search in bash
There are 2 existing ways to get something like this easily:
zsh's history-substring-search plugin
bash's ctrl+r mode
The problem with zsh is that it's not on many systems. The problem with bash's ...
1
vote
1
answer
89
views
Bash and/or Zsh: Is it possible to customize the Vi insert mode to create a bind that moves a specific number of characters?
I have a Vim configuration that is somewhat unconventional. I bind Shift+H and Shift+L to move left by 7 characters and move right by 7 characters, respectively. This makes it easier for my brain to ...
1
vote
1
answer
161
views
Line editing (readline?) with virtual keys
I want to bind terminal behavior to hotkeys without having to define escape sequences.
I understand readline binds to characters instead of actual key presses. Can it also bind to the lower level ...
3
votes
2
answers
535
views
How to specify command arguments for bind -x based on history?
Let's say I have a command called synopsis that takes the name of a command as an argument and prints out its syntax. Now I want to bind the synopsis to a key sequence. How can I pass the name of the ...
3
votes
1
answer
790
views
Bash 4.4 bracketed-paste-mode stays on while running commands - corrupts paste
I've been using bracketed paste in VIM which is excellent for ensuring pasted content gets into the editor un-modified without triggering actions (such as auto formatting, and auto closing parenthesis)...
24
votes
5
answers
3k
views
Bash command to copy before cursor and paste after?
I am not sure how to word this, but I often I find myself typing commands like this:
cp /etc/prog/dir1/myconfig.yml /etc/prog/dir1/myconfig.yml.bak
I usually just type out the path twice (with tab ...
1
vote
1
answer
335
views
Extend vi mode to irb, postgres etc in zsh
I am using oh-my-zsh's vi-mode plugin. Its working awesomely for regular terminal usage.
How to extend this vi-mode to psql, irb etc?
In bash I used to do this by adding commands in .inputrc
I am ...
20
votes
6
answers
1k
views
How do I input n repetitions of a digit in bash, interactively
I'd like to run the command
foo --bar=baz <16 zeroes>
How do I type the 16 zeroes efficiently*? If I hold Alt and press 1 6 0 it will repeat the next thing 160 times, which is not what I want....
17
votes
2
answers
9k
views
Can I navigate zsh's tab-completion menu with vi-like hjkl keys?
I use zsh's menu-based tab completion. I press Tab once, and a list of possible completions appears. If I press Tab again, I can navigate this list with the arrow keys. However, is it possible to ...
2
votes
1
answer
358
views
MIT Scheme prompt: indent and up/down arrows
I run Scheme either as: rlwrap scheme, option which let's me use up/down left/right arrows, but that disables tab. Or as scheme option that let's me indent commands with tab, but disables the arrows.
...
1
vote
1
answer
941
views
How to get second to last parameter of previous command in bash?
I can use Esc+. to get the last parameter of the previous command, but is there an equally convenient short-cut to get the second to last parameter?
1
vote
1
answer
255
views
Up arrow at an empty prompt in ksh93
This is a request for explanation or pointer to documentation.
I'm a KornShell93 (ksh on Mac OS X or ksh93 elsewhere) user. I like the shell for its relative simplicity as an interactive shell and for ...
24
votes
1
answer
12k
views
SQLite3 command line: how do you cancel a command?
I made a mistake writing a command at the SQLite command prompt, which I now want to abort, this is how my command line looks
sqlite> select * from todos'
...> '
...> ;^C
In this case,...
0
votes
2
answers
5k
views
Insert/overwrite mode in fish
I'm using Linux Mint on a MacBook and on its keyboard the equivalent for the INSERT key is the combination Fn + RETURN.
At the moment I can only see the intended behavior of this combination in GNU-...
3
votes
1
answer
616
views
zsh tcsh-like history navigation
In tcsh, the \eP and \eN commands take into account the whitespace-normalized prefix of the current line, not just the first word.
For instance if my history contains
git pull upstream feature-...
2
votes
1
answer
873
views
Find out if ctrl+backspace equals ctrl-H or ctrl-?
This question was about how to delete the last word in bash with ctrl-backspace. As already mentioned there, different Linux distros (or different Unices in general) behave differently: Some produce ^...
3
votes
3
answers
4k
views
Why can't Korn Shell do ctrl-r?
If I use PC-BSD with the default shell (Korn) then Ctrl+r doesn't work. Why won't it work?
Ctrl-r was introduced to search your history in the late 1970s or early 80s and my BSD still can't do it (...
26
votes
2
answers
1k
views
Opening Your Command Prompt In A Text Editor - What Is This Called?
One of my favorite tricks in Bash is when I open my command prompt in a text editor. I do this (in vi mode) by pressing ESC v. When I do this, whatever is in my command prompt is now displayed in my $...
7
votes
4
answers
2k
views
Is it possible to name a part of a command to reuse it in the same command later on?
If I want to move a file called longfile from /longpath/ to /longpath/morepath/ can I do something like
mv (/longpath)/(longfile) $1/morepath/$2
i.e. can I let the bash know that it should remember ...
3
votes
2
answers
1k
views
rlwrap: tclsh multi-word autocompletion
How do I get multi-word autocompletion with rlwrap for tclsh?
Example: I type file <space> then pressing <tab> <tab> I only want to see the sub-commands to file, such as exists ...
27
votes
4
answers
29k
views
Ctrl-Backspace and Ctrl-Delete in bash
Putting on Debian 8.3
stty werase '^H'
or on Arch Linux 2/2016
stty werase '^?'
in .bashrc (for example) makes Ctrl-Backspace delete the last word in the terminal. Still it's not the same behavior ...
32
votes
1
answer
4k
views
ESC + { : What is it and where I can know more about it?
I was play around at the bash prompt, and pressed ESC followed by { , after which , the shell showed all the files for completion, in a fileglob string.
Eg : If I had typed bash C followed by ESC+{ , ...
6
votes
2
answers
1k
views
Echo text as suggested prompt in bash
Is it possible to change text that appears after $PS1. It is what user inputs. I want to suggest some command hereafter my_function is run. Of Course I should be able to modify/delete it using ...
6
votes
2
answers
2k
views
How can I undo an accidental newline in bash?
If I unintentionally add a newline in a command, as far as I can tell, the only way to undo it is to press Ctrl+c and type the command again. For example:
$ cat 'John's File'
> ^C
$ cat "John's ...
1
vote
0
answers
480
views
paste clipboard text plus string with .inputrc
I've got in my .inputrc something like
"\C-v": "script.sh "
I use a link from my clipboard as a parameter for the script, so I type ctrl-v and then paste the link, and then hit enter.
So I've seen ...
1
vote
1
answer
89
views
Some characters are filtered in bash
I'm currently running a Xubuntu image using VirtualBox and a strange issue just started occurring: I cannot enter a or c in a terminal or terminal emulator. A and C (that is, a/c + left/right Shift or ...
1
vote
1
answer
359
views
stty doesn't display backward-delete-word shortcut
stty -a
shows,
speed 38400 baud; rows 39; columns 143; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = M-^?; eol2 = M-^?; swtch = M-^?; start = ^Q; stop = ^S; susp = ^Z; rprnt ...
7
votes
1
answer
3k
views
How to cancel and keep reverse-i-search?
Often I fail to find something with reverse-i-search but want to keep what I have already written. For example, typing pdflatex fails to complete to pdflatex mydocument.tex. If I then cancel it with ...
3
votes
1
answer
231
views
Pass 'typed text' from bash interactive shell to a command
I would like to pass whatever the user has typed in a bash shell to a command, when the user presses a keyboard binding|shortcut
For example : Lets say Ctrl+b is our binding
bind '"\C-b": "myCommand....
6
votes
1
answer
1k
views
bash/gnu readline multiline command: move row up/down
How to move one editing row up (back) or down (forward) in a multi-line command in bash/readline?
Somethnig like gj/gk in Vim.
5
votes
3
answers
247
views
Output Output of command to command line directly, NOT variable [duplicate]
I am on the bash shell and I want the output of a command to appear directly in the command prompt that appears after the command has executed !
Example of what I envision it, to illustrate my idea:
...