├── LICENSE ├── README.md ├── maildir_counter.tmux └── screenshots └── maildir_counter.png /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Erick Pintor 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Tmux maildir counter 2 | 3 | **NOTE:** This project is no longer in active development. Bugs and 4 | features requests won't get implemented by the project maintainers. 5 | We still welcome discussions and community pull requests, though. 6 | 7 | --- 8 | 9 | Plugin that counts files on a specific mail directory. 10 | 11 | If you use [offlineimap](http://offlineimap.org/) to synchronize your emails with your computer, 12 | you can use this plugin to count how many emails you have in a specific folder and display in your tmux 13 | left or right status bar. 14 | 15 | Shows how many unread emails I have in both my personal and work accounts: 16 | ![prefix_off](screenshots/maildir_counter.png) 17 | 18 | ### Usage 19 | 20 | Add the list of folders you want to count to your `tmux.conf`. All folders must be separated by `|`. 21 | 22 | ```tmux.conf 23 | set -g @maildir_counters '~/Mail/Personal/INBOX/new|~/Mail/Work/INBOX/new' 24 | ``` 25 | 26 | Then, add the `maildir_counter` to your left/right status bar where `N` is the index of the folder you want to show. 27 | 28 | ```tmux.conf 29 | set -g status-right 'Personal: #{maildir_counter_1}, Work: #{maildir_counter_2} | %a %Y-%m-%d %H:%M' 30 | ``` 31 | 32 | If you want to get unread count, pass only the path of the IMAP folder and plugin will check `cur` and `new` subfolders, filter them and present any unread mail. Omit trailing slash. 33 | 34 | ```tmux.conf 35 | set -g @maildir_counters '~/Mail/Personal/INBOX/new|~/Mail/Work/INBOX' 36 | ``` 37 | 38 | Then, add the `maildir_unread_counter` variable and set it to `yes`: 39 | 40 | ```tmux.conf 41 | set -g @maildir_unread_counter 'yes' 42 | ``` 43 | 44 | ### Installation with Tmux Plugin Manager (recommended) 45 | 46 | Add plugin to the list of TPM plugins: 47 | 48 | ```tmux.conf 49 | set -g @plugin 'tmux-plugins/tmux-maildir-counter' 50 | ``` 51 | 52 | Press prefix + I to install it. 53 | 54 | ### Manual Installation 55 | 56 | Clone the repo: 57 | 58 | ```bash 59 | $ git clone https://github.com/tmux-plugins/tmux-maildir-counter.git ~/clone/path 60 | ``` 61 | 62 | Add this line to your .tmux.conf: 63 | 64 | ```tmux.conf 65 | run-shell ~/clone/path/tmux-maildir-counter.tmux 66 | ``` 67 | 68 | Reload TMUX environment with: 69 | 70 | ```bash 71 | $ tmux source-file ~/.tmux.conf 72 | ``` 73 | 74 | ### License 75 | 76 | [MIT](LICENSE) 77 | -------------------------------------------------------------------------------- /maildir_counter.tmux: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | # Place holder for status left/right 6 | place_holder="\#{maildir_counter_N}" 7 | 8 | # Possible configurations. 9 | # MUST contain the list of folders separated by | 10 | maildir_counters='@maildir_counters' 11 | maildir_unread_counter='@maildir_unread_counter' 12 | 13 | interpolate() { 14 | local -r status="$1" 15 | local -r counter="${place_holder/N/$2}" 16 | local -r count_files="#(ls -1 $3 | wc -l | xargs)" 17 | local -r count_files_cur="#(ls -1 $3/cur | grep -v ':2,.*S' | wc -l | xargs)" 18 | local -r count_files_new="#(ls -1 $3/new | wc -l | xargs)" 19 | 20 | local -r enable_unread_counter=$4 21 | 22 | local count_files_output=$count_files 23 | if [ "$enable_unread_counter" == 'yes' ]; then 24 | count_files_output=$count_files_cur+$count_files_new 25 | fi 26 | local -r status_value=$(tmux show-option -gqv "$status") 27 | tmux set-option -gq "$status" "${status_value//$counter/$count_files_output}" 28 | } 29 | 30 | main() { 31 | IFS=\| 32 | local i=1 33 | local toggle_unread_counter=$(tmux show-option -gqv "$maildir_unread_counter") 34 | for maildir in $(tmux show-option -gqv "$maildir_counters"); do 35 | interpolate "status-left" "$i" "$maildir" "$toggle_unread_counter" 36 | interpolate "status-right" "$i" "$maildir" "$toggle_unread_counter" 37 | i=$((i+1)) 38 | done 39 | } 40 | 41 | main 42 | -------------------------------------------------------------------------------- /screenshots/maildir_counter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tmux-plugins/tmux-maildir-counter/68136a8020815f99eeba88bc0aae807a465e0e29/screenshots/maildir_counter.png --------------------------------------------------------------------------------