On Thu, May 10, 2012 at 04:39:33PM -0400, Ed Blackman wrote:
On Thu, May 10, 2012 at 06:58:28PM +0700, Diep Pham Van wrote:
Sometimes when reading a new mail, I must going to an other folder and
after some searching, I have no idea where is my previous
folder.

Or is there some tool that I don't know but every one use to make your
life with mutt easier?

I read mutt inside of screen, and use a macro to change folders such that the new folders is opened in a separate screen window, keeping the original folder where I left it.

macro index F '<sync-mailbox><enter-command>set my_folder=`mutt-prompt "Change to folder" \\`; push "!screen -X screen mutt -f $my_folder\<enter\>"<enter>'

That's all one line. It uses mutt-prompt, which I got from this mailing list a while ago. I'd be happy to post or send it if anyone's interested.

Diep Pham Van replied in an email direct to me: "Post it please. And how can I use this with tmux? :D"

I've attached it. It's mostly as I received it, though I added a line to change directory to $HOME/mail, which is where $folder points to. That lets me use tab completion to enter the names of mailboxes under $folder. This will only work for local mailboxes, though.

I don't know tmux, but "screen -X screen <command>" tells a running screen to open a new window running <command>. If I typed "screen -X screen mutt" at a command prompt in a screen window, screen will create a new screen window running mutt and switch to it. The macro uses that to switch to a new window running mutt in the given folder.

I presume that tmux has something similar, and someone more familiar with tmux may help you adjust the macro.

--
Ed Blackman
#!/bin/bash
##
## usage: mutt-prompt "prompt text"
## 
## In muttrc:
##   set my_var=`mutt-prompt "Folder"`
##

cd ~/mail

# save current tty state
s=`stty -g`

# redirect default i/o, saving current stdout in fd 5
exec 5>&1
exec >/dev/tty </dev/tty

# reset tty state
stty icanon sane onlcr
stty erase 

# position cursor at bottom of screen
rows=`tput lines`
rows=`expr $rows - 1`
tput cup $rows 0

# print prompt and read response
printf "${1}: "
read -e answer

# return response to mutt
echo "$answer" >&5

# reset tty state
stty "$s"

Attachment: signature.txt
Description: Digital signature

Reply via email to