sunaku / wmiirc

Ruby configuration for WMII window manager
ISC License
82 stars 26 forks source link

Error in launching a terminal when directory does not exist #22

Closed adityam closed 13 years ago

adityam commented 13 years ago

I use wmii with zsh. Zsh allows one to create named directories. I have a directory called ecse321 in my .zshrc. This allows me to use

cd ~ecse321

to cd to the path that ecse321 points to. Of course, other programs, like wmii and Ruby do not know about these path. This however causes wmii to hang. To reproduce this:

  1. Launch an xterm with title "Terminal: ~ecse321". (This will depend on your setup ...). Make sure that there is no user with the name "ecse321".
  2. Use Mod+Enter to launch a new terminal.

Wmii stops responding to all keyboard events. You can still use the mouse to move to different clients on the current view, but cannot change the view. The wmiirc.log file says

E, [2011-02-28T15:41:21.696664 #32706] ERROR -- : user ecse321 doesn't exist (ArgumentError)
/home/adityam/.wmii-hg/control/action/launch.yaml:control:keyboard_action:launch_terminal:23:in `expand_path'
/home/adityam/.wmii-hg/control/action/launch.yaml:control:keyboard_action:launch_terminal:23:in `block (4 levels) in control'
/home/adityam/.wmii-hg/control/action/launch.yaml:control:keyboard_action:launch_terminal:12:in `reverse_each'
/home/adityam/.wmii-hg/control/action/launch.yaml:control:keyboard_action:launch_terminal:12:in `block (3 levels) in control'
/home/adityam/.wmii-hg/lib/wmiirc/handler.rb:20:in `call'
/home/adityam/.wmii-hg/lib/wmiirc/handler.rb:20:in `block in handle'
/home/adityam/.wmii-hg/lib/wmiirc/handler.rb:19:in `each'
/home/adityam/.wmii-hg/lib/wmiirc/handler.rb:19:in `handle'
/home/adityam/.wmii-hg/lib/wmiirc/handler.rb:73:in `key'
/home/adityam/.wmii-hg/lib/wmiirc/config.rb:100:in `block (2 levels) in control'
/home/adityam/.wmii-hg/lib/wmiirc/handler.rb:20:in `call'
/home/adityam/.wmii-hg/lib/wmiirc/handler.rb:20:in `block in handle'
/home/adityam/.wmii-hg/lib/wmiirc/handler.rb:19:in `each'
/home/adityam/.wmii-hg/lib/wmiirc/handler.rb:19:in `handle'
/home/adityam/.wmii-hg/lib/wmiirc/handler.rb:39:in `event'
/home/adityam/.wmii-hg/lib/wmiirc/loader.rb:94:in `block (2 levels) in enter_event_loop'
/home/adityam/.wmii-hg/lib/wmiirc/loader.rb:90:in `each'
/home/adityam/.wmii-hg/lib/wmiirc/loader.rb:90:in `block in enter_event_loop'
/usr/lib/ruby/gems/1.9.1/gems/rumai-4.0.0/lib/rumai/fs.rb:105:in `each_line'
/usr/lib/ruby/gems/1.9.1/gems/rumai-4.0.0/lib/rumai/fs.rb:105:in `block in each_line'
/usr/lib/ruby/gems/1.9.1/gems/rumai-4.0.0/lib/rumai/ixp/transport.rb:220:in `open'
/usr/lib/ruby/gems/1.9.1/gems/rumai-4.0.0/lib/rumai/fs.rb:84:in `open'
/usr/lib/ruby/gems/1.9.1/gems/rumai-4.0.0/lib/rumai/fs.rb:103:in `each_line'
/home/adityam/.wmii-hg/lib/wmiirc/loader.rb:89:in `enter_event_loop'
/home/adityam/.wmii-hg/lib/wmiirc/loader.rb:15:in `run'
/home/adityam/.wmii-hg/wmiirc:5:in `
' I, [2011-02-28T15:41:21.758462 #32706] INFO -- : stop

Any ideas on how to avoid this?

sunaku commented 13 years ago

Does ZSH expand the named directory in your prompt (the %~ token)?

adityam commented 13 years ago

Yes it does. After

cd ~ecse321

the prompt says

adityam@adi-netbook:~ecse321$ 

and the xterm title says

Terminal: ~ecse321
adityam commented 13 years ago

In case it was not clear in the original request, I do not want wmii to know about the zsh named directories. I am OK with Mod-Enter just ignoring non-existing directories like ~ecse321. It should not hang the system.

sunaku commented 13 years ago

Since your prompt expands the named directory, try overriding the default terminal title function with your own that uses %~. Here is an example: https://github.com/sunaku/home/blob/master/.zshrc#L49

adityam commented 13 years ago

I misunderstood the word "expand" in your previous question. The shell does not expand ~ecse321 to its full path; it just shows it as ~ecse321. Looking at http://zsh.sourceforge.net/Doc/Release/Expansion.html#SEC77 it appears that this is on purpose.

My .zshrc already contains:

if [ -z "$DISPLAY" ] ; then ; else 
  # Set xterm title to command name
  preexec () { 
    if [ -z "$(ps | grep vim)" ] ;
    then 
      print -Pn "\e]2;$1\a"
    fi }
  # reset xterm title
  precmd  () { 
    if [ -z "$(ps | grep vim)" ] ;
    then 
      print -Pn "\e]2;Terminal: %~\a" 
    fi }
fi
sunaku commented 13 years ago

Try using %/ (which expands into an absolute path of $PWD) instead of %~ in your pre* functions.

adityam commented 13 years ago

Works perfectly. Thank you for your support on this non-wmii issue.