From 51ebf880dcfd28ba773c91f44c13f87007cb4fce Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Sun, 2 Jun 2013 17:42:31 +0300 Subject: [PATCH 01/16] Only add $TMUXIFIER/bin to $PATH if it is not in $PATH already --- init.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/init.sh b/init.sh index 541a2d9..0669c31 100644 --- a/init.sh +++ b/init.sh @@ -6,7 +6,9 @@ else fi # Add `bin` directroy to `$PATH`. -export PATH="$TMUXIFIER/bin:$PATH" +if [[ ":$PATH:" != *":$TMUXIFIER/bin:"* ]]; then + export PATH="$TMUXIFIER/bin:$PATH" +fi # If `tmuxifier` is available, and `$TMUXIFIER_NO_COMPLETE` is not set, then # load tmuxifier shell completion. From 7ab7586f742bd36042e46c6909bf6846337b7aa9 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Sun, 2 Jun 2013 17:43:41 +0300 Subject: [PATCH 02/16] Auto-set $TMUXIFIER to correct directory based on relative path --- bin/tmuxifier | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/bin/tmuxifier b/bin/tmuxifier index 1d58357..656a187 100755 --- a/bin/tmuxifier +++ b/bin/tmuxifier @@ -2,8 +2,26 @@ set -e [ -n "$TMUXIFIER_DEBUG" ] && set -x +resolve_link() { + $(type -p greadlink readlink | head -1) $1 +} + +abs_dirname() { + local cwd="$(pwd)" + local path="$1" + + while [ -n "$path" ]; do + cd "${path%/*}" + local name="${path##*/}" + path="$(resolve_link "$name" || true)" + done + + pwd + cd "$cwd" +} + if [ -z "${TMUXIFIER}" ]; then - export TMUXIFIER="${HOME}/.tmuxifier" + export TMUXIFIER="$(dirname "$(abs_dirname "$0")")" else export TMUXIFIER="${TMUXIFIER%/}" fi From 7cc9228839f673a22765bb90acd1c0c7d6265cc2 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Sun, 2 Jun 2013 17:51:43 +0300 Subject: [PATCH 03/16] Add early version new tmuxifier-init command --- libexec/tmuxifier-init | 59 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100755 libexec/tmuxifier-init diff --git a/libexec/tmuxifier-init b/libexec/tmuxifier-init new file mode 100755 index 0000000..e12edc9 --- /dev/null +++ b/libexec/tmuxifier-init @@ -0,0 +1,59 @@ +#! /usr/bin/env bash +set -e +[ -n "$TMUXIFIER_DEBUG" ] && set -x + +print="" +for args in "$@"; do + if [ "$args" = "-" ]; then + print=1 + shift + 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 + + exit 1 +fi + +case "$shell" in + csh | tcsh ) + echo "setenv TMUXIFIER \"$TMUXIFIER\"" + echo "source \"\$TMUXIFIER/init.tcsh\"" + ;; + * ) + echo "export TMUXIFIER=\"$TMUXIFIER\"" + echo "source \"\$TMUXIFIER/init.sh\"" + ;; +esac From ed3fda5769a350a3dec552ff987bf17ee4f5d89c Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Sun, 2 Jun 2013 21:25:19 +0300 Subject: [PATCH 04/16] 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 From d94ccf560e5fd923e5c191488b7521c35208556e Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Sun, 2 Jun 2013 21:29:38 +0300 Subject: [PATCH 05/16] Simplify internals of init command a bit --- libexec/tmuxifier-init | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/libexec/tmuxifier-init b/libexec/tmuxifier-init index 349d3d5..cc51abb 100755 --- a/libexec/tmuxifier-init +++ b/libexec/tmuxifier-init @@ -45,15 +45,8 @@ You might also need to add Tmuxifier's bin directory to your PATH." exit fi -print="" -for args in "$@"; do - if [ "$args" = "-" ]; then - print=1 - shift - fi -done - -if [ -z "$print" ]; then +# Print help if "-" argument is not given +if [[ " $@ " != *" - "* ]]; then echo "$(tmuxifier-help init $@)" >&2 exit 1 fi From 4d486d48d0037b6b93dfc2f0ea9b519092ab5f48 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Sun, 2 Jun 2013 21:30:56 +0300 Subject: [PATCH 06/16] Fix a typo --- libexec/tmuxifier-init | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libexec/tmuxifier-init b/libexec/tmuxifier-init index cc51abb..6246bd5 100755 --- a/libexec/tmuxifier-init +++ b/libexec/tmuxifier-init @@ -29,7 +29,7 @@ case "$shell" in profile='~/.tcshrc' ;; * ) - profile='your shell init file' + profile='shell init file' ;; esac From 1a9dd4787d999e8172b42dea4b25d2db1e899726 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Mon, 3 Jun 2013 09:16:58 +0300 Subject: [PATCH 07/16] Improve argument handling of init command --- libexec/tmuxifier-init | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/libexec/tmuxifier-init b/libexec/tmuxifier-init index 6246bd5..5f30ed7 100755 --- a/libexec/tmuxifier-init +++ b/libexec/tmuxifier-init @@ -2,11 +2,12 @@ set -e [ -n "$TMUXIFIER_DEBUG" ] && set -x -if [ "$1" == "-" ] || [ "$1" == "--help" ]; then - shell="$2" -else - shell="$1" -fi +# Set shell to first argument that is not "-" or "--help". +for arg in "$@"; do + if [ "$arg" != "-" ] && [ "$arg" != "--help" ]; then + shell="$arg" + fi +done if [ -z "$shell" ]; then shell="$(basename "$SHELL")" From c9c3534f05b3741ef7ad452389f020a2039005c0 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Wed, 12 Jun 2013 00:08:44 +0100 Subject: [PATCH 08/16] Improve init command's argument parsing --- libexec/tmuxifier-init | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libexec/tmuxifier-init b/libexec/tmuxifier-init index 5f30ed7..4e826f3 100755 --- a/libexec/tmuxifier-init +++ b/libexec/tmuxifier-init @@ -2,9 +2,9 @@ set -e [ -n "$TMUXIFIER_DEBUG" ] && set -x -# Set shell to first argument that is not "-" or "--help". +# Set shell to first argument that is not "-", "-h" or "--help". for arg in "$@"; do - if [ "$arg" != "-" ] && [ "$arg" != "--help" ]; then + if [ "$arg" != "-" ] &&[ "$arg" != "-h" ] && [ "$arg" != "--help" ]; then shell="$arg" fi done From f0647b03263d81e624ed5084acbb54eb8fb3362d Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Wed, 12 Jun 2013 00:09:19 +0100 Subject: [PATCH 09/16] Update init scripts --- init.sh | 4 ++-- init.tcsh | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/init.sh b/init.sh index 0669c31..059fec5 100644 --- a/init.sh +++ b/init.sh @@ -1,4 +1,4 @@ -# Set tmuxifier root path. +# Set/fix Tmuxifier root path if needed. if [ -z "${TMUXIFIER}" ]; then export TMUXIFIER="${HOME}/.tmuxifier" else @@ -11,7 +11,7 @@ if [[ ":$PATH:" != *":$TMUXIFIER/bin:"* ]]; then fi # If `tmuxifier` is available, and `$TMUXIFIER_NO_COMPLETE` is not set, then -# load tmuxifier shell completion. +# load Tmuxifier shell completion. if [ -n "$(command -v "tmuxifier")" ] && [ -z "$TMUXIFIER_NO_COMPLETE" ]; then if [ -n "$BASH_VERSION" ]; then source "$TMUXIFIER/completion/tmuxifier.bash" diff --git a/init.tcsh b/init.tcsh index a681394..c17dd49 100644 --- a/init.tcsh +++ b/init.tcsh @@ -1,13 +1,15 @@ -# Set tmuxifier root path. +# Set Tmuxifier root path if needed. if ( ! $?TMUXIFIER ) then setenv TMUXIFIER "${HOME}/.tmuxifier" endif -# Add `bin` directroy to `$PATH`. -set path = ( $TMUXIFIER/bin $path ) +# Add `bin` directroy to `$path` if needed. +if ( " $path " =~ "* $TMUXIFIER/bin *" ) then + set path = ( $TMUXIFIER/bin $path ) +endif # If `tmuxifier` is available, and `$TMUXIFIER_NO_COMPLETE` is not set, then -# load tmuxifier shell completion. +# load Tmuxifier shell completion. if ( ! $?TMUXIFIER_NO_COMPLETE ) then which tmuxifier > /dev/null && source "$TMUXIFIER/completion/tmuxifier.tcsh" endif From 9e8a5c3dc9c4ce117dacf998341212be22486eec Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Wed, 12 Jun 2013 00:48:48 +0100 Subject: [PATCH 10/16] Separate init command output commands with ; fixing issues with tcsh --- libexec/tmuxifier-init | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libexec/tmuxifier-init b/libexec/tmuxifier-init index 4e826f3..1205c3e 100755 --- a/libexec/tmuxifier-init +++ b/libexec/tmuxifier-init @@ -54,11 +54,11 @@ fi case "$shell" in csh | tcsh ) - echo "setenv TMUXIFIER \"$TMUXIFIER\"" - echo "source \"\$TMUXIFIER/init.tcsh\"" + echo "setenv TMUXIFIER \"$TMUXIFIER\";" + echo "source \"\$TMUXIFIER/init.tcsh\";" ;; * ) - echo "export TMUXIFIER=\"$TMUXIFIER\"" - echo "source \"\$TMUXIFIER/init.sh\"" + echo "export TMUXIFIER=\"$TMUXIFIER\";" + echo "source \"\$TMUXIFIER/init.sh\";" ;; esac From 536f625b5d72bad87514994bb95e67151a38cd07 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Wed, 12 Jun 2013 00:49:21 +0100 Subject: [PATCH 11/16] Print correct help info for init command based on the shell used --- libexec/tmuxifier-init | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/libexec/tmuxifier-init b/libexec/tmuxifier-init index 1205c3e..a467bea 100755 --- a/libexec/tmuxifier-init +++ b/libexec/tmuxifier-init @@ -39,10 +39,20 @@ if [[ " $@ " == *" --help "* ]]; then echo "usage: tmuxifier init - Load Tmuxifier by adding the following to your ${profile}: +" - eval \"\$(tmuxifier init -)\" + case "$shell" in + csh | tcsh ) + echo " eval \`tmuxifier init -\` +" + ;; + * ) + echo " eval \"\$(tmuxifier init -)\" +" + ;; + esac -You might also need to add Tmuxifier's bin directory to your PATH." + echo "You might also need to add Tmuxifier's bin directory to your PATH." exit fi From 831deec069cbfdbfb03dfa22cc3b09e4aa382b75 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Wed, 12 Jun 2013 08:50:25 +0100 Subject: [PATCH 12/16] Update readme with details of new init system --- README.md | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 83a042f..68254c0 100644 --- a/README.md +++ b/README.md @@ -58,13 +58,29 @@ Clone the repo to your machine: git clone https://github.com/jimeh/tmuxifier.git ~/.tmuxifier ``` +Then add `~/.tmuxifier/bin` to your PATH: + +### bash & zsh + +```bash +export PATH="~/.tmuxifier/bin:$PATH" +``` + +### tcsh + +```tcsh +set path = ( ~/.tmuxifier/bin $path ) +``` + +## Setup + ### bash & zsh And add the following to your `~/.profile`, `~/.bash_profile`, `~/.zshrc` or equivalent: ```bash -[[ -s "$HOME/.tmuxifier/init.sh" ]] && source "$HOME/.tmuxifier/init.sh" +eval "$(tmuxifier init -)" ``` ### tcsh @@ -72,9 +88,14 @@ equivalent: Add the following to your `~/.cshrc`, `~/.tcshrc` or equivalent: ```tcsh -if ( -s "$HOME/.tmuxifier/init.sh" ) then - source "$HOME/.tmuxifier/init.sh" -endif +eval `tmuxifier init -` +``` + +## Updating + +```bash +cd ~/.tmuxifier +git pull ``` ## Usage From 9f1a3621f0710da76c9ea7ff54f1cd0c762facd9 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Wed, 12 Jun 2013 09:00:18 +0100 Subject: [PATCH 13/16] Fix an error and tweak some styling in readme --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 68254c0..4fd1e0f 100644 --- a/README.md +++ b/README.md @@ -60,21 +60,21 @@ git clone https://github.com/jimeh/tmuxifier.git ~/.tmuxifier Then add `~/.tmuxifier/bin` to your PATH: -### bash & zsh +__In bash & zsh:__ ```bash export PATH="~/.tmuxifier/bin:$PATH" ``` -### tcsh +__In tcsh:__ ```tcsh -set path = ( ~/.tmuxifier/bin $path ) +set path = ( "~/.tmuxifier/bin" $path ) ``` ## Setup -### bash & zsh +__In bash & zsh:__ And add the following to your `~/.profile`, `~/.bash_profile`, `~/.zshrc` or equivalent: @@ -83,7 +83,7 @@ equivalent: eval "$(tmuxifier init -)" ``` -### tcsh +__In tcsh:__ Add the following to your `~/.cshrc`, `~/.tcshrc` or equivalent: From a4e3edc4caa4b385768962132118f95314e5403e Mon Sep 17 00:00:00 2001 From: peter-d Date: Thu, 13 Jun 2013 16:01:24 +0200 Subject: [PATCH 14/16] Fixed the path setup for tcsh --- init.tcsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.tcsh b/init.tcsh index c17dd49..0a20c0b 100644 --- a/init.tcsh +++ b/init.tcsh @@ -4,7 +4,7 @@ if ( ! $?TMUXIFIER ) then endif # Add `bin` directroy to `$path` if needed. -if ( " $path " =~ "* $TMUXIFIER/bin *" ) then +if ( ! (" $path " =~ "* $TMUXIFIER/bin *" ) ) then set path = ( $TMUXIFIER/bin $path ) endif From 54561b9bbd580821776a417b780c9c655a684dd8 Mon Sep 17 00:00:00 2001 From: peter-d Date: Mon, 17 Jun 2013 14:25:24 +0200 Subject: [PATCH 15/16] fixed a typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4fd1e0f..114c7b2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Tmuxifier -Tmuxify your Tmux. Create, edit, mangage and load complex Tmux session, window +Tmuxify your Tmux. Create, edit, manage and load complex Tmux session, window and pane configurations with ease. In short, Tmuxifier allows you to easily create, edit, and load "layout" From 83b6b47f7c10366b38f4d224f9542bbf3c42859e Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Tue, 18 Jun 2013 00:05:15 +0100 Subject: [PATCH 16/16] Update readme --- README.md | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 114c7b2..1da9600 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,8 @@ Clone the repo to your machine: git clone https://github.com/jimeh/tmuxifier.git ~/.tmuxifier ``` -Then add `~/.tmuxifier/bin` to your PATH: +Then add `~/.tmuxifier/bin` to your PATH to make the `tmuxifier` executable +available to you: __In bash & zsh:__ @@ -72,6 +73,12 @@ __In tcsh:__ set path = ( "~/.tmuxifier/bin" $path ) ``` +### Custom Installation Path + +To install Tmuxifier somewhere else than the suggested `~/.tmuxifier`, simply +clone the repository to your custom location, and ensure the `bin` folder is +added to your PATH making the `tmuxifier` executable available to you. + ## Setup __In bash & zsh:__ @@ -150,17 +157,6 @@ in it. ## Configure & Customize -### Custom Installaton Path - -To install Tmuxifier to a custom path, clone the repository to your desired -path and set `$TMUXIFIER` to that path, additionally loading `init.sh` or -`init.tcsh` from that same path. - -```bash -export TMUXIFIER="$HOME/.dotfiles/tmuxifier" -[[ -s "$TMUXIFIER/init.sh" ]] && source "$TMUXIFIER/init.sh" -``` - ### Custom Layouts Path You can customize the layouts directory used by Tmuxifier by setting