enkore / j4-dmenu-desktop

A fast desktop menu
GNU General Public License v3.0
672 stars 70 forks source link

Using zsh On Top Of Bash j4-dmenu-desktop not working #23

Closed ghost closed 10 years ago

ghost commented 10 years ago

Hi,

I learned a trick a while back on being able to run bash as the shell but use zsh for it's features without having to switch to zsh as your shell.

In order to do this, all you have to do is place in your .bashrc;

exec /bin/zsh

And then of course you have a zsh config file ~/.zshrc placed in your $HOME

When I run j4 from the terminal this is all I see for any application I try and run, there are no errors, but nothing will start.

j4-dmenu-desktop
SearchPath: /home/foo/.local/share/applications/
LocaleSuffix: en
LocaleSuffix: en_US
Read 4 .desktop files, found 3 apps.
User input is: Firefox 
firefox 
/bin/bash -i -c 'firefox '

Also in case it caught your eye, don't worry I changed the source SearchPath only for my $HOME :)

I hope you can fix this, I really like using my terminal with bash this way.

Here is my .bashrc;

#.bashrc

# colors & char ########################################################
alias 256colors='for code in {0..255}; do echo -e "\e[38;05;${code}m $code: Test"; done'
case $TERM in (xterm|screen) TERM=$TERM-256color;; esac
# reset color
NC='\e[0m'
# Add color
eval `dircolors -b`

# alias ################################################################
# ls & grep ------------------------------------------------------------
alias ls='ls --color=auto'
alias dir='dir --color=auto'
alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias ll='ls -l'
alias la='ls -A'
alias l='ls -CF'
alias diff='colordiff'
alias cls='clear && ls -hal'
alias xpropc='xprop | grep "WM_WINDOW_ROLE\|WM_CLASS" && echo "WM_CLASS(STRING) = \"NAME\", \"CLASS\""'
alias xevc='xev | grep -A2 --line-buffered '\''^KeyRelease'\'' | sed -n '\''/keycode /s/^.*keycode \([0-9]*\).* (.*, \(.*\)).*$/\1 \2/p'\'
# end of alias #########################################################

# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000

# Add bin to path
export PATH="$PATH:/usr/sbin"

# echo -en "\e[1;31mSlackware64 \e[1;31m14.0 \e[0;32m(GNU/Linux)\e[m\n\n"
PS1="\[\e[00;33m\]\A \[\e[00;35m\]\[\e[1;35m\]\u\e[m \w> "
#PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

#export DESKTOP_SESSION="gnome"
export EDITOR="nano"
export BROWSER="firefox"
export PAGER="most"
exec /bin/zsh

# Set the environment variable to force a specific style for QT5
export QT_STYLE_OVERRIDE=gtk

# Set desktop to use for QT5
export DESKTOP_SESSION=gnome

Here is my .zshrc

##############################
## zsh config file ~/.zshrc ##
##                          ##
##############################
## variables -----------------------------------------------------------
export BROWSER="firefox"
export EDITOR="nano"
export PAGER="most"
export NMON=cmdn
# text normal colors
alias 256colors='for code in {0..255}; do echo -e "\e[38;05;${code}m $code: Test"; done'
case $TERM in (xterm|screen) TERM=$TERM-256color;; esac
# reset color
NC='\e[0m'
########################################################################
## options #############################################################
########################################################################
# misc -----------------------------------------------------------------
# use vi keybinds
bindkey -v
# no beep
unsetopt beep
unsetopt hist_beep
unsetopt list_beep
# display errors
#setopt print_exit_value
# confirm 'rm *'
unsetopt rm_star_silent
# no error on search 
setopt nullglob
# completion menu
setopt auto_menu
# confirm 'rm *' etc
setopt rm_star_wait
# don't &proc kill on exit
setopt auto_continue
# don’t nice &proc
setopt no_bg_nice
# keys -----------------------------------------------------------------
typeset -A key
key[Home]=${terminfo[khome]}
key[End]=${terminfo[kend]}
key[Insert]=${terminfo[kich1]}
key[Delete]=${terminfo[kdch1]}
key[Up]=${terminfo[kcuu1]}
key[Down]=${terminfo[kcud1]}
key[Left]=${terminfo[kcub1]}
key[Right]=${terminfo[kcuf1]}
key[PageUp]=${terminfo[kpp]}
key[PageDown]=${terminfo[knp]}
# setup key accordingly
[[ -n "${key[Home]}"    ]]  && bindkey  "${key[Home]}"    beginning-of-line
[[ -n "${key[End]}"     ]]  && bindkey  "${key[End]}"     end-of-line
[[ -n "${key[Insert]}"  ]]  && bindkey  "${key[Insert]}"  overwrite-mode
[[ -n "${key[Delete]}"  ]]  && bindkey  "${key[Delete]}"  delete-char
[[ -n "${key[Up]}"      ]]  && bindkey  "${key[Up]}"      up-line-or-history
[[ -n "${key[Down]}"    ]]  && bindkey  "${key[Down]}"    down-line-or-history
[[ -n "${key[Left]}"    ]]  && bindkey  "${key[Left]}"    backward-char
[[ -n "${key[Right]}"   ]]  && bindkey  "${key[Right]}"   forward-char
# history --------------------------------------------------------------
# history size
HISTSIZE=5000
SAVEHIST=5000
# history file
HISTFILE=~/.zsh_history
# history without double entry
setopt hist_ignore_all_dups
# all zsh instance share same file
setopt share_history
# update history
setopt inc_append_history
########################################################################
## alias ###############################################################
########################################################################
# ls & grep ------------------------------------------------------------
alias ls='ls --color=auto'
alias dir='dir --color=auto'
alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias ll='ls -l'
alias la='ls -A'
alias l='ls -CF'
########################################################################
## file type alias #####################################################
########################################################################
alias -s html=$BROWSER
alias -s pdf=epdfview
alias -s svg=inkscape
alias -s png=viewnior
alias -s jpg=viewnior
alias -s gif=viewnior
alias -s txt=$EDITOR
alias -s conf=$EDITOR
alias -s py=$EDITOR
alias -s php=$EDITOR
alias -s mp3=deadbeef
alias -s ogg=deadbeef
alias -s ogv=smplayer
alias -s flv=smplayer
alias -s avi=smplayer
alias -s mp4=smplayer
alias -s mkv=smplayer
alias -s m3u=deadbeef
alias -s zip=dtrx
alias -s tar=dtrx
alias -s tar.gz=dtrx
alias -s tar.bz2=dtrx
alias -s xz=dtrx
alias -s rar=dtrx

########################################################################
## completion ##########################################################
########################################################################
autoload -Uz compinit
compinit
zstyle ':completion:*' auto-description 'specify: %d'
zstyle ':completion:*' completer _expand _complete _correct _approximate
zstyle ':completion:*' format 'Completing %d'
zstyle ':completion:*' group-name ''
zstyle ':completion:*' menu select=1
eval "$(dircolors -b)"
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*' list-colors ''
zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=* l:|=*'
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
zstyle ':completion:*' use-compctl false
zstyle ':completion:*' verbose true
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'

########################################################################
## prompt ##############################################################
########################################################################
autoload -Uz promptinit
autoload -U colors && colors
promptinit
RPROMPT="%{$reset_color%}< %{$fg[blue]%}%M%{$reset_color%}:%{$fg[cyan]%}%y%{$reset_color%}:%{$fg[yellow]%}%~%{$reset_color%}"
PROMPT="%{$reset_color%}%{$fg[yellow]%} %T%{$reset_color%} %{$fg[green]%}%n%{$reset_color%} > "
## EOF #################################################################
enkore commented 10 years ago

Maybe you need to set $SHELL explicitly to zsh, because $SHELL is /bin/bash in your zsh session.

ghost commented 10 years ago

I don't want to use zsh as my shell.

I only use it to give me some nice options in the terminal is all.

Why can't j4-dmenu work like this?

Thanks

enkore commented 10 years ago

How should it know that it should start things using zsh if you're not telling it to do so?

$SHELL should always point to the shell you're using.

ghost commented 10 years ago

This is the output at my terminal;

~> echo $SHELL
/bin/bash

It's my understanding that all this does is add more functionality to the terminal and should not break anything needing bash.

enkore commented 10 years ago

Are you sure you're using a bash?

What does echo $0 say?

ghost commented 10 years ago

Ahhh I've never known of echo 0, all I've ever known was echo $SHELL...

echo 0 says /bin/zsh

So what does this mean that echo $SHELL says bash and ech 0 say zsh?

Thanks for your time...

enkore commented 10 years ago

It means you're really using zsh all the time ;)

ghost commented 10 years ago

Ok, but why does echo $SHELL say bash?

By the way using zsh like I'm doing with those options in my .zshrc, could it break something when compiling source, especially the kernel, or anything else important you can think of?

Sheesh just when I thought I was geek enough, maybe I should just dump it... :(

thanks again...

enkore commented 10 years ago

$SHELL is usually set at login time I think.

I'd recommend to copy the settings from .bashrc to your zshrc and setting your shell (login shell, default emulator shell [depends on terminal emulator] and so on) to zsh. That also avoids always running two shells at the same time (outer bash shell and inner zsh shell).

thomaspenteker commented 10 years ago

encore: please note that "exec cmd" will replace the current (bash) shell.

You may want to try invoking zsh as either an interactive shell (zsh -i) or as a login-shell (zsh -l) both invocations will "inititalize" the environment accordingly, including $SHELL.

enkore commented 10 years ago

encore: please note that "exec cmd" will replace the current (bash) shell.

Thanks, I missed that. Quoting the POSIX spec:

If command is specified, exec shall not return to the shell; rather, the exit status of the process shall be the exit status of the program implementing command, which overlaid the shell.

ghost commented 10 years ago

To be honest I thought I'd use zsh for the fancy terminal options, but I find myself not really using them. I don't know much about this, but I was told for compiling things as example, maybe even the kernel, you want to compile from a bash shell not zsh...

$Shell crap I've never been to good at, just some real basics, so maybe it's best I just stick to bash, but do you guys know any .similar things I could add to my .bashrc to accomplsh pretty much the same? Anywhere online I could read that shows a lot of nice bash options to use similar to zsh?

Thanks

P.S. I found two cmds and I figured out how to malke a pretty cool prompt;

bind 'TAB:menu-complete'
bind "set show-all-if-ambiguous on"
PS1="\[\e[38;5;24m\]\h\[\e[38;5;255m\]:\[\e[38;5;24m\]pts\[\e[38;5;251m\]\w\[\e[1;36m\]\l \[\e[38;5;23m\] \D{%I}\[\e[38;5;251m\]:\[\e[38;5;23m\]\D{%M} \[\e[38;5;24m\]\u\e[m \w> "
enkore commented 10 years ago

I'm using zsh as my default shell since quite some time everywhere and haven't experienced any issues building stuff or something like that.

enkore commented 10 years ago

Aha... could you try replacing exec zsh with exec zsh "$@" in your bashrc? This should fix the initial issue.

ghost commented 10 years ago

Hi,

As a user I took the leap LOL;

chsh -s /bin/zsh

So I'm now on zsh shell and j4 is working fine, but I'll also give exec zsh "$@" a go too.

Thanks