diff --git a/.tmux.conf b/.tmux.conf index 145527d..b2050a0 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -74,14 +74,6 @@ bind C-c new-session # find session bind C-f command-prompt -p find-session 'switch-client -t %%' -# split current window vertically, retain current path -bind '"' split-window -h -c "#{pane_current_path}" -bind _ split-window -h -c "#{pane_current_path}" -# split current window horizontally, retain current path -unbind % -bind % split-window -v -c "#{pane_current_path}" -bind - split-window -v -c "#{pane_current_path}" - # pane navigation bind -r h select-pane -L # move left bind -r j select-pane -D # move down @@ -157,6 +149,7 @@ if '[ -f ~/.tmux.conf.local ]' 'source ~/.tmux.conf.local' # -- 8< ------------------------------------------------------------------------ run 'cut -c3- ~/.tmux.conf | sh -s apply_theme $tmux_conf_theme' +run 'cut -c3- ~/.tmux.conf | sh -s apply_configurable_bindings $tmux_conf_new_windows_retain_current_path $tmux_conf_new_panes_retain_current_path' run 'for name in $(printenv | grep -Eo ^tmux_conf_[^=]+); do tmux setenv -gu $name; done;' @@ -366,4 +359,26 @@ run 'for name in $(printenv | grep -Eo ^tmux_conf_[^=]+); do tmux setenv -gu $na # printf "%0.s$battery_symbol_empty" $(seq 1 $empty) # } # +# apply_configurable_bindings() { +# windows_retain_current_path=${1:-false} +# if [ x"$windows_retain_current_path" = x"true" -o x"$windows_retain_current_path" = x"1" ] ; then +# tmux bind c new-window -c '#{pane_current_path}' +# else +# tmux bind c new-window +# fi +# +# panes_retain_current_path=${2:-true} +# if [ x"$panes_retain_current_path" = x"true" -o x"$panes_retain_current_path" = x"1" ] ; then +# tmux bind '"' split-window -h -c "#{pane_current_path}" \;\ +# bind _ split-window -h -c "#{pane_current_path}" \;\ +# bind % split-window -v -c "#{pane_current_path}" \;\ +# bind - split-window -v -c "#{pane_current_path}" +# else +# tmux bind '"' split-window -h \;\ +# bind _ split-window -h \;\ +# bind % split-window -v \;\ +# bind - split-window -v +# fi +# } +# # $@ diff --git a/.tmux.conf.local b/.tmux.conf.local index 0582f09..f064dde 100644 --- a/.tmux.conf.local +++ b/.tmux.conf.local @@ -8,6 +8,10 @@ # or alternatively use an external tool, e.g. https://github.com/Goles/Battery #tmux_conf_battery='#(battery -t) ' +# new windows and new panes optionally retain current path +#tmux_conf_new_windows_retain_current_path=false +#tmux_conf_new_panes_retain_current_path=true + # if you're running tmux within iTerm2 # - and tmux is 1.9 or 1.9a # - and iTerm2 is configured to let option key act as +Esc diff --git a/README.md b/README.md index ed8c091..e1d3c1c 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ Features - mouse mode toggle with `m` - automatic usage of `reattach-to-user-namespace` if available - laptop battery status + - configurable new windows and panes behavior (optionally retain current path) Installation ------------ @@ -59,6 +60,15 @@ Edit your `~/.tmux.conf.local` file and uncomment the following lines: See `~/.tmux.conf.local` for more details. +### Configuring new windows and new panes creation + +Edit your `~/.tmux.conf.local` file and uncomment the following lines: + + #tmux_conf_new_windows_retain_current_path=false + #tmux_conf_new_panes_retain_current_path=true + +See `~/.tmux.conf.local` for more details. + ### Accessing the Mac OSX clipboard from within tmux sessions [Chris Johnsen created the `reattach-to-user-namespace`