Tips_And_Tricks.mdwn
changeset 1 1e57279b82b1
equal deleted inserted replaced
0:eff7327bcabe 1:1e57279b82b1
       
     1 
       
     2 [[!toc]]
       
     3 
       
     4 # Multi-line messages
       
     5 
       
     6 You can send multi-line messages with the `/msay` command (see the [manpage][]
       
     7 for usage details).
       
     8 
       
     9 You can bind `/msay toggle` and/or `/msay toggle_verbatim` so that you can
       
    10 switch quickly to/from multi-line mode:
       
    11 
       
    12     # Alt-m to switch to/from multi-line mode
       
    13     bind M109 = msay toggle
       
    14     # Alt-M to switch to/from _verbatim_ multi-line mode
       
    15     bind M77 = msay toggle_verbatim
       
    16 
       
    17 With mcabber 0.10 you can try the module extsay if you're using the screen
       
    18 utility (see the [[Modules]] page).
       
    19 
       
    20 # Jump to a contact
       
    21 
       
    22 You can use `/roster search` to jump to a contact in your roster. You can even
       
    23 bind a key, for example if you talk very often with john.doe@jabber.foo, you can
       
    24 bind the F1 key:
       
    25 
       
    26     bind 265 = roster search john.doe
       
    27 
       
    28 **Note:** this command only looks for the contact in the displayed buddy, so if you
       
    29 hide offline buddies it won't find a disconnected contact.
       
    30 
       
    31 You may want to create an alias for this command, if you use it a lot:
       
    32 
       
    33     alias rsearch = roster search
       
    34 
       
    35 With the completion, you only need to type `/rs<tab>` now.
       
    36 
       
    37 # One history for multiple buddies
       
    38 
       
    39 (You'll need mcabber >=0.9.2 for that feature)  
       
    40 You're using jabber with several transports and you have some buddies who are
       
    41 using more than one chat protocol?  mcabber is able to share one history file
       
    42 between all of them.
       
    43 
       
    44 Let's say you have a contact abc@jabber.org and abc@icq.jabber.org. First of
       
    45 all, you have to merge both histories with `merge_history.py`, so that old data
       
    46 won't be lost.
       
    47 
       
    48     $ cd ~/.mcabber/histo/
       
    49     $ merge_history abc\@jabber.org abc\@icq.jabber.org > abc
       
    50     $ mv abc abc\@jabber.org
       
    51     $ rm abc\@icq.jabber.org
       
    52 
       
    53 Now you have to create a symlink(abc@icq.jabber.org -> abc@jabber.org):
       
    54 
       
    55     $ ln -sf abc\@jabber.org abc\@icq.jabber.org
       
    56 
       
    57 After a restart, mcabber will load the history only once for both contacts. Both
       
    58 JIDs are sharing this history now. Commands relating to the chat buffer, such as
       
    59 `/buffer scroll_lock/purge/clean` on one buddy will change the buffer of the
       
    60 other buddy as well (because it's internally the same buffer).
       
    61 
       
    62 Of course it is possible to link more than two buddies to one history... :)
       
    63 
       
    64 # Indication of transported buddies availability
       
    65 
       
    66 Using FIFO feature and eventcmd script you can mark transported buddies with
       
    67 different color, when transport is not connected. In `mcabberrc`:
       
    68 
       
    69     color roster clear
       
    70     color roster *     *                green
       
    71     color roster dn_?  *                brightblack
       
    72     color roster *     *@icq.jabber.org red
       
    73     color roster dn_?  *@icq.jabber.org red
       
    74 
       
    75 This will mark transported buddies as unavailable initially. Then in
       
    76 `eventcmd.sh`, when processing `STATUS` event ( `"$1" = 'STATUS'` )
       
    77 
       
    78     if [ "$3" = 'icq.jabber.org' ]; then
       
    79             if [ "$2" = '_' ]; then
       
    80                     echo "color roster * *@icq.jabber.org red" > ~/.mcabber/fifo
       
    81                     echo "color roster dn_? *@icq.jabber.org red" > ~/.mcabber/fifo
       
    82             else
       
    83                     echo "color roster * *@icq.jabber.org white" > ~/.mcabber/fifo
       
    84                     echo "color roster dn_? *@icq.jabber.org brightblack" > ~/.mcabber/fifo
       
    85             fi
       
    86     fi
       
    87 
       
    88 This will change their color, when transport becomes available/unavailable.
       
    89 
       
    90 # Delayed actions (eg message for 'dnd' buddy)
       
    91 
       
    92 You can delay some action until buddy becomes available or some other event
       
    93 happens. Add to `eventcmd.sh`:
       
    94 
       
    95     if [ -f ~/.mcabber/jobs/"$1_$2_$3" ]; then
       
    96             cat ~/.mcabber/jobs/"$1_$2_$3" > ~/.mcabber/fifo
       
    97             rm ~/.mcabber/jobs/"$1_$2_$3"
       
    98     fi
       
    99 
       
   100 and create jobs dir:
       
   101 
       
   102     $ mkdir ~/.mcabber/jobs/
       
   103 
       
   104 Then you can do something like this:
       
   105 
       
   106     $ cat > ~/.mcabber/jobs/STATUS_O_buddy@jabber.org <<EOF
       
   107     > say_to -q buddy@jabber.org Hi, this is a jobbed message
       
   108     > say_to -q buddy@jabber.org Please, when you will have free time, do this and that.
       
   109     > EOF
       
   110 
       
   111 That will not bother buddy while he is 'dnd', and you won't have to keep your
       
   112 message in mind.
       
   113 
       
   114 # Folding groups on start
       
   115 
       
   116 With a hooks feature you can fold infrequently used groups (eg transports and
       
   117 other services) on startup. In `mcabberrc`:
       
   118 
       
   119     set hook-post-connect   = source ~/.mcabber/post-connect.rc
       
   120     set hook-pre-disconnect = source ~/.mcabber/pre-disconnect.rc
       
   121 
       
   122 and in `~/.mcabber/post-connect.rc`:
       
   123 
       
   124     group fold Transports
       
   125     group fold Old
       
   126 
       
   127 # Auto-Away and Screen
       
   128 
       
   129 So, we all want an auto-away but love to keep mcabber ticking away in a screen
       
   130 session. By putting the following into your `~/.logout` (or `~/.bash_logout` if
       
   131 you use BASH), you should get what you are looking for:
       
   132 
       
   133     # mcabber auto-away - probably a Linux only solution as we use /proc
       
   134     if [ -p .mcabber/mcabber.fifo ]; then
       
   135       MCABBER_PID=$(pgrep -u $USER mcabber)
       
   136       if [ -n $MCABBER_PID ]; then
       
   137         MCABBER_STY=$(cat /proc/$MCABBER_PID/environ | tr '\0' '\n' | grep '^STY=' | cut -d'=' -f2)
       
   138     
       
   139         if [ -n $MCABBER_STY ]; then
       
   140           if [ -z "$(screen -list | grep $MCABBER_STY.*\(Attached\))" ]; then
       
   141             echo /status notavail > .mcabber/mcabber.fifo
       
   142           fi
       
   143         fi
       
   144       fi
       
   145     fi
       
   146 
       
   147 [manpage]: http://www.lilotux.net/~mikael/mcabber/files/mcabber.1.html
       
   148