Last active
November 29, 2019 20:11
-
-
Save rummik/51ae3027a36318737dc40d43ac1a6908 to your computer and use it in GitHub Desktop.
WIP nix shell wrapper for Zsh with `--rcfile` support
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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