Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
zsh question (complaint?)
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
Beetle B.
Guru
Guru


Joined: 01 Mar 2003
Posts: 524

PostPosted: Tue Aug 05, 2008 11:18 pm    Post subject: zsh question (complaint?) Reply with quote

Trying to switch from bash to zsh. Liking a lot of it so far.

One thing I got used to in bash is that if I started a process and put it in the background:

Code:

startprog &


I could exit the shell and the process would continue to run.

In zsh, I have to use &| or &! - or use the plain & and explicitly disown the job. Is there no way to set some option somewhere such that all processes loaded with & will remain there even when leaving the shell?
_________________
Beetle B.

Please update the table of equivalents.
A Firefox guide.
Back to top
View user's profile Send private message
bunder
Bodhisattva
Bodhisattva


Joined: 10 Apr 2004
Posts: 5934

PostPosted: Tue Aug 05, 2008 11:56 pm    Post subject: Reply with quote

Moved from Off the Wall to Portage & Programming.
_________________
Neddyseagoon wrote:
The problem with leaving is that you can only do it once and it reduces your influence.

banned from #gentoo since sept 2017
Back to top
View user's profile Send private message
SiberianSniper
Guru
Guru


Joined: 06 Apr 2006
Posts: 378
Location: Dayton, OH, USA

PostPosted: Wed Aug 06, 2008 1:01 am    Post subject: Reply with quote

Not sure about zsh, since I really only use bash, but if I run process & and close the shell, it kills that process. I have to run process & disown - not sure if there's an easier way that works in both shells?
Back to top
View user's profile Send private message
cpakkala
Apprentice
Apprentice


Joined: 17 Dec 2004
Posts: 154

PostPosted: Wed Aug 06, 2008 4:00 am    Post subject: Reply with quote

nohup is meant for what you seek.

example:
Code:
nohup startprog &


Read the manpage for more details.
Back to top
View user's profile Send private message
Beetle B.
Guru
Guru


Joined: 01 Mar 2003
Posts: 524

PostPosted: Wed Aug 06, 2008 5:38 am    Post subject: Reply with quote

Hmm... OK - some inconsistency.

Maybe I was careless with my terminology.

Just to be clear - I was not talking about logging out, but merely exiting a shell.

Second, I'm not referring to stopped jobs, but jobs running in the background.

Let me explain the behavior I get on my side:

Scenario 1:

I'm in zsh.
I type 'bash' to go into a bash shell.
I type 'konqueror &'.
I type exit and it quits the bash shell and returns to zsh. konqueror is running fine.

I don't get the above behavior were it zsh. It'll complain about jobs running.

Scenario 2:

I'm in zsh.
I type 'bash' to go into a bash shell.
I type 'mutt &'.
I type exit and it complains about stopped jobs.

Both zsh and bash won't let me exit the shell if the jobs are stopped. But if they're actually running fine in the background, bash lets me leave the shell but zsh won't.

Lastly, this is all from a konsole window (I assume xterm and the like will give similar results). I don't know the behavior were I logged into a pure console. This is related to the first point: I'm not logging out - just exiting the shell.
_________________
Beetle B.

Please update the table of equivalents.
A Firefox guide.
Back to top
View user's profile Send private message
semdornus
n00b
n00b


Joined: 13 Sep 2007
Posts: 58
Location: Tokyo

PostPosted: Wed Aug 06, 2008 6:47 am    Post subject: Reply with quote

If I understand you correctly you could just "setopt nohup" in your .zshrc?
Back to top
View user's profile Send private message
Beetle B.
Guru
Guru


Joined: 01 Mar 2003
Posts: 524

PostPosted: Wed Aug 06, 2008 4:13 pm    Post subject: Reply with quote

That didn't work.

I know the SIGHUP is sent when one logs out, but is it also sent when one exits a shell?
_________________
Beetle B.

Please update the table of equivalents.
A Firefox guide.
Back to top
View user's profile Send private message
cpakkala
Apprentice
Apprentice


Joined: 17 Dec 2004
Posts: 154

PostPosted: Wed Aug 06, 2008 5:13 pm    Post subject: Reply with quote

I'm guessing konqueror in particular is just ignoring the SIGHUP, since the bash man page says that your first scenario should've resulted in a SIGHUP being sent to konqueror:

Quote:
The shell exits by default upon receipt of a SIGHUP. Before exiting, an interactive shell resends the SIGHUP to all
jobs, running or stopped. Stopped jobs are sent SIGCONT to ensure that they receive the SIGHUP. To prevent the shell
from sending the signal to a particular job, it should be removed from the jobs table with the disown builtin (see
SHELL BUILTIN COMMANDS below) or marked to not receive SIGHUP using disown -h.


The only difference between bash and zsh is that zsh makes you deal with the jobs instead of just automatically sending SIGHUPs as bash does.
Back to top
View user's profile Send private message
Beetle B.
Guru
Guru


Joined: 01 Mar 2003
Posts: 524

PostPosted: Wed Aug 06, 2008 7:07 pm    Post subject: Reply with quote

Quote:
I'm guessing konqueror in particular is just ignoring the SIGHUP, since the bash man page says that your first scenario should've resulted in a SIGHUP being sent to konqueror:


I don't think it's ignoring it. This behavior is not specific to konqueror, but to pretty much any X app I run.

Perhaps some refinement:

If I load up xterm (bash or zsh), and then load konqueror &, and then close xterm, konqueror dies with it.
If I load up xtwem (bash), and then load konqueror &, and quit xterm by typing "exit", konqueror continues to live.
If I load up xtwem (zsh), and then load konqueror &, and quit xterm by typing "exit", zsh won't let me quit.

BTW, this bash behavior is on two separate machines on which I've installed Gentoo.

As for bash's man page, I think you're reading it wrong. That occurs if the shell itself is given a SIGHUP. I think the general behavior is in the next paragraph:

Quote:
If the huponexit shell option has been set with shopt, bash sends a SIGHUP to all jobs when an interactive login shell exits.


So I guess I don't have huponexit option set?

I think the previous paragraph also gives some insight:

Quote:
Non-builtin commands run by bash have signal handlers set to the values inherited by the shell from its parent.


So I guess if the parent that spawned the shell is set to ignore SIGHUP, then so will any process spawned by the shell?
_________________
Beetle B.

Please update the table of equivalents.
A Firefox guide.
Back to top
View user's profile Send private message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6749

PostPosted: Thu Aug 07, 2008 6:09 am    Post subject: Reply with quote

The behavior is just a question of how you configured the zsh option "hup" and "check_jobs".
Probably you want
Code:
setopt nohup nocheckjobs
Back to top
View user's profile Send private message
Beetle B.
Guru
Guru


Joined: 01 Mar 2003
Posts: 524

PostPosted: Thu Aug 07, 2008 3:49 pm    Post subject: Reply with quote

That did it. Thanks!
_________________
Beetle B.

Please update the table of equivalents.
A Firefox guide.
Back to top
View user's profile Send private message
alex.blackbit
Advocate
Advocate


Joined: 26 Jul 2005
Posts: 2397

PostPosted: Fri Aug 08, 2008 9:29 pm    Post subject: zsh - love & hate Reply with quote

hi,

zsh has a lot of cool features, but very basic things do not work out of the box, and that's very annoying.
DIRCOLORS
after quite a while i tinkered a very good working rc file, with functionality very similar to gentoo /etc/bashrc.
i will post that when i am finished.
KEYBINDINGS
when using bash you do not have to worry about keybindings, they just work.
e.g. HOME, END, DEL, alt-left, alt-right, ...
these work on the console and every terminal emulator known to mankind: xterm, rxvt, aterm, eterm, gnome-terminal, konsole, screen, putty.
not so with zsh. until today i did not find a solution for that problem. a lot of rc files are out there, but none worked out of the box for me and i don't want to spend the time to read the complete zsh documentation, it's really huge, and the docs of all the terminals. if bash does it for 0$, zsh should do it too, and i want to know how.
can anybody provide a script that fixes at least the above given keybindings for zsh for the given terminals?

REWARD: free bed and breakfast for 1 week in salzburg, austria, europe.
Back to top
View user's profile Send private message
bunder
Bodhisattva
Bodhisattva


Joined: 10 Apr 2004
Posts: 5934

PostPosted: Fri Aug 08, 2008 11:12 pm    Post subject: Reply with quote

merged one post.
_________________
Neddyseagoon wrote:
The problem with leaving is that you can only do it once and it reduces your influence.

banned from #gentoo since sept 2017
Back to top
View user's profile Send private message
Beetle B.
Guru
Guru


Joined: 01 Mar 2003
Posts: 524

PostPosted: Sat Aug 09, 2008 3:43 am    Post subject: Reply with quote

What's the problem with dircolors?

As for the keybindings, look in /etc/inputrc. Find the ones you want. For example, alt-left is:

Code:

"\e[1;3D": backward-word


Then edit your .zshrc, and put:

Code:

bindkey '\e[1;3D' backward-word


and likewise for the rest. It's possible that the command (backward-word in this case) may not be the same in zsh as it is in bash, so do a "man zshzle" to get a full list of possible commands.

Quote:
these work on the console and every terminal emulator known to mankind: xterm, rxvt, aterm, eterm, gnome-terminal, konsole, screen, putty.
not so with zsh.


You're comparing apples and oranges. zsh and bash are shells. xterm, konsole, etc are console apps. Not the same thing. The reason you get the behavior you like is because it's been set up in /etc/inputrc - which was set up by baselayout - which was set up by Gentoo for bash users. Those keybindings are not necessarily bash defaults.

To give you an idea, in my web hosting account, which runs bash, the keystrokes you list don't work. Because they're not bash defaults.
_________________
Beetle B.

Please update the table of equivalents.
A Firefox guide.
Back to top
View user's profile Send private message
alex.blackbit
Advocate
Advocate


Joined: 26 Jul 2005
Posts: 2397

PostPosted: Sat Aug 09, 2008 9:31 am    Post subject: Reply with quote

Beetle B. wrote:
What's the problem with dircolors?

i already fixed that. in the default zsh startup files on gentoo systems there are no evaluations of the dircolors files, /etc/DIR_COLORS and ~/.dir_colors. the code block of /etc/bash/bashrc works almost unchanged. but that's something that should be provided by the package maintainer.
Beetle B. wrote:
and likewise for the rest. It's possible that the command (backward-word in this case) may not be the same in zsh as it is in bash, so do a "man zshzle" to get a full list of possible commands.

it is unbelievable that i am the first person on this planet who wants to have bash-like keybindings for zsh on a variety of terminal emulators. i looked at the zsh startup files of about 5-6 linux distributions, nowhere any keybindings are defined.
which means, after installation, keys like HOME, END, etc. do not work, for anybody. everybody has to think "well, it does not work. if i want to use that shell effectivly, i have to fix it. or i simply go back to bash, because there it already works". maybe that's a reason why zsh has no wide-spread popularity, albeit the sophisticated features.
Beetle B. wrote:
You're comparing apples and oranges. zsh and bash are shells. xterm, konsole, etc are console apps. Not the same thing.

Beetle B., i know that. i never said that bash and xterm are of the same kind.
Beetle B. wrote:
To give you an idea, in my web hosting account, which runs bash, the keystrokes you list don't work. Because they're not bash defaults.

very strange. so far i worked with bash under a dozen linux distributions, solaris, aix and a few others, all the keys worked everywhere, all terminals, putty, screen, etc.. maybe you are right and that's because the people of the distribution provide a good /etc/inputrc. but then the same thing should be possible for zsh.
remarkable is also, that in /etc/inputrc there are no seperate definitions for screen, but actually bash work great in screen. when using zsh, working keybindings for xterm do not work in screen. why is that?

please do not point to the zle manpage. for the following reasons:
  • it contains only information how to bind keys to functions, that's not what i need, i already can do that.
  • people before me had the same problems, it's not good that one million people do the same task again and again. i would like to write down defaults that are known to work so that others can benefit of that already existing knowledge.


again, can someone provide some lines of definitions for zsh keybindings so that they work at least in the following environment:
os/distribution:gentoo
terminals: system console, xterm, gnome-terminal, konsole, gnu screen, ssh connection with putty.

don't forget, you get a reward. :wink:

p.s.: what i forgot completely in my initial post: terminal titles do not work either in standard zsh setup, but i found a solution for that too, that i will post later.
Back to top
View user's profile Send private message
Beetle B.
Guru
Guru


Joined: 01 Mar 2003
Posts: 524

PostPosted: Sat Aug 09, 2008 3:08 pm    Post subject: Reply with quote

Quote:
i already fixed that. in the default zsh startup files on gentoo systems there are no evaluations of the dircolors files, /etc/DIR_COLORS and ~/.dir_colors. the code block of /etc/bash/bashrc works almost unchanged. but that's something that should be provided by the package maintainer.


Yes, that's a "problem" with the way Gentoo set it up and not with zsh. Although I don't really blame them as zsh is not that popular, and they can't go around supporting all shells out there.

Quote:
it is unbelievable that i am the first person on this planet who wants to have bash-like keybindings for zsh on a variety of terminal emulators.


<sigh>

What's a "bash-like" keybinding?

You mentioned Alt-left and alt-right for skipping words. The more standard default is Alt-f and Alt-b.

Let me give you an idea. On my web hosting account, which runs Debian, /etc/inputrc exists, but is completely commented out. I don't know if the hosting people did that or if that's how it is in Debian. But I'm sure it was done for a good reason - those keybindings are anything but standard. I'm not that old but I've been using UNIX for 10 years, and the more "reliable" (and painful) keybindings are those horrible HJKL types.

On my other work machine, which runs Red Hat, /etc/inputrc exists. But both that and the Debian ones don't have Alt-Left and Alt-Right. They instead have Ctrl-Left and Ctrl-Right (one has it commented and the other doesn't).

Even when you remove all the commented out stuff, neither file has as many keybindings as the Gentoo one does. In a sense, you're bashing Gentoo (pun intended) for providing an exemplary config file for one shell, whereas most distros provide a very basic one to begin with.

I honestly don't know what the defaults are for Bash. I can tell you that the inputrc that's shipped with Bash does not have any explicit keybindings for skipping words (although perhaps there is a default keybinding for it and you can use inputrc to override).

Quote:
everybody has to think "well, it does not work. if i want to use that shell effectivly, i have to fix it. or i simply go back to bash, because there it already works". maybe that's a reason why zsh has no wide-spread popularity, albeit the sophisticated features.


Yes, somewhat of a chicken and egg thing. I'm sure if a popular distro made zsh the standard and put good bindings in it, it'd catch on quicker. But just way too many people have bash scripts they want to keep running. So it then becomes a bad idea to make zsh the default.

In any case, this isn't zsh's fault.

Quote:
remarkable is also, that in /etc/inputrc there are no seperate definitions for screen, but actually bash work great in screen. when using zsh, working keybindings for xterm do not work in screen. why is that?


I'll confess that I don't know the subtleties involved with terminals and screen. I just use konsole for almost everything, so I wouldn't know. I can say that a quick test right now with screen + xterm seemed to work fine in terms of keybindings.

Quote:
* people before me had the same problems, it's not good that one million people do the same task again and again. i would like to write down defaults that are known to work so that others can benefit of that already existing knowledge.


Good luck in that. Once you've got it done, you can file a bug in bugs.gentoo.org and request that they either make it a default or at least provide it with the package as a sample and make an ebuild message that will inform new users of the sample file.

In any case, loads of people have posted their .zshrc's on the Web. Have you browsed through them?

As for the title, I just noticed you're right. I'll put that on my todo list...

If you ever create such a file, make sure you also source /etc/mc.gentoo (as they do for bash). This ensures that when mc changes directories and then quits, you find yourself in the new directory, not the one you started with.
_________________
Beetle B.

Please update the table of equivalents.
A Firefox guide.
Back to top
View user's profile Send private message
kiksen
Guru
Guru


Joined: 24 Jun 2002
Posts: 401
Location: Denmark

PostPosted: Mon Nov 03, 2008 4:38 pm    Post subject: Reply with quote

You may want to have a look at the zsh lovers project at: http://grml.org/zsh/ - they maintain a *huge* script with tons of features.

/kiksen
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming 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