You are not logged in.

#1 2013-01-20 00:10:35

eruditorum
Member
Registered: 2012-11-12
Posts: 130

[SOLVED] Making bash zsh-like!

Hello, guys! Do you know whether it is possible to do the following:

+ Hide "cd %something%" message when changing current working directory with typing just its name (without "cd") with "shopt -s autocd" enabled
+ Colorify the output of tab-completion (ordinary colored ls behaviour)

?

Last edited by eruditorum (2013-02-16 11:10:48)

Offline

#2 2013-01-20 00:13:46

chris_l
Member
Registered: 2010-12-01
Posts: 390

Re: [SOLVED] Making bash zsh-like!

Why not just using zsh? is pretty similar with bash anyway


"open source is about choice"
No.
Open source is about opening the source code complying with this conditions, period. The ability to choose among several packages is just a nice side effect.

Offline

#3 2013-01-20 00:16:43

eruditorum
Member
Registered: 2012-11-12
Posts: 130

Re: [SOLVED] Making bash zsh-like!

Zshell is really difficult to set up.

Last edited by eruditorum (2013-01-20 07:24:46)

Offline

#4 2013-01-20 00:26:40

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,554
Website

Re: [SOLVED] Making bash zsh-like!

Exit code in the prompt is easy, just put $? in your PS1.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#5 2013-01-20 00:29:00

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,734
Website

Re: [SOLVED] Making bash zsh-like!

Not difficult... Try grml-zsh-config in [extra].

Offline

#6 2013-01-20 00:44:29

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: [SOLVED] Making bash zsh-like!

eruditorum wrote:

Zshell is really difficult to set up.


It works fine out of the box: it even has an interactive wizard-type thing to set up a basic config for you. And there is excellent documentation available.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#7 2013-01-20 01:12:01

eruditorum
Member
Registered: 2012-11-12
Posts: 130

Re: [SOLVED] Making bash zsh-like!

Trilby wrote:

Exit code in the prompt is easy, just put $? in your PS1.

Already figured that out, thanks. But I've found some problem...

Last edited by eruditorum (2013-01-20 07:25:28)

Offline

#8 2013-01-20 02:03:29

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,554
Website

Re: [SOLVED] Making bash zsh-like!

You can use trap to make your own handler for command not found errors that runs your own cd function if the unknown command is a directory.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#9 2013-01-20 07:20:25

eruditorum
Member
Registered: 2012-11-12
Posts: 130

Re: [SOLVED] Making bash zsh-like!

About displaying last exit code in promt: how do I display it only once and then remove it if no more program was started after that (just hit enter with empty input many times)?

I mean this:

EXIT () { 
case "$?" in 
  0) echo "";; *) echo -e "\e[1;35m$?\e[m ";; 
esac 
}
PS1='$(EXIT)\[\e[1;34m\]$PWD \[\e[1;32m\]#\[\e[m\] '

It won't update my prompt until some other program is executed sad(. Is that possible on z-shell?

Last edited by eruditorum (2013-01-20 07:26:31)

Offline

#10 2013-01-20 08:43:13

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: [SOLVED] Making bash zsh-like!

eruditorum wrote:

Is that possible on z-shell?

Yes.

%(0?..%?)

Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#11 2013-01-21 06:30:43

eruditorum
Member
Registered: 2012-11-12
Posts: 130

Re: [SOLVED] Making bash zsh-like!

Okay. This works as I wanted:

EC () {
  echo -e '\e[1;35m'$?'\n'
}
trap EC ERR

Offline

Board footer

Powered by FluxBB