Ubuntu – Does bash (or any shell, for that matter) have an ‘overwrite’ mode

bashbash-historycommand lineshortcut-keys

I'm running similar commands on (e.g.) a set of files. As an example, let's say I'm doing something like this (this isn't what I'm doing, it's just an example):

> cat path/to/dir/file01.txt
  [file contents]
> another-command path/to/dir/file01.txt
  [more output]
> cat path2/to/dir/file02.txt
  [file contents, from which I can tell I should do something different]
> different-command path2/to/dir/file02.txt
  [yet more output]
> cat path3/to/dir/file03.txt
  [file contents]
> another-command path3/to/dir/file03.txt
  [output]

etc.

It would be convenient if, after using the key to return to a previous command, I could overwrite non-duplicated text ― like the file name, or a common part of the path — rather than having to delete it and retype it.

Is there a way to do this?

Best Answer

Bash has that but it isn't bound to any key by default.

Add the line

Control-o: overwrite-mode

to your $HOME/.inputrc or /etc/inputrc to use Ctrl+o to toggle between insert mode and override mode.

See the READLINE section in the Bash manpage for more.

Related Question