MercuryTechnologies / nix-your-shell

A `nix` and `nix-shell` wrapper for shells other than `bash`
MIT License
85 stars 12 forks source link

`$SHELL` remains as `/run/current-system/sw/bin/bash`? #39

Closed spikespaz closed 9 months ago

spikespaz commented 10 months ago

Edit: I realized that my ZSH plugins seem to be working, even though $SHELL is a path to bash. What's up with that?


I still end up in a bash shell when running nix develop, but I can see that in my normal interactive ZSH terminal:

$ which nix
nix () {
    /nix/store/x7sh9fxjvpi4wc9921mn739c9p04d6mn-nix-your-shell-1.3.0/bin/nix-your-shell zsh nix -- "$@"
}

And after running nix develop:

$ echo $SHELL
/run/current-system/sw/bin/bash

I have attached my .zshrc, and the initialization command provided is at the bottom. I hope that this is enough to go by, and that the problem is trivial, because I don't have much other information to provide.

#######################
### STAGE: PRE-INIT ###
#######################

### DEFAULT INITIALIZATION ###

typeset -U path cdpath fpath manpath

for profile in ${(z)NIX_PROFILES}; do
  fpath+=(
    "$profile/share/zsh/site-functions"
    "$profile/share/zsh/$ZSH_VERSION/functions"
    "$profile/share/zsh/vendor-completions"
  )
done

HELPDIR="/nix/store/sn59qaijwgpf8n41khl60mfnfbxyb16x-zsh-5.9/share/zsh/$ZSH_VERSION/help"

### END ###

# Referenced <https://github.com/mattmc3/zsh_unplugged>.
function plugin-load {
  : ${ZPLUGINDIR:=${ZDOTDIR:-~/.config/zsh}/plugins}
  plugname=$1
  plugdir=$ZPLUGINDIR/$plugname
  initfile=$plugdir/$plugname.plugin.zsh
  if [[ ! -f $initfile ]]; then
    initfiles=($plugdir/*.{plugin.zsh,zsh-theme,zsh,sh}(N))
    (( $#initfiles )) || { echo >&2 "No init file for '$plugname'." && continue }
    initfile=$initfiles[1]
  fi
  fpath+=$plugdir
  source $initfile
}

#########################
### STAGE: INITIALIZE ###
#########################

### PROMPT ###

# Prompt is at the top so that I can start typing right away.
# Ignore if in TTY.
if ! tty | grep '/dev/tty[0-9]\?'; then
  eval "$(
    /nix/store/apywyyyv78xkb1z84ibfvhz9686pss8l-starship-1.16.0/bin/starship \
      init zsh --print-full-init
  )"
  # This was here to eliminate the 2-space padding on the right of
  # the prompt. No longer needed because there's nothing at the end.
  # <https://github.com/starship/starship/issues/4358>
  # PROMPT="${PROMPT//\$COLUMNS/\$((COLUMNS+2))}"
  ZLE_RPROMPT_INDENT=0
fi

### COMPLETION ###

setopt AUTO_CD
setopt ALWAYS_TO_END

### GLOBBING ###

setopt BAD_PATTERN
setopt EXTENDED_GLOB
setopt GLOB_DOTS
setopt GLOB_STAR_SHORT
setopt NULL_GLOB

### HISTORY ###

HISTFILE=$ZDOTDIR/.zsh_history
HISTSIZE=1000000
SAVEHIST=$HISTSIZE

setopt EXTENDED_HISTORY
setopt HIST_FCNTL_LOCK
setopt HIST_IGNORE_ALL_DUPS
setopt HIST_REDUCE_BLANKS
setopt HIST_SAVE_NO_DUPS
setopt SHARE_HISTORY

### INTERACTION ###

setopt INTERACTIVE_COMMENTS
setopt RM_STAR_SILENT

########################
### STAGE: POST-INIT ###
########################

### HOME MANAGER EXTRA INITIALIZATION ###

if [[ $options[zle] = on ]]; then
  . /nix/store/n3q966ii2anifp8k45wgyc8v35kmxr93-fzf-0.42.0/share/fzf/completion.zsh
  . /nix/store/n3q966ii2anifp8k45wgyc8v35kmxr93-fzf-0.42.0/share/fzf/key-bindings.zsh
fi

source /nix/store/0f2q17zw5zvk8b2n0a7w5m55a08br6y6-nix-index-0.1.7/etc/profile.d/command-not-found.sh

### END ###

###################
### STAGE: MAIN ###
###################

### AUTOCOMPLETE ###

# Disable security checks.
# Needed to avoid warnings about sourcing "insecure"
# files from `/nix/store`.
zstyle '*:compinit' arguments -C

zstyle ':autocomplete:*' min-delay 0.5
zstyle ':autocomplete:*' min-input 1
zstyle ':autocomplete:*' insert-unambiguous yes
zstyle ':autocomplete:*' fzf-completion yes

plugin-load zsh-autocomplete

zstyle ':completion:*:paths' path-completion yes

plugin-load zsh-autopair

### AUTOSUGGEST ###

ZSH_AUTOSUGGEST_STRATEGY=(history completion)

plugin-load zsh-autosuggestions

### SYNTAX HIGHLIGHTING ###

plugin-load fast-syntax-highlighting

PAGER='less'

### KEYBINDINGS ###

plugin-load zsh-edit

### NOTIFICATIONS ###

AUTO_NOTIFY_THRESHOLD=300
AUTO_NOTIFY_TITLE='Command has completed!'
AUTO_NOTIFY_BODY='<i>%command</i>'
AUTO_NOTIFY_BODY+='\n'
AUTO_NOTIFY_BODY+='With exit code %exit_code after %elapsed seconds.'
AUTO_NOTIFY_EXPIRE_TIME=15000

plugin-load zsh-auto-notify

### WINDOW TITLE ###

ZSH_WINDOW_TITLE_DIRECTORY_DEPTH=4

plugin-load zsh-window-title

### MISCELLANEOUS ###

/nix/store/x7sh9fxjvpi4wc9921mn739c9p04d6mn-nix-your-shell-1.3.0/bin/nix-your-shell zsh | source /dev/stdin

### HOME MANAGER ALIASES ###

alias la='/nix/store/y64iin9pxc13gfw7f64fnrgxhdqwdifz-lsd-1.0.0/bin/lsd -A'
alias ll='/nix/store/y64iin9pxc13gfw7f64fnrgxhdqwdifz-lsd-1.0.0/bin/lsd -l'
alias lla='/nix/store/y64iin9pxc13gfw7f64fnrgxhdqwdifz-lsd-1.0.0/bin/lsd -lA'
alias llt='/nix/store/y64iin9pxc13gfw7f64fnrgxhdqwdifz-lsd-1.0.0/bin/lsd -l --tree'
alias ls='/nix/store/y64iin9pxc13gfw7f64fnrgxhdqwdifz-lsd-1.0.0/bin/lsd'
alias lt='/nix/store/y64iin9pxc13gfw7f64fnrgxhdqwdifz-lsd-1.0.0/bin/lsd --tree'

### END ###
meskill commented 10 months ago

what's your initial value for $SHELL before running nix command?

As for my knowledge - $SHELL points to default shell of the user and the value is changed after user login for specific user e.g. if you have bash as default shell for your current user the $SHELL variable will still point to bash regardless of actually running shell right now.

9999years commented 10 months ago

I'm not sure I have enough to figure out if there's a bug here or what it might be. Maybe try strace nix-your-shell zsh nix -- develop and see if you can spot where/if it launches bash?

spikespaz commented 10 months ago

@meskill So you're saying that $SHELL is the login shell, not the current shell?

meskill commented 10 months ago

@meskill So you're saying that $SHELL is the login shell, not the current shell?

Yes, for me it always points to bash shell although I'm using another shell in nix