@@ -315,8 +315,21 @@ check_path() {
315315}
316316
317317check_shell_magic () {
318- sh=" $( basename " $SHELL " ) "
319- if test " $sh " = zsh; then
318+ # foo knows I cannot tell you why $SHELL may be unset
319+ if test -z " $SHELL " ; then
320+ if which finger > /dev/null 2>&1 ; then
321+ SHELL=" $( finger " $USER " | grep Shell | cut -d: -f3 | tr -d ' ' ) "
322+ elif which getent > /dev/null 2>&1 ; then
323+ SHELL=" $( basename " $( getent passwd " $USER " ) " ) "
324+ fi
325+ if test -z " $SHELL " ; then
326+ # well dang
327+ SHELL=" unknown"
328+ fi
329+ fi
330+
331+ case " $( basename " $SHELL " ) " in
332+ zsh)
320333 gum_func format -- << -EOMD
321334 # want magic?
322335 tea’s shell magic works via a one-line addition to your \` ~/.zshrc\` \\
@@ -332,7 +345,8 @@ check_shell_magic() {
332345 add-zsh-hook -Uz chpwd(){ source <(tea -Eds) } #tea
333346 EOSH
334347 fi
335- elif test " $sh " = " fish" ; then
348+ ;;
349+ fish)
336350 gum_func format -- << -EOMD
337351 # want magic?
338352 tea’s shell magic works via a simple hook function in fish \\
@@ -348,7 +362,8 @@ check_shell_magic() {
348362 function add_tea_environment --on-variable PWD; tea -Eds | source; end #tea
349363 EOSH
350364 fi
351- elif test " $sh " = " bash" ; then
365+ ;;
366+ bash)
352367 gum_func format -- << -EOMD
353368 # want magic?
354369 tea’s shell magic works via a simple function in bash \\
@@ -364,15 +379,16 @@ check_shell_magic() {
364379 cd() { builtin cd "\$ @" || return; [ "\$ OLDPWD" = "\$ PWD" ] || source <(tea -Eds); }
365380 EOSH
366381 fi
367- else
382+ ;;
383+ * )
368384 gum_func format -- << -EOMD
369385 # we need your help 🙏
370386
371- our shell magic doesn’t support \` $sh \` yet, can you make a pull request?
387+ our shell magic doesn’t support \` $SHELL \` yet, can you make a pull request?
372388
373389 > https://github.com/teaxyz/cli/pulls
374390 EOMD
375- fi
391+ esac
376392
377393 echo # spacer
378394}
0 commit comments