The line editor in shells and other command line programs

learn more… | top users | synonyms

2
votes
1answer
29 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 ...
0
votes
2answers
29 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-...
2
votes
1answer
39 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-...
1
vote
1answer
23 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 ^...
2
votes
3answers
753 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 (...
25
votes
2answers
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
4answers
845 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
2answers
61 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 ...
3
votes
2answers
193 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 ...
32
votes
1answer
1k 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+{ , ...
4
votes
1answer
62 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 ...
3
votes
2answers
80 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
0answers
57 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
1answer
45 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 ...
0
votes
0answers
35 views

Ctrl + y on shell terminal, paste from system clipboard [duplicate]

I use emacs style bindings for my bash terminal. And i use only the system clipboard and never use any of the application specific/primary selection stuff. When i copy text from emacs window and use ...
1
vote
1answer
48 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; ...
3
votes
1answer
209 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
1answer
86 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....
1
vote
1answer
180 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
3answers
188 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: ...
1
vote
1answer
167 views

Ctrl-Y, emacs styled yank text is not working when user is switched

I cut the bash command line text using Ctrl+K. The line was cut as expected. Next, I ran sudo su to become the root user. I tried to paste the command that I cut as the non-sudo user using Ctrl+Y. ...
2
votes
5answers
197 views

Adjust gap between 2 columns to make them look straight

file1.txt: hi wonderful amazing sorry superman superhumanwith loss file2.txt : 1 2 3 4 5 6 7 When i try to combine using paste -d" " file1.txt file2.txt > actualout.txt actualout.txt : hi 1 ...
1
vote
2answers
34 views

Addition of values

foo.txt: Lillypaul_sg 204803 204803 204803 Ammy_sg 3 ramaswamy_sg 3 33 tommy_sg 3 3 137374 100 Desired Out.txt : Lillypaul_sg 614409 Ammy_sg 3 ramaswamy_sg 36 tommy_sg 137480 The output is a sum ...
4
votes
0answers
146 views

Bash command not found due to stray garbage characters

What is the cause of this behavior? $ cd ../ $ bash: $'\210\210cd': command not found This happens sometimes (rarely) when I enter a command, there is no visible character preceding the cd, still ...
1
vote
1answer
283 views

Read a line with default input in zsh

This function can be used to help user input a modification of some text. function change { bash -c "read -ei \"$1\" temp && echo \$temp" } What is idiomatic zsh way to do something ...
1
vote
1answer
198 views

Enable cursor keys in python shell over ssh

I run OpenElec on a Pi. I can ssh to the Pi and open a python shell. How do I enable the cursor keys to work like up getting to last command in the python shell, like it does on my Ubuntu box. Now ...
0
votes
1answer
101 views

How to switch from input mode into command mode in ed ?

As far as I know, ed starts in command mode. Once I input i,a or c ed changes into input mode. So far it worked. Now I read that in order to switch from input mode into command mode one has to input ",...
3
votes
2answers
233 views

How do I swap the two last command line arguments?

$ ln -s ./dir/target.txt /path/to/source.txt{cursor here} How do swap file typed filenames in command line? Alt+T swaps words, not filenames, resulting in ln -s ./dir/target.txt /path/to/txt.source. ...
2
votes
0answers
79 views

Why does select-word-style stop me from using backward-kill-word for leading whitespace?

If I have just some whitespace at be beginning of my zsh prompt, I can usually ^W (backward-kill-word) it away. However, as soon as I load select-word-style - even if I don't select any special style -...
3
votes
2answers
170 views

Command to output to current prompt

Is there any command that will output text to the (next) command prompt? I would like to write a function, which upon execution, will perform some commands and then "suggest" the next command to be ...
5
votes
1answer
203 views

Keep the space after completion for some characters in zsh

Zsh has a bit of completion-related automation that's nice most of the time: after pressing Tab, a space is inserted automatically (or some other appropriate character such as , inside braces). I ...
2
votes
2answers
81 views

clipboard in bash

We can cut and paste current line in bash with ctl+u and ctl+y But I have read here that bash doesn't have clipboard concept, so how those shortkeys working? (or in another way: what they doing?)
1
vote
2answers
307 views

How to delete a word next of last slash

I have the following path : $ vim /path/to/some/where If I press Ctrl + w, It removes entire text to first space. The result would be : $ vim How do I delete just the word next of last slash ...
1
vote
2answers
138 views

Map Return with no other input to an alias

I would like to use Return with no other input to run an aliased command in the shell. Is this possible in Bash or Zsh? In other words, when I enter an empty command line, I want to run one specific ...
1
vote
1answer
96 views

Key to comment out the current line and keep editing it in zsh

On Bash I was using ESC # after Ctrl+R to prefix a # to the found line and keep it in the terminal, something similar for zsh?
1
vote
3answers
242 views

How to transpose command line arguments with emacs keybindings?

Using Bash, with emacs keybindings set, the transpose-words keybinding (M-t) doesn't transpose arguments, but "words" (by its own definition of words). So if I have this: vimdiff project-number-One/...
8
votes
2answers
320 views

How to stop bash editing the history when I reuse and modify an entry?

Some instances of bash change the command history when you re-use and edit a previous command, others apparently don't. I've been searching and searching but can't find anything that says how to ...
3
votes
3answers
3k views

How to handle backspace while reading?

How do I handle the backspaces entered, it shows ^? if tried & how read counts the characters, as in 12^?3 already 5 characters were complete(though all of them were not actual input), but after ...
4
votes
2answers
165 views

Why does tmux fail to “scroll” when entering a command that exceeds one line? (OSX Terminal.app)

When I use tmux and enter a command that exceeds the line, it fails to redraw the previous line. It simply clears the current line and I can't see what I just wrote. It does only redraw the first line....
4
votes
5answers
11k views

How to add text to end of line when pattern is matched?

inputs: line1 with the PATTERN that contains ( ) line2 with the PATTERN that contains ( ) lineN with the PATTERN that contains ( ) outputs: line1 with the PATTERN that contains ( ) ; line2 with ...
2
votes
5answers
2k views

How can I delete input in the terminal?

Xubuntu 13.10 Say I paste a command, something like sudo apt-get install abc yxz 123 DEF MMM KKK into the terminal. Then I suddenly had a change in mind and thus I would like to delete the last 3 ...
8
votes
3answers
327 views

Clear / erase a mistyped password in a terminal

One thing that annoys me using Linux's terminal is when I have to type a invisble password, like when you run ssh the terminal I was wondering if there's a way to clear/erase the invisible password ...
2
votes
1answer
179 views

Simulating READLINE_LINE in Bash < 4.0

I am trying to make some of my code bash 3.X compatible and I have a key-binding that utilizes READLINE_LINE inside its callback function. 3.0 versions of Bash don't supply the READLINE_LINE, so I ...
3
votes
3answers
2k views

rlwrap: mysql autocompletion not working

Normally, autocompletion works fine in mysql command-line client (mysql-client-5.5). I have a table called booking. When I type the letter b and pres TAB the name of my table gets autocompleted: ...
11
votes
1answer
3k views

First characters of the command repeated in the display when completing

The first two chars were repeated while I use Tab to do completion. In the screenshot below, cd is repeated. I have tried rxvt-unicdoe, xterm, terminator. All these terminal emulators have this ...
0
votes
1answer
651 views

In tcsh shell how I find a particular word in the command prompt?

Suppose I have the following line in my command prompt and the cursor is at the and of the line or the beginning of the line by using (CTRL+A) [subhrcho@slc04lyo pcbpel]$ abc def ghi jkl How can I ...
3
votes
1answer
214 views

Where is the bash feature to open a command in $EDITOR documented?

I have recently discovered that if we press Ctrl+X Ctrl+E, bash opens the current command in an editor (set in $VISUAL or $EDITOR) and executes it when the editor is closed. But it doesen't seem to be ...
1
vote
1answer
1k views

How can I move between words in the command prompt in tcsh in linux?

I want a feature like vim's going forward or backwards command (w,e,ge,b) etc in the shell prompt. I am using tcsh shell in Linux. I would like to go 'n' number of words backs or forward etc and do ...
6
votes
1answer
395 views

can you make zsh autocorrect smarter?

I like zsh autocorrect, but it keeps asking me about things that don't need correcting. dzil build zsh: correct 'build' to '.build' [nyae]? % .build is a directory created by the build (or any ...
3
votes
1answer
739 views

How can I clear portion of what is typed into the prompt while working on Linux and using C-shell?

I am working in Linux and C-shell. Often times I would require to change some portion of what is there already in the prompt that I obtain from reverse searching through the history command by use of ...