diff --git a/readme.md b/readme.md index ccc5291..769eb50 100644 --- a/readme.md +++ b/readme.md @@ -113,5 +113,7 @@ Two interpreted languages for flexibility. * apt * apt-file search | grep * ffmpeg +* tmux + * get unresolved path for new panes & windows ### 6.2 [Further tasks](#when) {#when-further} diff --git a/sh/tmux.sh b/sh/tmux.sh index a437b23..12f5820 100644 --- a/sh/tmux.sh +++ b/sh/tmux.sh @@ -45,6 +45,34 @@ rwx_tmux_servers() { IFS=\"\${ifs}\" echo \"\${text}\" } +rwx_tmux_status() { + local current=\"\${1}\" + local operand=\"\${2}\" + case \"\${operand}\" in + \"+\") + case \"\${current}\" in + \"off\") current=\"on\" ;; + \"on\") current=\"2\" ;; + \"2\") current=\"3\" ;; + \"3\") current=\"4\" ;; + \"4\") current=\"5\" ;; + *) ;; + esac + ;; + \"-\") + case \"\${current}\" in + \"on\") current=\"off\" ;; + \"2\") current=\"on\" ;; + \"3\") current=\"2\" ;; + \"4\") current=\"3\" ;; + \"5\") current=\"4\" ;; + *) ;; + esac + ;; + *) ;; + esac + tmux set-option -g status \"\${current}\" +} rwx_tmux_uptime() { local since=\"\$(uptime --since)\" local date=\"\$(echo \"\${since}\" | awk '{print \$1}')\" @@ -106,12 +134,16 @@ set-option -g set-titles on # set title to working directory set-option -g set-titles-string '\ #(sh -c \". ${script}; rwx_tmux_server\")\ - → \ + / \ #{session_name}\ - → \ -#{window_name} (#{window_index}∕#{session_windows})\ - → \ -#{pane_current_command} (#{pane_index}∕#{window_panes})\ + / \ +#{window_name}\ + / \ +#{pane_current_command}\ + - \ +#{window_width} × #{window_height}\ + / \ +#{pane_width} × #{pane_height}\ ' # ╭────────┬──────╮ @@ -155,6 +187,7 @@ set-option -g status-format[0] '\ #[fg=default]\ #[bg=default] \ } \ +\ #[align=right]\ #[fg=yellow]\ #[bg=##181818] \ @@ -179,6 +212,7 @@ set-option -g status-format[1] '\ #[fg=default]\ #[bg=default] \ } \ +\ #[align=right]\ #(sh -c \". ${script}; rwx_tmux_servers\")\ ' @@ -188,11 +222,8 @@ set-option -g status-format[2] '\ #[fg=cyan]#{pane_current_path}\ #[fg=default]\ #[bg=default] \ +\ #[align=right]\ -#[fg=yellow]\ -#[bg=##181818] \ -#[bg=##282828]#{session_name}\ -#[bg=##181818] \ ' # line 4 @@ -205,6 +236,7 @@ set-option -g status-format[3] '\ #[fg=default]\ #[bg=default] \ } \ +\ #[align=right]\ #(sh -c \". ${script}; rwx_tmux_uptime\")\ ' @@ -219,12 +251,7 @@ set-option -g status-format[4] '\ #[fg=default]\ #[bg=default] \ } \ -#[fg=green]\ -#[bg=##181818] \ -#[bg=##282828]#{window_width}×#{window_height}\ -#[bg=##181818] \ -#[fg=default]\ -#[bg=default] \ +\ #[align=right]\ #{?uid,#[fg=green],#[fg=red]}\ #[bg=##181818] \ @@ -268,6 +295,8 @@ bind-key -n C-F2 set-option -g status 2 bind-key -n C-F3 set-option -g status 3 bind-key -n C-F4 set-option -g status 4 bind-key -n C-F5 set-option -g status 5 +bind-key -n M-NPage run-shell '. ${script}; rwx_tmux_status #{status} -' +bind-key -n M-PPage run-shell '. ${script}; rwx_tmux_status #{status} +' # switch session bind-key -n M-Down switch-client -n @@ -286,8 +315,8 @@ bind-key C-s command-prompt { rename-session '%%' } bind-key C-w command-prompt { rename-window '%%' } # split window -bind-key h split-window -h -bind-key v split-window -v +bind-key h split-window -c '#{pane_current_path}' -h +bind-key v split-window -c '#{pane_current_path}' -v # kill server bind-key k kill-server