dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles
Log | Files | Refs | README | LICENSE Back to index

commit 9352f9503dc5b19b86767b3d1470385195b00bbf
parent be0963df5e99558fa0d75bcbe5649c99932710bd
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Tue, 21 May 2019 12:45:59 +0200

Use POSIX sh for mailstatus, clean up tmux conf

Diffstat:
A.local/bin/mailstatus | 35+++++++++++++++++++++++++++++++++++
M.tmux.conf | 61+++++++++++++++++++++++++------------------------------------
2 files changed, 60 insertions(+), 36 deletions(-)

diff --git a/.local/bin/mailstatus b/.local/bin/mailstatus @@ -0,0 +1,35 @@ +#!/bin/sh +maildir=~/mail +if [ ! -d $maildir ]; then + exit 0 +fi +newmails=$(find $maildir/*/INBOX/new $maildir/*/git/new -type f) +numbernewmails=$(echo "$newmails" | wc -w | sed 's/ *//') +mailboxes="$(echo "$newmails" | tr ' ' '\n' | \ + sed 's/.*\/mail\///;s/\/INBOX.*//;s/adamsgaard\/git.*/git/')" + +accounts="" + +contains() { + string="$1" + substring="$2" + if test "${string#*$substring}" != "$string" + then + return 0 # $substring is in $string + else + return 1 # $substring is not in $string + fi +} + +contains "$mailboxes" "adamsgaard" && accounts="${accounts}a" +contains "$mailboxes" "git" && accounts="${accounts}G" +contains "$mailboxes" "princeton" && accounts="${accounts}p" +contains "$mailboxes" "noaa" && accounts="${accounts}n" +contains "$mailboxes" "gmail" && accounts="${accounts}g" +contains "$mailboxes" "geomail" && accounts="${accounts}e" +contains "$mailboxes" "ucsd" && accounts="${accounts}u" +contains "$mailboxes" "riseup" && accounts="${accounts}r" + +if [ "$numbernewmails" -gt 0 ]; then + echo "M: ${numbernewmails} (${accounts})" +fi diff --git a/.tmux.conf b/.tmux.conf @@ -1,7 +1,7 @@ ### GENERAL set-option -g prefix C-a # Set prefix to <C-a> -bind a send-prefix # Send <C-a> with <C-a>a +bind a send-prefix # Send <C-a> with <C-a>a bind R source-file ~/.tmux.conf \; display "~/.tmux.conf reloaded" bind -n M-R source-file ~/.tmux.conf \; display "~/.tmux.conf reloaded" @@ -24,13 +24,13 @@ bind , rename-window "" \; command-prompt "rename-window '%%'" set -g default-terminal "screen-256color" # use 256 colors setw -g aggressive-resize on # resize window to smallest client -set -g pane-border-style fg=colour238 # border color for inactive panes -set -g pane-active-border-style fg=colour247 # border color for active panes +set -g pane-border-style fg=7 # border color for inactive panes +set -g pane-active-border-style fg=0 # border color for active panes # Status bar colors and format -setw -g window-status-format ' #[fg=#999999]#I #[fg=$666666]#W ' -setw -g window-status-current-format '#[fg=#ffffff] #I #W#[fg=#ffffff] ' -setw -g window-status-separator '#[fg=#292929]|#[fg=default]' +setw -g window-status-format ' #[fg=7]#I #[fg=7]#W ' +setw -g window-status-current-format '#[fg=6] #I #W#[fg=default] ' +setw -g window-status-separator '#[fg=7]|#[fg=default]' set -g status-bg default # background color for status bar set -g status-position bottom # put status bar on top or bottom set -g status-interval 2 # interval in s to update status @@ -49,10 +49,9 @@ bind t set status on bind T set status off # Right section of status bar -if-shell 'uname | grep -qi Darwin' "set -g status-right -\"#[fg=#81a2be]#(/usr/local/bin/mpc | head -n 1 | sed 's/volume.*$//') #[fg=cyan]#(~/.local/bin/battery-osx) #(~/.local/bin/mailstatus) #[fg=yellow]#(uptime|sed 's/.* //') #[fg=#666666]%F #[fg=#bababa]%R\"" +if-shell 'uname | grep -qi Darwin' "set -g status-right \"#[fg=#81a2be]#(/usr/local/bin/mpc | head -n 1 | sed 's/volume.*$//') #[fg=cyan]#(~/.local/bin/battery-osx) #(~/.local/bin/mailstatus) #[fg=yellow]#(uptime|sed 's/.* //') #[fg=#666666]%F #[fg=#bababa]%R\"" -if-shell 'uname | grep -qi Linux' "set -g status-right \"#(~/.local/bin/sysstatus)\"" +if-shell 'uname | grep -qi Linux' "set -g status-right \"#[fg=7]#(sysstatus)\"" # Scaling of status-bar sections set -g status-right-length 40 @@ -61,10 +60,10 @@ set -g status-right-length 40 #### NAVIGATION # With C-a prefix -bind h select-pane -L # navigate left with <C-a>h -bind j select-pane -D # navigate down with <C-a>j -bind k select-pane -U # navigate up with <C-a>k -bind l select-pane -R # navigate right with <C-a>l +bind h select-pane -L # navigate left with <C-a>h +bind j select-pane -D # navigate down with <C-a>j +bind k select-pane -U # navigate up with <C-a>k +bind l select-pane -R # navigate right with <C-a>l bind -r H resize-pane -L 5 # resize pane left with <C-a>H bind -r J resize-pane -D 5 # resize pane down with <C-a>J bind -r K resize-pane -U 5 # resize pane up with <C-a>K @@ -92,16 +91,15 @@ bind -n M-8 select-window -t :=8 bind -n M-9 select-window -t :=9 bind -n M-0 select-window -t :=10 -bind C-s last-window # go to last window with <C-a><C-s> -bind C-a last-pane # go to last pane with <C-a><C-a> -bind -n M-s last-window # go to last pane with M-s -bind -n M-a last-pane # go to last pane with M-a -bind -r n next-window # next window with <C-a>n -bind -r b previous-window # next window with <C-a>p +bind C-s last-window # go to last window with <C-a><C-s> +bind C-a last-pane # go to last pane with <C-a><C-a> +bind -n M-s last-window # go to last pane with M-s +bind -n M-a last-pane # go to last pane with M-a +bind -r n next-window # next window with <C-a>n +bind -r b previous-window # next window with <C-a>p +bind -n -r M-n next-window # next window with <M-n> +bind -n -r M-b previous-window # previous window with <M-n> -bind -n -r M-n next-window # next window with <M-n> -bind -n -r M-b previous-window # previous window with <M-n> -#bind -n M-, run-shell "tmux list-panes -as -F \"##I.##P ##{pane_current_command} . #{pane_current_path} (#W)#F\" | fzf-tmux | cut -d \" \" -f 1 | xargs tmux select-pane -t" bind -n M-, run-shell "tmux list-windows -F \"##I:##W\" | fzf-tmux | cut -d \":\" -f 1 | xargs tmux select-window -t" bind -n M-. run-shell "tmux list-sessions -F \"##S\" | fzf-tmux | xargs tmux switch -t" @@ -116,15 +114,11 @@ bind -r z resize-pane -Z # toggle pane zoom with <C-a>z bind -r y next-layout # cycle to next pane layout with <C-a>y bind -r Y previous-layout # cycle to previous pane layout with <C-a>Y bind -r r rotate-window # rotate panes with <C-a>r - bind -n M-z resize-pane -Z # toggle pane zoom with <M-z> bind -n -r M-y next-layout # cycle to next pane layout with <M-y> bind -n -r M-Y previous-layout # cycle to previous pane layout with <M-Y> bind -n -r M-r rotate-window # rotate panes with <M-r> -bind -r Left swap-window -t -1 # Swap window left -bind -r Right swap-window -t +1 # Swap window right - bind -r B swap-window -t -1 # Swap window left bind -r N swap-window -t +1 # Swap window right bind -n -r M-B swap-window -t -1 # Swap window left @@ -164,15 +158,15 @@ bind u capture-pane -J \; \ bind o split-window -p 25 '$SHELL -c "offlineimap -qf INBOX"' \; select-pane -l bind O split-window -p 25 '$SHELL -c "offlineimap"' \; select-pane -l -# Use nested bindings (<C-a>l) for grouping process launch bindings -bind -n C-M-v new-window -n vim "/usr/local/bin/vim" +bind -n C-M-v new-window -n vim "vim" bind -n C-M-w new-window -n weather \ "curl 'wttr.in/?m'; echo -e '\nPress <enter> to quit'; read -n 1 -s" # Open new window and resize status accordingly (should be a hook instead) -bind Enter new-window -c "#{pane_current_path}" "$SHELL" -bind -n M-Enter new-window \ - "tmux set status-right-length `echo $(tput cols)/2|bc|tr -d '\n'`; zsh" +bind Enter new-window -c "#{pane_current_path}" \ + "tmux set status-right-length `echo $(tput cols)/2|bc|tr -d '\n'`; $SHELL" +bind -n M-Enter new-window -c "#{pane_current_path}" \ + "tmux set status-right-length `echo $(tput cols)/2|bc|tr -d '\n'`; $SHELL" # Use nested bindings (<C-a>m) for grouping music-control bindings bind m switchc -Tmpd @@ -183,17 +177,12 @@ bind -Tmpd s display "#(mpc stop | tr '\n' ' ')" bind -Tmpd n display "#(mpc next | tr '\n' ' ')" bind -Tmpd b display "#(mpc prev | tr '\n' ' ')" bind -Tmpd r display "#(mpc clear && mpc ls | mpc add && mpc random on && mpc play | tr '\n' ' ')" -#bind -Tmpd r new-window -n mpc "mpc clear && mpc ls | mpc add && mpc shuffle && mpc play" bind -n C-M-p display "#(mpc toggle | tr '\n' ' ')" bind -n C-M-s display "#(mpc stop | tr '\n' ' ')" bind -n C-M-n display "#(mpc next | tr '\n' ' ')" bind -n C-M-b display "#(mpc prev | tr '\n' ' ')" -#bind -n C-M-r display "#(mpc clear && mpc ls | mpc add && mpc random on && mpc play | tr '\n' ' ')" bind -n C-M-a split-window -p 50 "source ~/code/fzf-mpd/fzf-mpd.zsh && fm" -# fzf-locate from entire file system and insert result in current pane (Alt-`) -bind -n 'M-`' run "tmux split-window -p 40 'tmux send-keys -t #{pane_id} \"$(locate / | fzf -m | paste -sd\\ -)\"'" - # Change to the previous pane, repeat the last command, change back bind -n M-! last-pane \; send-keys C-p C-m \; last-pane