From ed3fda5769a350a3dec552ff987bf17ee4f5d89c Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Sun, 2 Jun 2013 21:25:19 +0300 Subject: [PATCH] Update init command to use new help system --- libexec/tmuxifier-init | 77 ++++++++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 33 deletions(-) diff --git a/libexec/tmuxifier-init b/libexec/tmuxifier-init index e12edc9..349d3d5 100755 --- a/libexec/tmuxifier-init +++ b/libexec/tmuxifier-init @@ -2,6 +2,49 @@ set -e [ -n "$TMUXIFIER_DEBUG" ] && set -x +if [ "$1" == "-" ] || [ "$1" == "--help" ]; then + shell="$2" +else + shell="$1" +fi + +if [ -z "$shell" ]; then + shell="$(basename "$SHELL")" +fi + +case "$shell" in + bash ) + profile='~/.bash_profile' + ;; + zsh ) + profile='~/.zshrc' + ;; + ksh ) + profile='~/.profile' + ;; + csh ) + profile='~/.cshrc' + ;; + tcsh ) + profile='~/.tcshrc' + ;; + * ) + profile='your shell init file' + ;; +esac + +# Provide tmuxifier help +if [[ " $@ " == *" --help "* ]]; then + echo "usage: tmuxifier init - + +Load Tmuxifier by adding the following to your ${profile}: + + eval \"\$(tmuxifier init -)\" + +You might also need to add Tmuxifier's bin directory to your PATH." + exit +fi + print="" for args in "$@"; do if [ "$args" = "-" ]; then @@ -10,40 +53,8 @@ for args in "$@"; do fi done -shell="$1" -if [ -z "$shell" ]; then - shell="$(basename "$SHELL")" -fi - if [ -z "$print" ]; then - case "$shell" in - bash ) - profile='~/.bash_profile' - ;; - zsh ) - profile='~/.zshrc' - ;; - ksh ) - profile='~/.profile' - ;; - csh ) - profile='~/.cshrc' - ;; - tcsh ) - profile='~/.tcshrc' - ;; - * ) - profile='your profile' - ;; - esac - - { echo "# Load tmuxifier automatically by adding" - echo "# the following to ${profile}:" - echo - echo "eval \"\$(tmuxifier init -)\"" - echo - } >&2 - + echo "$(tmuxifier-help init $@)" >&2 exit 1 fi