Added unread mail count to tmux pane

Unread mail count comes from an AppleScript that asks Mail.app
This commit is contained in:
Nick Nisi
2012-09-29 18:50:23 -05:00
parent 5d26e75ae6
commit 1f6f09e457
5 changed files with 78 additions and 13 deletions

0
bin/itunes.applescript → bin/itunes.scpt Normal file → Executable file
View File

65
bin/mail.scpt Executable file
View File

@@ -0,0 +1,65 @@
#!/usr/bin/osascript
property defaultAccount : "Pollen"
property defaultMailbox : "INBOX"
on run args
set justUnread to false
set theAccount to missing value
set theMailbox to missing value
if defaultAccount = missing value then set defaultAccount to "-g"
if defaultMailbox = missing value then set defaultMailbox to "INBOX"
set theCount to the count of args
if theCount > 0 then
if item 1 of args = "-u" then
set justUnread to true
set theCount to theCount - 1
set args to the rest of args
else if item 1 of args = "-ug" or item 1 of args = "-gu" then
set justUnread to true
set item 1 of args to "-g"
else if theCount > 1 and ¬
item 1 of args = "-g" and item 2 of args = "-u" then
set justUnread to true
set theCount to theCount - 1
set args to the rest of args
set item 1 of args to "-g"
end if
end if
tell application "Mail"
if theCount = 0 then
set theAccount to defaultAccount
set theMailbox to defaultMailbox
else if theCount = 1 then
set theAccount to item 1 of args
set theMailbox to defaultMailbox
else if theCount = 2 then
set theAccount to item 1 of args
set theMailbox to item 2 of args
else
error character id 10 ¬
& "Usage: inbox-count [-u] [[account] mailbox]" & character id 10 ¬
& " inbox-count [-u] -g [mailbox]"
end if
set mailboxValue to missing value
if theAccount = "-g" then
if theMailbox = "INBOX" then
set mailboxValue to inbox
else
set mailboxValue to mailbox theMailbox
end if
else
set mailboxValue to mailbox theMailbox of account theAccount
end if
if justUnread then
return the unread count of mailboxValue
else
return the count of messages of mailboxValue
end if
end tell
end run

0
bin/rdio.applescript → bin/rdio.scpt Normal file → Executable file
View File

0
bin/spotify.applescript → bin/spotify.scpt Normal file → Executable file
View File

View File

@@ -101,7 +101,7 @@ bind -t vi-copy 'y' copy-selection
#### COLOUR
# default statusbar colors
set-option -g status-bg colour234
set-option -g status-bg colour232
set-option -g status-fg colour26
set-option -g status-attr default
@@ -120,7 +120,7 @@ set-option -g pane-border-fg colour245
set-option -g pane-active-border-fg colour240
# message text
set-option -g message-bg colour234
set-option -g message-bg colour232
set-option -g message-fg colour26
# pane number display
@@ -134,23 +134,23 @@ set-window-option -g clock-mode-colour colour26
#### Plugins #####
##################
# current Spotify track
spotify_track='#[fg=colour2]#(osascript ~/.dotfiles/bin/spotify.applescript)'
# current iTunes track
itunes_track='#[fg=colour27]#(osascript ~/.dotfiles/bin/itunes.applescript)'
# current Rdio track
rdio_track='#[fg=colour127]#(osascript ~/.dotfiles/bin/rdio.applescript)'
tm_spotify_track='#[fg=colour2]#(osascript ~/.dotfiles/bin/spotify.applescript)'
tm_itunes_track='#[fg=colour27]#(osascript ~/.dotfiles/bin/itunes.applescript)'
tm_rdio_track='#[fg=colour127]#(osascript ~/.dotfiles/bin/rdio.applescript)'
tm_date='#[fg=colour245] %R %d %b'
tm_host='#[fg=colour198,bg=colour234,bold]#h'
tm_host='#[fg=colour198,bg=colour232,bold]#h'
tm_session_name='#[fg=colour198,bg=colour232,bold] ❤ #S'
tm_mail='#[fg=colour196,bold]✉ #(~/.dotfiles/bin/mail.scpt -ug)'
set -g status-left-length 32
set -g status-right-length 150
set -g status-interval 20
set -g window-status-format "#[fg=colour239,bg=colour234] #I #W "
set -g window-status-format "#[fg=colour239,bg=colour232] #I #W "
set -g window-status-current-format "#[fg=colour234,bg=colour26]#[fg=colour16,bg=colour26,noreverse,bold] #I #W #[fg=colour26,bg=colour234,nobold]"
set -g status-left '#[fg=colour198,bg=colour234,bold] #S'
set -g status-right $itunes_track' '$spotify_track' '$tm_date' '$tm_host
# set -g window-status-current-format "#[fg=colour232,bg=colour26]#[fg=colour16,bg=colour26,noreverse,bold] #I #W #[fg=colour26,bg=colour232,nobold]"
set -g window-status-current-format "#[fg=colour232,bg=colour26]#[fg=colour16,bg=colour26,noreverse,bold] #I #W #[fg=colour26,bg=colour232,nobold]"
set -g status-left $tm_session_name
set -g status-right $tm_itunes_track' '$tm_spotify_track' '$tm_mail' '$tm_date' '$tm_host