Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
backspace with cat?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
_______0
Guru
Guru


Joined: 15 Oct 2012
Posts: 521

PostPosted: Sun Oct 27, 2013 12:28 pm    Post subject: backspace with cat? Reply with quote

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
View user's profile Send private message
khayyam
Advocate
Advocate


Joined: 07 Jun 2012
Posts: 2949

PostPosted: Sun Oct 27, 2013 5:02 pm    Post subject: Reply with quote

_______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
View user's profile Send private message
_______0
Guru
Guru


Joined: 15 Oct 2012
Posts: 521

PostPosted: Sun Oct 27, 2013 5:33 pm    Post subject: Reply with quote

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
View user's profile Send private message
khayyam
Advocate
Advocate


Joined: 07 Jun 2012
Posts: 2949

PostPosted: Mon Oct 28, 2013 5:32 pm    Post subject: Reply with quote

_______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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum