diff --git a/.gitignore b/.gitignore index 4fe6511..4f3b7d1 100644 --- a/.gitignore +++ b/.gitignore @@ -25,4 +25,6 @@ Network Trash Folder Temporary Items .apdisk - +# Log files and swap +*.log +*.swp diff --git a/install.sh b/install.sh index 1a09b66..0cc0c4f 100755 --- a/install.sh +++ b/install.sh @@ -12,32 +12,42 @@ REPODIR="$(cd "$(dirname "$0")"; pwd -P)" cd "$REPODIR"; if ! is_app_installed tmux; then - printf "WARNING: \"tmux\" command is not found. \ -Install it first\n" + printf "WARNING: \"tmux\" command is not found. Install it first\n" exit 1 fi +if [ ! -e "$HOME/.tmux/plugins" ]; then + mkdir -p ~/.tmux/plugins +fi + if [ ! -e "$HOME/.tmux/plugins/tpm" ]; then - printf "WARNING: Cannot found TPM (Tmux Plugin Manager) \ - at default location: \$HOME/.tmux/plugins/tpm.\n" + printf "WARNING: Cannot found TPM (Tmux Plugin Manager) at default location: \$HOME/.tmux/plugins/tpm.\n" git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm fi if [ -e "$HOME/.tmux.conf" ]; then - printf "Found existing .tmux.conf in your \$HOME directory. Will create a backup at $HOME/.tmux.conf.bak\n" + tmuxbak="$HOME/.tmux.conf.bak$(date +%Y%m%d_%H%M%S)" + printf "Found existing ~/.tmux.conf in your \$HOME directory. Creating a backup at $tmuxbak\n" + cp -f "$HOME/.tmux.conf" "$tmuxbak" 2>/dev/null || true +fi + +if [ ! -e "$HOME/.tmux.conf.local" ]; then + touch $HOME/.tmux.conf.local fi -cp -f "$HOME/.tmux.conf" "$HOME/.tmux.conf.bak" 2>/dev/null || true -cp -a ./tmux/. "$HOME"/.tmux/ -ln -sf .tmux/tmux.conf "$HOME"/.tmux.conf; +cp -a ./tmux/renew_env.sh ~/.tmux/ +cp -a ./tmux/tmux.remote.conf ~/.tmux/ +cp -a ./tmux/yank.sh ~/.tmux/ +#ln -sf "${PWD}"/tmux/tmux.conf ~/.tmux.conf; +cp -a ./tmux/tmux.conf ~/.tmux.conf # Install TPM plugins. # TPM requires running tmux server, as soon as `tmux start-server` does not work # create dump __noop session in detached mode, and kill it when plugins are installed -printf "Install TPM plugins\n" +printf "Installing TPM plugins\n" tmux new -d -s __noop >/dev/null 2>&1 || true tmux set-environment -g TMUX_PLUGIN_MANAGER_PATH "~/.tmux/plugins" -"$HOME"/.tmux/plugins/tpm/bin/install_plugins || true +~/.tmux/plugins/tpm/bin/install_plugins || true tmux kill-session -t __noop >/dev/null 2>&1 || true printf "OK: Completed\n" diff --git a/readme.md b/readme.md index 955ac35..c0934d7 100644 --- a/readme.md +++ b/readme.md @@ -4,6 +4,8 @@ Tmux configuration, that supercharges your [tmux](https://tmux.github.io/) and b ![intro](https://user-images.githubusercontent.com/768858/33152741-ec5f1270-cfe6-11e7-9570-6d17330a83aa.gif) +**Note:** Put local changes in `$HOME/.tmux.conf.local` to add or to override settings in `$HOME/.tmux.conf` + Table of contents ----------------- diff --git a/tmux/tmux.conf b/tmux/tmux.conf index afa72fa..b28dd8c 100644 --- a/tmux/tmux.conf +++ b/tmux/tmux.conf @@ -380,5 +380,8 @@ bind -T off F12 \ set -u window-status-current-format \;\ refresh-client -S +# Source local configuration +source-file ~/.tmux.conf.local + # Run all plugins' scripts run '~/.tmux/plugins/tpm/tpm' diff --git a/tmux/tmux.conf.local b/tmux/tmux.conf.local new file mode 100644 index 0000000..8a07ef6 --- /dev/null +++ b/tmux/tmux.conf.local @@ -0,0 +1,40 @@ +# Change prefix key back to C-b, I'm use to using that +unbind C-a +set -g prefix C-b + +# split windows with a pipe and dash +bind - splitw +bind | splitw -h + +# Jump to previous used tab (tmux-config sets this to Tab, which should be sufficient) +#bind-key C-l last-window + +# Vi copypaste mode (tmux-config already sets this) +#set-window-option -g mode-keys vi + +# Resize panes by repeatably tapping +bind-key -r J resize-pane -D 3 +bind-key -r H resize-pane -L 3 +bind-key -r K resize-pane -U 3 +bind-key -r L resize-pane -R 3 + +# hjkl pane traversal +bind h select-pane -L +bind j select-pane -D +bind k select-pane -U +bind l select-pane -R + +# I never have any luck with mouse mode enabled +set -g mouse off + +# Color +set -g default-terminal "screen-256color" + +bind Escape copy-mode + +# http://superuser.com/questions/600286/move-pane-to-a-new-window-in-tmux +# Move pane to new window (break-pane) or move window to pane (join-pane) +bind-key C-j command-prompt -p "join pane from:" "join-pane -s '%%'" +bind-key C-s command-prompt -p "send pane to:" "join-pane -t '%%'" +bind-key b break-pane +