Dangerous use of 'rm'
mark at ukug.uk.freebsd.org
Mon Jul 10 21:56:07 BST 2006
Stephen Allen wrote:
> James O'Gorman wrote:
>> So alias rm to rm -i and then when you're ready to add the -rf, hit
>> up, Ctrl-A and then right arrow three times to type -rf. Surely this
>> isn't too much effort to ensure the safety of your files?
> Aha! - Now that helps a lot. Ctrl+A is used as 'Home'. I've always
> been struggling (and still am) with getting all the keymap stuff to work
> in FreeBSD properly (by properly, I mean Home/End/Del/Backspace stuff).
> Ctrl+A will do while I work on the keymaps.
If you're using the default csh/tsch shell then you could start by
adding this to ~/.cshrc
if ( $?tcsh || $?csh ) then
bindkey "^W" backward-delete-word
bindkey -k up history-search-backward
bindkey -k down history-search-forward
bindkey "^?" delete-char
bindkey "\e[3~" delete-char
bindkey "\e[1~" beginning-of-line
bindkey "\e[4~" end-of-line
which, from top to bottom, maps the following....
Ctrl-W - delete one word backwards
Up (cursor key)
Down (cursor key) - previous/next command (typing some characters first
will find the previous/next match. e.g. ls <up> will step back through
all ls commands)
Delete - Deletes the character under the cursor (both "^?" and "\e[3~"
are for this. IIRC one is needed to work in xterm and/or Konsole (in
KDE), the other for the console (i.e. not in X). It's that long since I
did this I can't remember which is which).
Home - Move cursor to beginning of line
End - Move cursor to end of line
BTW, you can find the escape sequences for keys by typing Ctrl-V
followed by the relevant key, e.g. for the PgDn key, type Ctrl-V PgDn
To use it with bindkey you replace ^[ with \e giving \e[6~
Read csh(1) and search for bindkey for info on the action/edit commands
More information about the Ukfreebsd