zshrc: try to be smarter about the skel warning
authorFrank Terbeck <ft@bewatermyfriend.org>
Sun, 11 Jan 2009 19:35:45 +0000 (20:35 +0100)
committerFrank Terbeck <ft@bewatermyfriend.org>
Sun, 8 Feb 2009 12:32:02 +0000 (13:32 +0100)
In recent zsh versions, we can check the file name of the current code is.
That way, we can add additional information about the warning.
And automatically remove it if that seems reasonable.

etc/zsh/zshrc

index 4ee8737..aa49255 100644 (file)
@@ -270,8 +270,32 @@ function grml_do_not_warn_skel() {
     printf 'GRML_WARN_SKEL=0\n' >>! ~/.zshrc.pre
 }
 
-grml_warn_skel_main
-grml_warn_skel_remove
+# let's try to guess how the user uses us.
+if is-at-least 4.3.7 ; then
+    # funcsourcetrace requires at least version 4.3.7 of zsh.
+    GRML_SRC_FILE="${${funcsourcetrace[1]}%:*}"
+
+    grml_warn_skel_main
+    case ${GRML_SRC_FILE} in
+        (${HOME}/.zshrc.global)
+            grml_warn_skel_remove
+            printf '\nIt looks like you copied the grml zshrc to '\''~/.zshrc.global'\''.\n'
+            printf 'Nowadays you just copy the global zshrc to '\''~/.zshrc'\'' to use\n'
+            printf 'it on a non-grml-system.\n'
+            ;;
+        (${HOME}/.zshrc)
+            printf '\nIt looks like you copied the grml zshrc to '\''~/.zshrc'\''.\n'
+            printf 'We'\''ll disable this warning automatically for later sessions.\n'
+            grml_do_not_warn_skel
+            ;;
+        (*)
+            grml_do_not_warn_skel
+            ;;
+    esac
+else
+    grml_warn_skel_main
+    grml_warn_skel_remove
+fi
 
 unfunction grml_warn_skel_remove grml_warn_skel_main