Skip to content

Instantly share code, notes, and snippets.

@rummik
Last active November 29, 2019 20:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rummik/51ae3027a36318737dc40d43ac1a6908 to your computer and use it in GitHub Desktop.
Save rummik/51ae3027a36318737dc40d43ac1a6908 to your computer and use it in GitHub Desktop.
WIP nix shell wrapper for Zsh with `--rcfile` support
#!/usr/bin/env zsh
zmodload -F zsh/zutil b:zparseopts
zparseopts -A args -- \
-rcfile::
if [[ ! -v args[--rcfile] ]]; then
exec zsh --interactive
fi
# hist-ignore-space is set to prevent our eval from remaining in history
# we can then re-read from HISTFILE via `fc -R` to remove it
exec zsh \
--interactive \
--hist-ignore-space \
--sh-in-stdin &> /dev/null \
<<< " eval ${(qF):-"
# source the bash RC file
emulate -R bash -c 'source ${args[--rcfile]}'
# rebind I/O to TTY
exec 0</dev/tty 1>/dev/tty 2>/dev/tty
# enable ZLE
setopt zle
# attempt to remove our eval'd script from history
fc -R
"}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment