From 4b7c5051eb6073da5a336b48d33f3f845ce0c01d Mon Sep 17 00:00:00 2001 From: Frank Terbeck Date: Sun, 11 Jan 2009 20:35:45 +0100 Subject: [PATCH] zshrc: try to be smarter about the skel warning 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 | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc index 4ee8737..aa49255 100644 --- a/etc/zsh/zshrc +++ b/etc/zsh/zshrc @@ -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 -- 2.1.4