Review shell scripts
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
@@ -20,16 +20,34 @@
|
||||
in
|
||||
''
|
||||
nix-develop() {
|
||||
if [ -z "$1" ]; then
|
||||
echo "Usage: nix-develop <shell>"
|
||||
return 1
|
||||
local devshell=""
|
||||
|
||||
while getopts "s:" opt; do
|
||||
case $opt in
|
||||
s)
|
||||
devshell=$OPTARG
|
||||
;;
|
||||
*)
|
||||
echo "Usage: nix-develop [-s <devshell>]"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -z "$devshell" ]]; then
|
||||
if [ ! -f flake.nix ]; then cp "${./template.nix}" flake.nix; fi
|
||||
nix develop -c "$SHELL"
|
||||
else
|
||||
nix develop self#"$devshell" -c "$SHELL"
|
||||
fi
|
||||
nix develop self#"$1" -c "$SHELL"
|
||||
}
|
||||
|
||||
_nix-develop_completion() {
|
||||
local shells=(${devShells})
|
||||
compadd -- $shells
|
||||
local options=(
|
||||
'-s[Dev shell from root flake]:shell:(${devShells})'
|
||||
)
|
||||
|
||||
_arguments -s $options
|
||||
}
|
||||
|
||||
compdef _nix-develop_completion nix-develop
|
||||
|
Reference in New Issue
Block a user