View previous topic :: View next topic |
Author |
Message |
_______0 Guru
Joined: 15 Oct 2012 Posts: 521
|
Posted: Sun Oct 27, 2013 12:28 pm Post subject: backspace with cat? |
|
|
hi,
I've noticed that cat has a shortcoming, when I write something quick I can't delete or go back to previous lines.
Is there a way to enable line navigation with cat? Where arrows and backspacing over to the previous line works?
thanks. |
|
Back to top |
|
|
khayyam Watchman
Joined: 07 Jun 2012 Posts: 6227 Location: Room 101
|
Posted: Sun Oct 27, 2013 5:02 pm Post subject: |
|
|
_______0 ...
cat isn't an editor (and so provides no line editing) but as the shell provides line editing it can be used in such cases:
Code: | zsh% cat << EOF >| out
heredoc> hello
heredoc> this is wrong
heredoc> goodbye
heredoc> EOF <return>
<page up> history ... navigate and correct text
<return>
zsh% cat out
hello
this is right
goodbye |
best ... khay |
|
Back to top |
|
|
_______0 Guru
Joined: 15 Oct 2012 Posts: 521
|
Posted: Sun Oct 27, 2013 5:33 pm Post subject: |
|
|
thanks,
I just realized my page up/down ,start/end keys are messed up by some obscure zsh option :/
They switch from lower to upper case. And by the way ctrl-c doesn't save the document. |
|
Back to top |
|
|
khayyam Watchman
Joined: 07 Jun 2012 Posts: 6227 Location: Room 101
|
Posted: Mon Oct 28, 2013 5:32 pm Post subject: |
|
|
_______0 wrote: | I just realized my page up/down, start/end keys are messed up by some obscure zsh option. They switch from lower to upper case. And by the way ctrl-c doesn't save the document. |
ok ... well, without looking at your $zdotdir/.z{shrc,profile} its hard to see what may be causing this ... up-case-word is bound to "^[u" in emacs mode so it may be that this is what your keymap is sending with page-up.
All you need do is create a functional set of keybindings that match whatever the kbd is sending, ie, you could use terminfo to provide the matching key and bind it:
Code: | typeset -A key
key[PageUp]=${terminfo[kpp]}
key[PageDown]=${terminfo[knp]}
[[ -n "${key[PageUp]}" ]] && bindkey "${key[PageUp]}" up-line-or-history
[[ -n "${key[PageDown]}" ]] && bindkey "${key[PageDown]}" down-line-or-history |
There is also the 'zkbd' utility which can be used to create an entire set of keybindings, see: man zshcontrib | less -p "^ *Keyboard"
As for 'cntl-c', that would be perfectly consistent, your canceling the operation and so obviously no action is taken.
Just a thought, are you using oh-my-zsh? If so, then don't ...
best ... khay |
|
Back to top |
|
|
|