You are not logged in.

#1 2006-06-22 03:49:12

nogoma
Member
From: Cranston, RI
Registered: 2006-03-01
Posts: 217

zsh, wmii, aterm

I recently moved to wmii, but have encountered a problem with aterm and zsh. Most ctrl-<key> keys don't seem to be working properly; for instance (and most annoyingly to me) ctrl-r doesn't initiate a reverse history lookup (it does nothing), and ctrl-n and ctrl-p simple echo "^N" and "^P", respectively. If I use bash, it works fine. I previously used KDE, and when using zsh under konsole there, things worked fine. HOWEVER, it doesn't work when using konsole under wmii! I went back and discovered ctrl-r and such don't work with aterm under KDE, either. Interestingly (or perhaps not), if I ssh from zsh under aterm onto my desktop (also zsh), ctrl-r works just fine. Hopefully this is some simple config stuff I'm just unfamiliar with, but google/forum search hasn't been particularly helpful.

-nogoma


-nogoma
---
Code Happy, Code Ruby!
http://www.last.fm/user/nogoma/

Offline

#2 2006-06-22 15:29:42

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: zsh, wmii, aterm

That's because zsh doesn't use readline.  All those keybindings are readline keys.  It's a limitation of zsh, and you'll have to find a way to rebind them manually.

Offline

#3 2006-06-22 16:02:42

nogoma
Member
From: Cranston, RI
Registered: 2006-03-01
Posts: 217

Re: zsh, wmii, aterm

Ah, interesting. Yeah, I see now that bindkey'ing helps here (perhaps a little more investigation on my part would have revealed this last night  :oops: ). I was wondering why the short cuts work properly under Konsole while running KDE, but whatever. Also, googling around for "zsh readline" revealed "bindkey -v" unto me, which is intensely exciting to me as a vim user, but also horribly confusing wink . Does anybody use this mode successfully, and if so, got any tips or sample .zshrc that work well here?

-nogoma


-nogoma
---
Code Happy, Code Ruby!
http://www.last.fm/user/nogoma/

Offline

#4 2006-06-22 19:22:54

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: zsh, wmii, aterm

nogoma wrote:

Ah, interesting. Yeah, I see now that bindkey'ing helps here (perhaps a little more investigation on my part would have revealed this last night  :oops: ). I was wondering why the short cuts work properly under Konsole while running KDE, but whatever. Also, googling around for "zsh readline" revealed "bindkey -v" unto me, which is intensely exciting to me as a vim user, but also horribly confusing wink . Does anybody use this mode successfully, and if so, got any tips or sample .zshrc that work well here?

-nogoma

You can do the same thing in bash with

set -o vi

I tried it for a few weeks, but it's hard to use as there's no real visual indication when you are in normal/insert mode.  If there was, I'd be in love.

Offline

#5 2006-06-23 01:10:52

codemac
Member
From: Cliche Tech Place
Registered: 2005-05-13
Posts: 794
Website

Re: zsh, wmii, aterm

uh, zle = great.  use a .zshenv file to get that stuff.  It can also go in your .zshrc, but that's not the expected place.  And phrakture, I have a visiual indication of normal and insert with zsh.  Maybe it's time for you to change :-*  kidding kidding... stick with your slow bash_completion.

.zshenv

set show-all-if-ambiguous on
set match-hidden-files off
set expand-tilde off
set print-completion-horizontally on
set completion-query-item 300
set visible-stats on

bindkey "e[1~" beginning-of-line
bindkey "e[7~" beginning-of-line
bindkey "e[8~" end-of-line
bindkey "e[4~" end-of-line
bindkey "e[3~" delete-char

bindkey "e[5~" beginning-of-history
bindkey "e[6~" end-of-history

.zsh/zle

# vi keybindings
bindkey -v

bindkey -M vicmd "^R" redo
bindkey -M vicmd "u" undo
bindkey -M vicmd "ga" what-cursor-position

unsetopt promptcr


redisplay() {
   builtin zle .redisplay
   ( true ; show_mode "INSERT") &!
}
redisplay2() {
   builtin zle .redisplay
   (true ; show_mode "NORMAL") &!
}
zle -N redisplay
zle -N redisplay2
bindkey -M viins "^X^R" redisplay
bindkey -M vicmd "^X^R" redisplay2

screenclear () {
   echo -n "33[2J33[400H"
   builtin zle .redisplay
   (true ; show_mode "INSERT") &!
}
zle -N screenclear
bindkey "" screenclear

screenclearx () {
   repeat 2 print 
   local MYLINE="$LBUFFER$RBUFFER"
   highlight $MYLINE
   repeat 4 print 
   builtin zle redisplay
}
zle -N screenclearx
bindkey "^Xl" screenclearx

show_mode() {
   local COL
   local x
   COL=$[COLUMNS-3]
   COL=$[COL-$#1]
   x=$(echo $PREBUFFER | wc -l )
   x=$[x+1]
   echo -n "7[$x;A[0;G"
   echo -n ""
   echo -n "[0;37;44m--$1--[0m"
   echo -n "8"
}

zmodload zsh/parameter

###       vi-add-eol (unbound) (A) (unbound)
###              Move  to the end of the line and enter insert mode.

vi-add-eol() {
   show_mode "INSERT"
   builtin zle .vi-add-eol
}
zle -N vi-add-eol
bindkey -M vicmd "A" vi-add-eol

###       vi-add-next (unbound) (a) (unbound)
###              Enter insert mode after the  current  cursor  posi-
###              tion, without changing lines.
vi-add-next() {
   show_mode "INSERT"
   builtin zle .vi-add-next
   # OLDLBUFFER=$LBUFFER
   # OLDRBUFFER=$RBUFFER
   # NNUMERIC=$NUMERIC
   # bindkey -M viins "" vi-cmd-mode-a
}
zle -N vi-add-next
bindkey -M vicmd "a" vi-add-next


###       vi-change (unbound) (c) (unbound)
###              Read a movement command from the keyboard, and kill
###              from  the  cursor  position  to the endpoint of the
###              movement.  Then enter insert mode.  If the  command
###              is vi-change, change the current line.

vi-change() {
   show_mode "INSERT"
   builtin zle .vi-change
}
zle -N vi-change
bindkey -M vicmd "c" vi-change

###       vi-change-eol (unbound) (C) (unbound)
###              Kill  to the end of the line and enter insert mode.

vi-change-eol() {
   show_mode "INSERT"
   builtin zle .vi-change-eol
}
zle -N vi-change-eol
bindkey -M vicmd "C" vi-change-eol

###       vi-change-whole-line (unbound) (S) (unbound)
###              Kill the current line and enter insert mode.

vi-change-whole-line() {
   show_mode "INSERT"
   builtin zle .vi-change-whole-line
}
zle -N vi-change-whole-line
bindkey -M vicmd "S" vi-change-whole-line

###       vi-insert (unbound) (i) (unbound)
###              Enter insert mode.

vi-insert() {
   show_mode "INSERT"
   builtin zle .vi-insert
}
zle -N vi-insert
bindkey -M vicmd "i" vi-insert

###       vi-insert-bol (unbound) (I) (unbound)
###              Move to the first non-blank character on  the  line
###              and enter insert mode.

vi-insert-bol() {
   show_mode "INSERT"
   builtin zle .vi-insert-bol
}
zle -N vi-insert-bol
bindkey -M vicmd "I" vi-insert-bol

###       vi-open-line-above (unbound) (O) (unbound)
###              Open a line above the cursor and enter insert mode.

vi-open-line-above() {
   show_mode "INSERT"
   builtin zle .vi-open-line-above
}
zle -N vi-open-line-above
bindkey -M vicmd "O" vi-open-line-above

###       vi-open-line-below (unbound) (o) (unbound)
###              Open a line below the cursor and enter insert mode.

vi-open-line-below() {
   show_mode "INSERT"
   builtin zle .vi-open-line-below
}
zle -N vi-open-line-below
bindkey -M vicmd "o" vi-open-line-below

###       vi-substitute (unbound) (s) (unbound)
###              Substitute the next character(s).

vi-substitute() {
   show_mode "INSERT"
   builtin zle .vi-substitute
}
zle -N vi-substitute
bindkey -M vicmd "s" vi-substitute


###       vi-replace (unbound) (R) (unbound)
###              Enter overwrite mode.
###

vi-replace() {
   show_mode "REPLACE"
   builtin zle .vi-replace
}
zle -N vi-replace
bindkey -M vicmd "R" vi-replace

###       vi-cmd-mode (^X^V) (unbound) (^[)
###              Enter  command  mode;  that  is, select the `vicmd'
###              keymap.  Yes, this is bound  by  default  in  emacs
###              mode.

vi-cmd-mode() {
   show_mode "NORMAL"
   builtin zle .vi-cmd-mode
}
zle -N vi-cmd-mode
bindkey -M viins "" vi-cmd-mode



###       vi-oper-swap-case
###              Read a movement command from the keyboard, and swap
###              the case of all characters from the cursor position
###              to the endpoint of the movement.  If  the  movement
###              command  is vi-oper-swap-case, swap the case of all
###              characters on the current line.
###

bindkey -M vicmd "g~" vi-oper-swap-case

.zsh/zle is a custom filename, you have to source it in your .zshrc with '. ~/.zsh/zle'

Offline

#6 2006-06-23 03:54:09

nogoma
Member
From: Cranston, RI
Registered: 2006-03-01
Posts: 217

Re: zsh, wmii, aterm

Man, this is fantastic. I'm loving it already. I was wondering if there was a method of doing incremental history searches -- for example, w/ emacs bindings, I hit "^R" and it shows most recent match as I type; and when I'm actually using vim, when I do /foo in command mode, it incrementally searches. With bindkey -v, however, I find I have to go into cmd mode, hit "s/", type the string I want to search for and hit enter to get the first match, then use "n" and "N" to move through the matches in the history. I don't really know why I care, I'm just used to it, I guess.


-nogoma
---
Code Happy, Code Ruby!
http://www.last.fm/user/nogoma/

Offline

#7 2006-06-23 04:59:51

codemac
Member
From: Cliche Tech Place
Registered: 2005-05-13
Posts: 794
Website

Re: zsh, wmii, aterm

bindkey "^p" history-beginning-search-backward
bindkey "^n" history-beginning-search-forward

Have a good one :-D

Offline

Board footer

Powered by FluxBB