diff --git a/.gitignore b/.gitignore index 95767b2..acf815b 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,6 @@ # explicity ignore zcoredump zsh/.zcomp* + +# explicity ignore tmux plugins +tmux/plugins diff --git a/README.md b/README.md index b84cb6b..1e79674 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,9 @@ - install [ggman](https://github.com/tkw1536/ggman) - install [pyenv](https://github.com/pyenv/pyenv) to $XDG_DATA_HOME/.pyenv - set `PYENV_ROOT` and use [pyenv-installer](https://github.com/pyenv/pyenv-installer) - - install [pyenv-default-packages](git clone https://github.com/jawshooah/pyenv-default-packages.git $(pyenv root)/plugins/pyenv-default-packages) + - install [pyenv-default-packages](https://github.com/jawshooah/pyenv-default-packages.git) - symlink `.pyenv/default-packages` to `$PYENV_ROOT/default-packages` - install [neovim](https://neovim.io/) - follow `README.md` in [janezicmatej/nvim](https://github.com/janezicmatej/nvim/) +- install [tmux](https://github.com/tmux/tmux) + - install [tmp](https://github.com/tmux-plugins/tpm) for plugins diff --git a/tmux/tmux-sessionizer b/tmux/tmux-sessionizer new file mode 100755 index 0000000..b77f6c3 --- /dev/null +++ b/tmux/tmux-sessionizer @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +if [[ $# -eq 1 ]]; then + selected=$1 +else + selected=$(find -L $GGROOT -mindepth 1 -maxdepth 5 -type d -name .git -prune | xargs -n 1 dirname | fzf) +fi + +if [[ -z $selected ]]; then + exit 0 +fi + + +selected_name=$(basename "$selected" | tr . _) +tmux_running=$(pgrep tmux) + +if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then + tmux new-session -s $selected_name -c $selected + exit 0 +fi + +if ! tmux has-session -t=$selected_name 2> /dev/null; then + tmux new-session -ds $selected_name -c $selected +fi + +tmux switch-client -t $selected_name diff --git a/tmux/tmux.conf b/tmux/tmux.conf index 4e42e4d..66576de 100644 --- a/tmux/tmux.conf +++ b/tmux/tmux.conf @@ -1,5 +1,5 @@ set -ga terminal-overrides ",xterm-256color:Tc" -# set-option -g default-terminal "screen-256color" +set-option -g default-terminal "screen-256color" set -s escape-time 0 unbind C-b @@ -10,6 +10,9 @@ bind-key C-s send-prefix bind r source-file "$XDG_CONFIG_HOME/tmux/tmux.conf" set -g base-index 1 +set -g status-style 'bg=#45403d fg=#d4be98' +set -g status-left-length 30 + set-window-option -g mode-keys vi bind -T copy-mode-vi v send-keys -X begin-selection bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'pbcopy' @@ -21,58 +24,11 @@ bind -r j select-pane -D bind -r h select-pane -L bind -r l select-pane -R +bind -r D neww -c "#{pane_current_path}" "nvim TODO.md" -bind -r D neww -c "#{pane_current_path}" "[[ -e TODO.md ]] && nvim TODO.md || nvim ~/.dotfiles/personal/todo.md" +bind-key -r f run-shell "tmux neww ~/.config/tmux/tmux-sessionizer" +bind-key -r R run-shell "tmux neww ~/.config/tmux/tmux-sessionizer $XDG_CONFIG_HOME" +bind-key -r T run-shell "tmux neww ~/.config/tmux/tmux-sessionizer ~/Desktop/temp" -# theme - -## COLORSCHEME: gruvbox dark (medium) -set-option -g status "on" - -# default statusbar color -set-option -g status-style bg=colour237,fg=colour223 # bg=bg1, fg=fg1 - -# default window title colors -set-window-option -g window-status-style bg=colour214,fg=colour237 # bg=yellow, fg=bg1 - -# default window with an activity alert -set-window-option -g window-status-activity-style bg=colour237,fg=colour248 # bg=bg1, fg=fg3 - -# active window title colors -set-window-option -g window-status-current-style bg=red,fg=colour237 # fg=bg1 - -# pane border -set-option -g pane-active-border-style fg=colour250 #fg2 -set-option -g pane-border-style fg=colour237 #bg1 - -# message infos -set-option -g message-style bg=colour239,fg=colour223 # bg=bg2, fg=fg1 - -# writing commands inactive -set-option -g message-command-style bg=colour239,fg=colour223 # bg=fg3, fg=bg1 - -# pane number display -set-option -g display-panes-active-colour colour250 #fg2 -set-option -g display-panes-colour colour237 #bg1 - -# clock -set-window-option -g clock-mode-colour colour109 #blue - -# bell -set-window-option -g window-status-bell-style bg=colour167,fg=colour235 # bg=red, fg=bg - -## Theme settings mixed with colors (unfortunately, but there is no cleaner way) -set-option -g status-justify "left" -set-option -g status-left-style none -set-option -g status-left-length "80" -set-option -g status-right-style none -set-option -g status-right-length "80" -set-window-option -g window-status-separator "" - -set-option -g status-left "#[bg=colour241,fg=colour248] #S #[bg=colour237,fg=colour241,nobold,noitalics,nounderscore]" -set-option -g status-right "#[bg=colour237,fg=colour239 nobold, nounderscore, noitalics]#[bg=colour239,fg=colour246] %Y-%m-%d  %H:%M #[bg=colour239,fg=colour248,nobold,noitalics,nounderscore]#[bg=colour248,fg=colour237] #h " - -set-window-option -g window-status-current-format "#[bg=colour214,fg=colour237,nobold,noitalics,nounderscore]#[bg=colour214,fg=colour239] #I #[bg=colour214,fg=colour239,bold] #W#{?window_zoomed_flag,*Z,} #[bg=colour237,fg=colour214,nobold,noitalics,nounderscore]" -set-window-option -g window-status-format "#[bg=colour239,fg=colour237,noitalics]#[bg=colour239,fg=colour223] #I #[bg=colour239,fg=colour223] #W #[bg=colour237,fg=colour239,noitalics]" - -# vim: set ft=tmux tw=0 nowrap: +# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) +run '~/.config/tmux/plugins/tpm/tpm'