Skip to content

Instantly share code, notes, and snippets.

@orotalt
Forked from pascalpoitras/1.md
Created July 27, 2019 21:25
Show Gist options
  • Select an option

  • Save orotalt/a5635f902aa734d11732fce395014682 to your computer and use it in GitHub Desktop.

Select an option

Save orotalt/a5635f902aa734d11732fce395014682 to your computer and use it in GitHub Desktop.

Revisions

  1. @pascalpoitras pascalpoitras revised this gist Jul 12, 2019. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions myweechat.md
    Original file line number Diff line number Diff line change
    @@ -448,6 +448,7 @@ If you wonder why I replace +,\*,! and comma from the url, it is because those h

    ## nullpointer (https://0x0.st)

    ![WeeChat Screenshot](http://192.99.68.133/byzanz-record-2019-07-12-195000.gif)

    /alias add nullpointer /exec -sh -hsignal nullpointer $* 2>&1 | curl -sfSF file=@- https://0x0.st
    /trigger add nullpointer hsignal nullpointer
  2. @pascalpoitras pascalpoitras revised this gist Jul 12, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion myweechat.md
    Original file line number Diff line number Diff line change
    @@ -462,7 +462,7 @@ Well If we use this, the input bar will be filled with the command and not the u

    ## Dev info

    ![WeeChat Screenshot](http://192.99.68.133/2018-02-25-225802_1559x98_scrot.png)
    ![WeeChat Screenshot](http://192.99.68.133/2019-07-12-190937_1505x58_scrot.png)

    /trigger add devinfo hsignal devinfo
    /trigger set devinfo conditions ${err}==
  3. @pascalpoitras pascalpoitras revised this gist Jul 12, 2019. 1 changed file with 2 additions and 9 deletions.
    11 changes: 2 additions & 9 deletions myweechat.md
    Original file line number Diff line number Diff line change
    @@ -464,21 +464,14 @@ Well If we use this, the input bar will be filled with the command and not the u

    ![WeeChat Screenshot](http://192.99.68.133/2018-02-25-225802_1559x98_scrot.png)

    /trigger add devinfofr hsignal devinfofr
    /trigger set devinfofr conditions ${err}==
    /trigger set devinfofr regex "/([0-9]{4})-01-([0-9]{2})/${re:2} Janvier ${re:1}/out /([0-9]{4})-02-([0-9]{2})/${re:2} Février ${re:1}/out /([0-9]{4})-03-([0-9]{2})/${re:2} Mars ${re:1}/out /([0-9]{4})-04-([0-9]{2})/${re:2} Avril ${re:1}/out /([0-9]{4})-05-([0-9]{2})/${re:2} Mai ${re:1}/out /([0-9]{4})-06-([0-9]{2})/${re:2} Juin ${re:1}/out /([0-9]{4})-07-([0-9]{2})/${re:2} Juillet ${re:1}/out /([0-9]{4})-08-([0-9]{2})/${re:2} Août ${re:1}/out /([0-9]{4})-09-([0-9]{2})/${re:2} Septembre ${re:1}/out /([0-9]{4})-10-([0-9]{2})/${re:2} Octobre ${re:1}/out /([0-9]{4})-11-([0-9]{2})/${re:2} Novembre ${re:1}/out /([0-9]{4})-12-([0-9]{2})/${re:2} Décembre ${re:1}/out /.*/\n${out}/out /.*/${out}/stable /.*/${out}/stable_date /.*/${out}/devel /.*/${out}/next_stable_date /.*\nstable:([^\n]+).*/La version stable de WeeChat est la ${re:1}./stable /.*\nstable_date:([^\n]+).*/Elle est la version stable depuis le ${re:1}${info:ruby_eval,require 'date'; print ' (' + (Date.today.mjd - Date.parse('${re:1}').mjd).to_s + ' jours)'}./stable_date /.*\ndevel:([^\n]+).*/La version devel de WeeChat est la ${re:1}./devel /.*\nnext_stable_date:([^\n]+).*/La prochaine stable devrait arriver aux alentour du ${re:1}${info:ruby_eval,require 'date'; print ' (' + (Date.parse('${re:1}').mjd - Date.today.mjd).to_s + ' jours)'}./next_stable_date"
    /trigger set devinfofr command "/command -buffer ${buffer.full_name} * /say ${stable} ${stable_date} ${devel} ${next_stable_date}"

    /trigger add devinfo hsignal devinfo
    /trigger set devinfo conditions ${err}==
    /trigger set devinfo regex "/([0-9]{4})-01-([0-9]{2})/January ${re:2} ${re:1}/out /([0-9]{4})-02-([0-9]{2})/February ${re:2} ${re:1}/out /([0-9]{4})-03-([0-9]{2})/March ${re:2} ${re:1}/out /([0-9]{4})-04-([0-9]{2})/April ${re:2} ${re:1}/out /([0-9]{4})-05-([0-9]{2})/May ${re:2} ${re:1}/out /([0-9]{4})-06-([0-9]{2})/June ${re:2} ${re:1}/out /([0-9]{4})-07-([0-9]{2})/July ${re:2} ${re:1}/out /([0-9]{4})-08-([0-9]{2})/August ${re:2} ${re:1}/out /([0-9]{4})-09-([0-9]{2})/September ${re:2} ${re:1}/out /([0-9]{4})-10-([0-9]{2})/October ${re:2} ${re:1}/out /([0-9]{4})-11-([0-9]{2})/November ${re:2} ${re:1}/out /([0-9]{4})-12-([0-9]{2})/December ${re:2} ${re:1}/out /.*/\n${out}/out /.*/${out}/stable /.*/${out}/stable_date /.*/${out}/devel /.*/${out}/next_stable_date /.*\nstable:([^\n]+).*/The stable version of WeeChat is ${re:1}./stable /.*\nstable_date:([^\n]+).*/It is the stable version since ${re:1}${info:ruby_eval,require 'date'; print ' (' + (Date.today.mjd - Date.parse('${re:1}').mjd).to_s + ' days)'}./stable_date /.*\ndevel:([^\n]+).*/The devel version of WeeChat is ${re:1}./devel /.*\nnext_stable_date:([^\n]+).*/The next stable should be release around ${re:1}${info:ruby_eval,require 'date'; print ' (' + (Date.parse('${re:1}').mjd - Date.today.mjd).to_s + ' days)'}./next_stable_date"
    /trigger set devinfo command "/command -buffer ${buffer.full_name} * /say ${stable} ${stable_date} ${devel} ${next_stable_date}"

    /alias add devinfo /exec -norc -timeout 5 -hsignal devinfo url:https://weechat.org/dev/info/all/
    /alias add devinfofr /exec -norc -timeout 5 -hsignal devinfofr url:https://weechat.org/dev/info/all/

    /alias add devinfo /exec -norc -timeout 5 -hsignal devinfo url:https://weechat.org/dev/info/all/

    These alias send info about the current stable version of WeeChat and the next stable to the channel. The alias call exec and the output of exec is send as a hsignal. So the triggers handle the output.
    Thi alias send info about the current stable version of WeeChat and the next stable to the channel. The alias call exec and the output of exec is send as a hsignal. So the trigger handle the output.


    ## translate with translate-shell (need the escape_shell_single_quote trigger)
  4. @pascalpoitras pascalpoitras revised this gist Jul 12, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion myweechat.md
    Original file line number Diff line number Diff line change
    @@ -444,7 +444,7 @@ Note: The url and the date will not appears in log. This is a consequence of usi

    This trigger will be triggered when we press 'i' or 'm' on a news in cursor mode (in general we invoke this with the middle mouse button). 'i' insert the URL in the input bar. If the URL is too long to view it all, simply press return to send it to the channel, which anyway is +m so nobody will see it, and press alt+l to go in bare mode (so you can click on the URL). 'm' is more interesting, generally when you press 'm' in cursor mode, you add the message in the input bar, but remember, the message does not contain the URL anymore, so it is useless to send the title to someone without the URL. So, in this channel, 'm' is different. The URL is added back to the message.

    If you wonder why I replace +,*,! and comma from the url, it is because those have a special meaning in the tag mechanism or in /filter and it will be hard to, for example, filter on a tag containing a comma. I replace them by ASCII control characters in percent-encoding style. At first, I was replacing them by their equivalent percent-encoding style so for example + became %2B. The problem is that we must replace %2B by + when we retrieve the url from the tag later, because a + have a special meaning in url but not %2B (so this will not be the same url). But this will replace any %2B to +, even those that was originally %2B not +. So, instead, I use the first four ASCII control characters (in uri escape form) for +,*,! and comma. Therefore, this will replace + by %00 , by %01 ! by %02 and * by %03, then when you press 'i' in cursor mode, the %00 will become +, %01 will become , and so on.
    If you wonder why I replace +,\*,! and comma from the url, it is because those have a special meaning in the tag mechanism or in /filter and it will be hard to, for example, filter on a tag containing a comma. I replace them by ASCII control characters in percent-encoding style. At first, I was replacing them by their equivalent percent-encoding style so for example + became %2B. The problem is that we must replace %2B by + when we retrieve the url from the tag later, because a + have a special meaning in url but not %2B (so this will not be the same url). But this will replace any %2B to +, even those that was originally %2B not +. So, instead, I use the first four ASCII control characters (in uri escape form) for +,\*,! and comma. Therefore, this will replace + by %00 , by %01 ! by %02 and \* by %03, then when you press 'i' in cursor mode, the %00 will become +, %01 will become , and so on.

    ## nullpointer (https://0x0.st)

  5. @pascalpoitras pascalpoitras revised this gist Jul 12, 2019. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions myweechat.md
    Original file line number Diff line number Diff line change
    @@ -444,8 +444,7 @@ Note: The url and the date will not appears in log. This is a consequence of usi

    This trigger will be triggered when we press 'i' or 'm' on a news in cursor mode (in general we invoke this with the middle mouse button). 'i' insert the URL in the input bar. If the URL is too long to view it all, simply press return to send it to the channel, which anyway is +m so nobody will see it, and press alt+l to go in bare mode (so you can click on the URL). 'm' is more interesting, generally when you press 'm' in cursor mode, you add the message in the input bar, but remember, the message does not contain the URL anymore, so it is useless to send the title to someone without the URL. So, in this channel, 'm' is different. The URL is added back to the message.

    If you wonder why I replace +,*,! and comma from the url, it is because those have a special meaning in the tag mechanism and it will be hard to, for example, filter on a tag containing a comma. I replace them by ASCII control characters. At first, I was replacing them by their equivalent uri escape so for example + became %2B. The problem is that we must replace %2B by + when we retrieve the url from the tag later, because a + have a special meaning in url but not %2B (so this will not be the same url). But this will replace any %2B to +, even those that was originally %2B not +. So, instead, I use the first four ASCII control characters (in uri escape form) for +,*,! and comma. Anyway they should never appears in a url.

    If you wonder why I replace +,*,! and comma from the url, it is because those have a special meaning in the tag mechanism or in /filter and it will be hard to, for example, filter on a tag containing a comma. I replace them by ASCII control characters in percent-encoding style. At first, I was replacing them by their equivalent percent-encoding style so for example + became %2B. The problem is that we must replace %2B by + when we retrieve the url from the tag later, because a + have a special meaning in url but not %2B (so this will not be the same url). But this will replace any %2B to +, even those that was originally %2B not +. So, instead, I use the first four ASCII control characters (in uri escape form) for +,*,! and comma. Therefore, this will replace + by %00 , by %01 ! by %02 and * by %03, then when you press 'i' in cursor mode, the %00 will become +, %01 will become , and so on.

    ## nullpointer (https://0x0.st)

  6. @pascalpoitras pascalpoitras revised this gist Jul 12, 2019. 1 changed file with 5 additions and 3 deletions.
    8 changes: 5 additions & 3 deletions myweechat.md
    Original file line number Diff line number Diff line change
    @@ -419,12 +419,12 @@ This trigger create a new buffer named highmon. This buffer will contain all the
    *The following triggers use the new hook_line. You must be using weechat 2.3. Otherwise, looks in the revisions to take the other version.*

    /trigger add news_line line *;irc.freenode.##news;irc_privmsg+nick_newsly*
    /trigger set news_line regex "/.*/${tg_message_nocolor}/site_name /^\[([^]]+)\].*/${re:1}/site_name /.*/${tg_message_nocolor}/title /^\[[^]]+\]//title /.*/${site_name}/site_color /^([^-]+).*/${info:nick_color_name,${re:1}}/site_color /.*/${title}/url ==.*(https?://[^ ]+).*==${re:1}==url /\+/%2B%2B/url /,/%2C%2C/url /\!/%21%21/url /\*/%2A%2A/url /.*/${re:0}url_${url}/tags ==https?://[^ ]+ .*====title /.*/[${color:${site_color}}${site_name}${color:reset}] ${title}/message /.*//prefix"
    /trigger set news_line regex "/.*/${tg_message_nocolor}/site_name /^\[([^]]+)\].*/${re:1}/site_name /.*/${tg_message_nocolor}/title /^\[[^]]+\]//title /.*/${site_name}/site_color /^([^-]+).*/${info:nick_color_name,${re:1}}/site_color /.*/${title}/url ==.*(https?://[^ ]+).*==${re:1}==url /\+/%00/url /,/%01/url /\!/%02/url /\*/%03/url /.*/${re:0}url_${url}/tags ==https?://[^ ]+ .*====title /.*/[${color:${site_color}}${site_name}${color:reset}] ${title}/message /.*//prefix"

    the normal version.

    /trigger add news_line line *;irc.freenode.##news;irc_privmsg+nick_newsly*
    /trigger set news_line regex "/.*/${tg_message_nocolor}/site_name /^\[([^]]+)\].*/${re:1}/site_name /.*/${tg_message_nocolor}/title /^\[[^]]+\]//title / - / ${color:-underline} /site_name /.*/${site_name}/site_color /^([^]+).*/${info:nick_color_name,${re:1}}/site_color /.*/${title}/url ==.*(https?://[^ ]+).*==${re:1}==url /\+/%2B%2B/url /,/%2C%2C/url /\!/%21%21/url /\*/%2A%2A/url /.*/${re:0}url_${url}/tags ==https?://[^ ]+ .*====title /.*/${color:_black,${site_color}} ${site_name} ${color:${site_color},default}${color:reset}${title}/message /.*//prefix"
    /trigger set news_line regex "/.*/${tg_message_nocolor}/site_name /^\[([^]]+)\].*/${re:1}/site_name /.*/${tg_message_nocolor}/title /^\[[^]]+\]//title / - / ${color:-underline} /site_name /.*/${site_name}/site_color /^([^]+).*/${info:nick_color_name,${re:1}}/site_color /.*/${title}/url ==.*(https?://[^ ]+).*==${re:1}==url /\+/%00/url /,/%01/url /\!/%02/url /\*/%03/url /.*/${re:0}url_${url}/tags ==https?://[^ ]+ .*====title /.*/${color:_black,${site_color}} ${site_name} ${color:${site_color},default}${color:reset}${title}/message /.*//prefix"

    the one with powerline symbols.

    @@ -435,7 +435,7 @@ Note: The url and the date will not appears in log. This is a consequence of usi


    /trigger add hsignal_news_click hsignal news_click
    /trigger set hsignal_news_click regex "/.*,url_([^,]+).*/${re:1}/_chat_line_tags /%2B%2B/+/_chat_line_tags /%2C%2C/,/_chat_line_tags /%21%21/!/_chat_line_tags /%2A%2A/*/_chat_line_tags"
    /trigger set hsignal_news_click regex "/.*,url_([^,]+).*/${re:1}/_chat_line_tags /%00/+/_chat_line_tags /%01/,/_chat_line_tags /%02/!/_chat_line_tags /%03/*/_chat_line_tags"
    /trigger set hsignal_news_click command "/command -buffer ${buffer.full_name} core /input insert ${if:${_key}==m?${_chat_line_message} }${_chat_line_tags}\x20"

    /key bindctxt cursor @chat(irc.freenode.##news):i hsignal:news_click;/cursor stop
    @@ -444,6 +444,8 @@ Note: The url and the date will not appears in log. This is a consequence of usi

    This trigger will be triggered when we press 'i' or 'm' on a news in cursor mode (in general we invoke this with the middle mouse button). 'i' insert the URL in the input bar. If the URL is too long to view it all, simply press return to send it to the channel, which anyway is +m so nobody will see it, and press alt+l to go in bare mode (so you can click on the URL). 'm' is more interesting, generally when you press 'm' in cursor mode, you add the message in the input bar, but remember, the message does not contain the URL anymore, so it is useless to send the title to someone without the URL. So, in this channel, 'm' is different. The URL is added back to the message.

    If you wonder why I replace +,*,! and comma from the url, it is because those have a special meaning in the tag mechanism and it will be hard to, for example, filter on a tag containing a comma. I replace them by ASCII control characters. At first, I was replacing them by their equivalent uri escape so for example + became %2B. The problem is that we must replace %2B by + when we retrieve the url from the tag later, because a + have a special meaning in url but not %2B (so this will not be the same url). But this will replace any %2B to +, even those that was originally %2B not +. So, instead, I use the first four ASCII control characters (in uri escape form) for +,*,! and comma. Anyway they should never appears in a url.


    ## nullpointer (https://0x0.st)

  7. @pascalpoitras pascalpoitras revised this gist Jul 11, 2019. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions myweechat.md
    Original file line number Diff line number Diff line change
    @@ -419,12 +419,12 @@ This trigger create a new buffer named highmon. This buffer will contain all the
    *The following triggers use the new hook_line. You must be using weechat 2.3. Otherwise, looks in the revisions to take the other version.*

    /trigger add news_line line *;irc.freenode.##news;irc_privmsg+nick_newsly*
    /trigger set news_line regex "/.*/${tg_message_nocolor}/site_name /^\[([^]]+)\].*/${re:1}/site_name /.*/${tg_message_nocolor}/title /^\[[^]]+\]//title /.*/${site_name}/site_color /^([^-]+).*/${info:nick_color_name,${re:1}}/site_color /.*/${title}/url ==.*(https?://[^ ]+).*==${re:1}==url /\+/%2B/url /,/%2C/url /\!/%21/url /\*/%2A/url /.*/${re:0},url_${url}/tags ==https?://[^ ]+ .*====title /.*/[${color:${site_color}}${site_name}${color:reset}] ${title}/message /.*//prefix"
    /trigger set news_line regex "/.*/${tg_message_nocolor}/site_name /^\[([^]]+)\].*/${re:1}/site_name /.*/${tg_message_nocolor}/title /^\[[^]]+\]//title /.*/${site_name}/site_color /^([^-]+).*/${info:nick_color_name,${re:1}}/site_color /.*/${title}/url ==.*(https?://[^ ]+).*==${re:1}==url /\+/%2B%2B/url /,/%2C%2C/url /\!/%21%21/url /\*/%2A%2A/url /.*/${re:0}url_${url}/tags ==https?://[^ ]+ .*====title /.*/[${color:${site_color}}${site_name}${color:reset}] ${title}/message /.*//prefix"

    the normal version.

    /trigger add news_line line *;irc.freenode.##news;irc_privmsg+nick_newsly*
    /trigger set news_line regex "/.*/${tg_message_nocolor}/site_name /^\[([^]]+)\].*/${re:1}/site_name /.*/${tg_message_nocolor}/title /^\[[^]]+\]//title / - / ${color:-underline} /site_name /.*/${site_name}/site_color /^([^-]+).*/${info:nick_color_name,${re:1}}/site_color /.*/${title}/url ==.*(https?://[^ ]+).*==${re:1}==url /\+/%2B/url /,/%2C/url /\!/%21/url /\*/%2A/url /.*/${re:0},url_${url}/tags ==https?://[^ ]+ .*====title /.*/${color:_black,${site_color}} ${site_name} ${color:${site_color},default}${color:reset}${title}/message /.*//prefix"
    /trigger set news_line regex "/.*/${tg_message_nocolor}/site_name /^\[([^]]+)\].*/${re:1}/site_name /.*/${tg_message_nocolor}/title /^\[[^]]+\]//title / - / ${color:-underline} /site_name /.*/${site_name}/site_color /^([^]+).*/${info:nick_color_name,${re:1}}/site_color /.*/${title}/url ==.*(https?://[^ ]+).*==${re:1}==url /\+/%2B%2B/url /,/%2C%2C/url /\!/%21%21/url /\*/%2A%2A/url /.*/${re:0}url_${url}/tags ==https?://[^ ]+ .*====title /.*/${color:_black,${site_color}} ${site_name} ${color:${site_color},default}${color:reset}${title}/message /.*//prefix"

    the one with powerline symbols.

    @@ -435,7 +435,7 @@ Note: The url and the date will not appears in log. This is a consequence of usi


    /trigger add hsignal_news_click hsignal news_click
    /trigger set hsignal_news_click regex "/.*,url_([^,]+).*/${re:1}/_chat_line_tags"
    /trigger set hsignal_news_click regex "/.*,url_([^,]+).*/${re:1}/_chat_line_tags /%2B%2B/+/_chat_line_tags /%2C%2C/,/_chat_line_tags /%21%21/!/_chat_line_tags /%2A%2A/*/_chat_line_tags"
    /trigger set hsignal_news_click command "/command -buffer ${buffer.full_name} core /input insert ${if:${_key}==m?${_chat_line_message} }${_chat_line_tags}\x20"

    /key bindctxt cursor @chat(irc.freenode.##news):i hsignal:news_click;/cursor stop
  8. @pascalpoitras pascalpoitras revised this gist Jul 6, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion myweechat.md
    Original file line number Diff line number Diff line change
    @@ -112,7 +112,7 @@ If you want a trusted certificate, use [let's encrypt! with weechat relay](https
    ## Scripts


    /script install autojoinem.py buffer_autoset.py autosort.py grep.py text_item.py
    /script install autojoinem.py buffer_autoset.py autosort.py grep.py grep_filter.py text_item.py


    ### autosort.py
  9. @pascalpoitras pascalpoitras revised this gist Jul 2, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions myweechat.md
    Original file line number Diff line number Diff line change
    @@ -618,8 +618,8 @@ Used to increment but also decrement if you use a negative number. If you omit n
    ### irc buffers stats

    /trigger add ircbufstats_utils info ircbufstats
    /trigger set ircbufstats_utils conditions "${tg_arguments} =~ ^(all|server|channel|private)$"
    /trigger set ircbufstats_utils regex "/^(all|server|channel|private)$/${re:1}/tg_arguments /.*/${info:ruby_eval, infolist = Weechat.infolist_get('buffer', '', ''); buffers_stats = Hash.new do |hash,key| hash[key] = 0 end; while Weechat.infolist_next(infolist) != 0 do buffer_ptr = Weechat.infolist_pointer(infolist, 'pointer'); buffers_stats[Weechat.buffer_get_string(buffer_ptr, 'localvar_type')] += 1 if Weechat.infolist_string(infolist, 'plugin_name') == 'irc' end if infolist != 0; Weechat.infolist_free(infolist); puts '${tg_arguments}' == 'all' ? [buffers_stats['server'], buffers_stats['channel'], buffers_stats['private']].join(' ') : buffers_stats['${tg_arguments}'].to_s}/tg_info"
    /trigger set ircbufstats_utils conditions "${tg_arguments} =~ ^(all|server|channel|private|query)$"
    /trigger set ircbufstats_utils regex "/^query$/private/tg_arguments /.*/${info:ruby_eval, infolist = Weechat.infolist_get('buffer', '', ''); buffers_stats = Hash.new do |hash,key| hash[key] = 0 end; while Weechat.infolist_next(infolist) != 0 do buffer_ptr = Weechat.infolist_pointer(infolist, 'pointer'); buffers_stats[Weechat.buffer_get_string(buffer_ptr, 'localvar_type')] += 1 if Weechat.infolist_string(infolist, 'plugin_name') == 'irc' end if infolist != 0; Weechat.infolist_free(infolist); puts '${tg_arguments}' == 'all' ? [buffers_stats['server'], buffers_stats['channel'], buffers_stats['private']].join(' ') : buffers_stats['${tg_arguments}'].to_s}/tg_info"

    **example:** `/eval -n I am on ${info:ircbufstats,server} networks and ${info:ircbufstats,channel} channels with ${info:ircbufstats,private} queries` will result in I am on 3 networks and 17 channels with 1 queries

  10. @pascalpoitras pascalpoitras revised this gist Jul 1, 2019. 1 changed file with 10 additions and 4 deletions.
    14 changes: 10 additions & 4 deletions myweechat.md
    Original file line number Diff line number Diff line change
    @@ -574,9 +574,9 @@ if you use /exec with -sh and the option _exec\_command\_shell_ is set to bash,

    Replace any match (global) of the pattern (argument #1) to the replacement given by argument #2 in the string (argument #3)

    **example:** `/eval ${info:replace,,([0-9]),#\1,Press 1}` will result in Press #1
    **example:** `/eval ${info:replace,,[aeiou],*,hello}` will return h\*ll*.

    you can use a different delimiter (# or =) if you're regex or the replacement contains a comma
    you can use a different delimiter (# or =) if your regex or the replacement contains a comma

    **example:** `/eval ${info:replace,#,##I like banana, apple and orange}` will result in I like banana apple and orange (no comma)

    @@ -590,7 +590,13 @@ And yes, you need the comma after replace (no matter the delimiter). So the synt

    The difference between replace and replace2 is that replace use Oniguruma engine (if you are using Ruby 1.9 or later) while replace2 use re2. re2 does not support backreference and lookahead/lookbehind but is perfectly safe to use with untrusted data. You need to install the re2 library.

    **example:** `/eval ${info:replace2,[aeiou],*,hello}` will return h\*ll*.
    **example:** `/eval ${info:replace2,,[aeiou],*,hello}` will return h\*ll*.

    you can use a different delimiter (# or =) if your regex or the replacement contains a comma

    **example:** `/eval ${info:replace2,#,##I like banana, apple and orange}` will result in I like banana apple and orange (no comma)

    And yes, you need the comma after replace2 (no matter the delimiter). So the syntax is ${info:replace2,DELIMITERregexDELIMITERreplacementDELIMITERtext}

    ### length

    @@ -617,7 +623,7 @@ Used to increment but also decrement if you use a negative number. If you omit n

    **example:** `/eval -n I am on ${info:ircbufstats,server} networks and ${info:ircbufstats,channel} channels with ${info:ircbufstats,private} queries` will result in I am on 3 networks and 17 channels with 1 queries

    **example:** same but faster (need the replace trigger) `/eval -n ${info:replace,([0-9]+) ([0-9]+) ([0-9]+),I am on \1 networks and \2 channels with \3 queries,${info:ircbufstats,all}}`
    **example:** same but faster (need the replace trigger) `/eval -n ${info:replace,,([0-9]+) ([0-9]+) ([0-9]+),I am on \1 networks and \2 channels with \3 queries,${info:ircbufstats,all}}`

    ### holiday

  11. @pascalpoitras pascalpoitras revised this gist Jul 1, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions myweechat.md
    Original file line number Diff line number Diff line change
    @@ -574,13 +574,13 @@ if you use /exec with -sh and the option _exec\_command\_shell_ is set to bash,

    Replace any match (global) of the pattern (argument #1) to the replacement given by argument #2 in the string (argument #3)

    **example:** `/eval ${info:replace,([0-9]),#\1,Press 1}` will result in Press #1
    **example:** `/eval ${info:replace,,([0-9]),#\1,Press 1}` will result in Press #1

    you can use a different delimiter (# or =) if you're regex or the replacement contains a comma

    **example:** `/eval ${info:replace,#,##I like banana, apple and orange}` will result in I like banana apple and orange (no comma)

    And yes, you need the comma after replace. So the syntax is ${info:replace,DELIMITERregexDELIMITERreplacementDELIMITERtext}
    And yes, you need the comma after replace (no matter the delimiter). So the syntax is ${info:replace,DELIMITERregexDELIMITERreplacementDELIMITERtext}

    ### replace with re2 (require escape trigger)

  12. @pascalpoitras pascalpoitras revised this gist Jul 1, 2019. 1 changed file with 14 additions and 8 deletions.
    22 changes: 14 additions & 8 deletions myweechat.md
    Original file line number Diff line number Diff line change
    @@ -566,25 +566,31 @@ if you use /exec with -sh and the option _exec\_command\_shell_ is set to bash,

    **example:** `/eval /exec -norc -sh echo '${info:escape_shell_single_quote,${plugins.var.text}}' | cowsay` will display a cow saying the content of plugins.var.text option

    ### replace
    ### replace (require escape trigger)

    /trigger add replace info replace
    /trigger set replace conditions "${tg_arguments} =~ ^[^,]+,[^,]*,.+$"
    /trigger set replace regex "/.*/${tg_arguments}/tg_info /^([^,]+),([^,]*),(.+)/${info:ruby_eval, puts '${info:escape,${re:3}}'.gsub(Regexp.new('${info:escape,${re:1}}'), '${info:escape,${re:2}}')}/tg_info"
    /trigger set replace conditions "${tg_arguments} =~ ^,[^,]+,[^,]*,.+$ || ${tg_arguments} =~ ^=[^=]+=[^=]*=.+$ || ${tg_arguments} =~ ^#[^#]+#[^#]*#.+$"
    /trigger set replace regex "/.*/${tg_arguments}/tg_info /.*/${info:ruby_eval, arguments = '${info:escape,${tg_arguments}}'[1..-1].split('${info:escape,${tg_arguments}}'[0], 3); puts arguments[2].gsub(Regexp.new(arguments[0]), arguments[1])}/tg_info"

    Replace any match (global) of the pattern (argument #1) to the replacement given by argument #2 in the string (argument #3)

    **example:** (require escape trigger) `/eval ${info:replace,([0-9]),#\1,Press 1}` will result in Press #1
    **example:** `/eval ${info:replace,([0-9]),#\1,Press 1}` will result in Press #1

    ### replace with re2
    you can use a different delimiter (# or =) if you're regex or the replacement contains a comma

    **example:** `/eval ${info:replace,#,##I like banana, apple and orange}` will result in I like banana apple and orange (no comma)

    And yes, you need the comma after replace. So the syntax is ${info:replace,DELIMITERregexDELIMITERreplacementDELIMITERtext}

    ### replace with re2 (require escape trigger)

    /trigger add replace2 info replace2
    /trigger set replace2 conditions "${tg_arguments} =~ ^[^,]+,[^,]*,.+$"
    /trigger set replace2 regex "/.*/${tg_arguments}/tg_info /^([^,]+),([^,]*),(.+)/${info:ruby_eval, require 're2'; puts RE2.GlobalReplace('${info:escape,${re:3}}', '${info:escape,${re:1}}', '${info:escape,${re:2}}')}/tg_info"
    /trigger set replace2 conditions "${tg_arguments} =~ ^,[^,]+,[^,]*,.+$ || ${tg_arguments} =~ ^=[^=]+=[^=]*=.+$ || ${tg_arguments} =~ ^#[^#]+#[^#]*#.+$"
    /trigger set replace2 regex "/.*/${tg_arguments}/tg_info /.*/${info:ruby_eval, require 're2'; arguments = '${info:escape,${tg_arguments}}'[1..-1].split('${info:escape,${tg_arguments}}'[0], 3); puts RE2.GlobalReplace(arguments[2], arguments[0], arguments[1])}/tg_info"

    The difference between replace and replace2 is that replace use Oniguruma engine (if you are using Ruby 1.9 or later) while replace2 use re2. re2 does not support backreference and lookahead/lookbehind but is perfectly safe to use with untrusted data. You need to install the re2 library.

    **example:** (require escape trigger) `/eval ${info:replace2,[aeiou],*,hello}` will return h\*ll*.
    **example:** `/eval ${info:replace2,[aeiou],*,hello}` will return h\*ll*.

    ### length

  13. @pascalpoitras pascalpoitras revised this gist Jul 1, 2019. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions myweechat.md
    Original file line number Diff line number Diff line change
    @@ -569,8 +569,8 @@ if you use /exec with -sh and the option _exec\_command\_shell_ is set to bash,
    ### replace

    /trigger add replace info replace
    /trigger set replace conditions "${tg_arguments} =~ ^[^,]+,[^,]+,.+$"
    /trigger set replace regex "/.*/${tg_arguments}/tg_info /^([^,]+),([^,]+),(.+)/${info:ruby_eval, puts '${info:escape,${re:3}}'.gsub(Regexp.new('${info:escape,${re:1}}'), '${info:escape,${re:2}}')}/tg_info"
    /trigger set replace conditions "${tg_arguments} =~ ^[^,]+,[^,]*,.+$"
    /trigger set replace regex "/.*/${tg_arguments}/tg_info /^([^,]+),([^,]*),(.+)/${info:ruby_eval, puts '${info:escape,${re:3}}'.gsub(Regexp.new('${info:escape,${re:1}}'), '${info:escape,${re:2}}')}/tg_info"

    Replace any match (global) of the pattern (argument #1) to the replacement given by argument #2 in the string (argument #3)

    @@ -579,8 +579,8 @@ Replace any match (global) of the pattern (argument #1) to the replacement given
    ### replace with re2

    /trigger add replace2 info replace2
    /trigger set replace2 conditions "${tg_arguments} =~ ^[^,]+,[^,]+,.+$"
    /trigger set replace2 regex "/.*/${tg_arguments}/tg_info /^([^,]+),([^,]+),(.+)/${info:ruby_eval, require 're2'; puts RE2.GlobalReplace('${info:escape,${re:3}}', '${info:escape,${re:1}}', '${info:escape,${re:2}}')}/tg_info"
    /trigger set replace2 conditions "${tg_arguments} =~ ^[^,]+,[^,]*,.+$"
    /trigger set replace2 regex "/.*/${tg_arguments}/tg_info /^([^,]+),([^,]*),(.+)/${info:ruby_eval, require 're2'; puts RE2.GlobalReplace('${info:escape,${re:3}}', '${info:escape,${re:1}}', '${info:escape,${re:2}}')}/tg_info"

    The difference between replace and replace2 is that replace use Oniguruma engine (if you are using Ruby 1.9 or later) while replace2 use re2. re2 does not support backreference and lookahead/lookbehind but is perfectly safe to use with untrusted data. You need to install the re2 library.

  14. @pascalpoitras pascalpoitras revised this gist Jun 25, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion myweechat.md
    Original file line number Diff line number Diff line change
    @@ -570,7 +570,7 @@ if you use /exec with -sh and the option _exec\_command\_shell_ is set to bash,

    /trigger add replace info replace
    /trigger set replace conditions "${tg_arguments} =~ ^[^,]+,[^,]+,.+$"
    /trigger set replace regex "/.*/${tg_arguments}/tg_info /^([^,]+),([^,]+),(.+)/${info:ruby_eval, puts '${info:escape,${re:3}}'.gsub(%r'${info:escape,${re:1}}', '${info:escape,${re:2}}')}/tg_info"
    /trigger set replace regex "/.*/${tg_arguments}/tg_info /^([^,]+),([^,]+),(.+)/${info:ruby_eval, puts '${info:escape,${re:3}}'.gsub(Regexp.new('${info:escape,${re:1}}'), '${info:escape,${re:2}}')}/tg_info"

    Replace any match (global) of the pattern (argument #1) to the replacement given by argument #2 in the string (argument #3)

  15. @pascalpoitras pascalpoitras revised this gist Jun 24, 2019. 1 changed file with 13 additions and 14 deletions.
    27 changes: 13 additions & 14 deletions myweechat.md
    Original file line number Diff line number Diff line change
    @@ -514,15 +514,15 @@ This let you translate text with the translate-shell program (package has the sa
    /trigger add upgrade_scripts signal day_changed
    /trigger set upgrade_scripts command "/script update;/wait 10s /script upgrade"

    The trigger _upgrade_scripts_ will update the local script cache and then upgrade all the installed scripts at midnight.
    This trigger will update the local script cache and then upgrade all the installed scripts at midnight.

    ### Friend Birthday

    /trigger add marie_birthday signal day_changed
    /trigger set marie_birthday conditions "${tg_signal_data} =~ 03-22$"
    /trigger set marie_birthday command "/command -buffer ${sec.data.mariechannel} ruby /ruby eval -o print "BONNNE FÊTEEEE!!! BON #{${date:%Y} - 1984}ieme anniversaire!!!""

    The trigger _marie_birthday_ will be triggered the March 22 of each years at midnight to tell my friend "happy birthday"
    This trigger will be triggered the March 22 of each years at midnight to tell my friend "happy birthday"

    ### Holiday Friend

    @@ -541,11 +541,12 @@ This trigger will check if today is a holiday (using the holiday_utils trigger s
    /trigger set modifier_is_nick_valid regex "==/nick (.+)==${re:1}==tg_string_nocolor ===/nick (.+)===/nick ${if:${info:irc_is_nick,${tg_string_nocolor}}&&${cut:${info:irc_server_isupport_value,${server},NICKLEN},,${tg_string_nocolor}}==${tg_string_nocolor}?${color:*green}:${color:*red}}${re:1} -- NICKLEN:${color:-bold} ${info:perl_eval,print ${info:irc_server_isupport_value,${server},NICKLEN} - (${buffer.input_buffer_length} - 6) . ' /'} ${info:irc_server_isupport_value,${server},NICKLEN} ${color:bold}Allowed Chars: ${color:-bold}${esc:a-zA-Z0-9_-\[]{}^`|}===tg_string"


    The trigger modifier_is_nick_valid will give you hint about max nickname length and available character in nickname and will also tell you if the nick is valid (green) or not (red). Note that it doesn't works with -all option of the /nick command.
    This trigger will give you hint about max nickname length and available character in nickname and will also tell you if the nick is valid (green) or not (red). Note that it doesn't works with -all option of the /nick command.


    ## hook_info triggers

    ### escape

    /trigger add escape info escape
    /trigger set escape conditions "${tg_arguments}"
    @@ -555,7 +556,7 @@ This info is used almost everytime I call ${info:ruby_eval or /ruby eval. It wil

    **example:** `/eval -n ${info:ruby_eval,puts '${info:escape,Hi' Everyone}'}` will result in Hi' Everyone

    ---
    ### escape shell single quote

    /trigger add escape_shell_single_quote info escape_shell_single_quote
    /trigger set escape_shell_single_quote conditions "${tg_arguments}"
    @@ -565,7 +566,7 @@ if you use /exec with -sh and the option _exec\_command\_shell_ is set to bash,

    **example:** `/eval /exec -norc -sh echo '${info:escape_shell_single_quote,${plugins.var.text}}' | cowsay` will display a cow saying the content of plugins.var.text option

    ---
    ### replace

    /trigger add replace info replace
    /trigger set replace conditions "${tg_arguments} =~ ^[^,]+,[^,]+,.+$"
    @@ -575,7 +576,7 @@ Replace any match (global) of the pattern (argument #1) to the replacement given

    **example:** (require escape trigger) `/eval ${info:replace,([0-9]),#\1,Press 1}` will result in Press #1

    ---
    ### replace with re2

    /trigger add replace2 info replace2
    /trigger set replace2 conditions "${tg_arguments} =~ ^[^,]+,[^,]+,.+$"
    @@ -585,14 +586,14 @@ The difference between replace and replace2 is that replace use Oniguruma engine

    **example:** (require escape trigger) `/eval ${info:replace2,[aeiou],*,hello}` will return h\*ll*.

    ---
    ### length

    /trigger add length_utils info length
    /trigger set length_utils regex "/.*/${if:${tg_arguments}?${info:ruby_eval,puts '${info:escape,${tg_arguments}}'.size.to_s}:0}/tg_info"

    **example:** `/eval -n ${info:length,weechat}` will result in 7

    ---
    ### increment and decrement

    /trigger add inc_utils info inc
    /trigger set inc_utils conditions "${tg_arguments} =~ ^(-?[0-9]+)*,[0-9]+$"
    @@ -602,7 +603,7 @@ Used to increment but also decrement if you use a negative number. If you omit n

    **example:** `/eval -n ${info:inc,,7} and ${info:inc,5,${info:length,weechat}}` will result 8 and 12

    ---
    ### irc buffers stats

    /trigger add ircbufstats_utils info ircbufstats
    /trigger set ircbufstats_utils conditions "${tg_arguments} =~ ^(all|server|channel|private)$"
    @@ -612,17 +613,15 @@ Used to increment but also decrement if you use a negative number. If you omit n

    **example:** same but faster (need the replace trigger) `/eval -n ${info:replace,([0-9]+) ([0-9]+) ([0-9]+),I am on \1 networks and \2 channels with \3 queries,${info:ircbufstats,all}}`

    ---
    ### holiday

    /trigger add holiday_utils info holiday
    /trigger set holiday_utils conditions "${tg_arguments} =~ ^(0[1-9]|[1-2][0-9]|3[0-1])-(0[1-9]|1[0-2])$"
    /trigger set holiday_utils regex "/.*/${tg_arguments}/ /01-01/HAPPY NEW YEAR!/ /25-12/MERRY CHRISTMAS!/ /[0-9][0-9]-[0-9][0-9]//"

    **example:** `/eval ${if:${info:holiday,${date:%d-%m}}?Yes! today is a holiday \o/ -- ${info:holiday,${date:%d-%m}} all!:Go to work!}` will result in Yes! today is a holiday -- MERRY CHRISTMAS! all! if, of course we are December 25!

    ---
    this info is useful for the weechat.look.day_change_message_1_date and _2dates. See these options at the bottom of my configuration. This trigger is also used from the holiday_friend trigger.

    hook_info triggers are new in WeeChat 2.5. The 5 triggers above are useful and some are used somewhere in the configuration. The escape trigger will escape single-quote and double quote characters. The escape_shell_single_quote is designed to escape single-quote in single-quoted string for the shell. The ircbufstats trigger return the number of servers, channels or query. The length return the length of the string. The inc is used to increment (or decrement with a negative number as the first number) a number. The holiday_utils trigger is useful for the weechat.look.day_change_message_1_date and _2dates. See these options at the bottom of my configuration. This trigger is also used from the holiday_friend trigger.
    **example:** `/eval ${if:${info:holiday,${date:%d-%m}}?Yes! today is a holiday \o/ -- ${info:holiday,${date:%d-%m}} all!:Go to work!}` will result in Yes! today is a holiday -- MERRY CHRISTMAS! all! if, of course we are December 25!


    ## Keys
  16. @pascalpoitras pascalpoitras revised this gist Jun 24, 2019. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions myweechat.md
    Original file line number Diff line number Diff line change
    @@ -509,29 +509,30 @@ This let you translate text with the translate-shell program (package has the sa

    ## Triggers

    ### Upgrade Scripts

    /trigger add upgrade_scripts signal day_changed
    /trigger set upgrade_scripts command "/script update;/wait 10s /script upgrade"

    The trigger _upgrade_scripts_ will update the local script cache and then upgrade all the installed scripts at midnight.

    ---
    ### Friend Birthday

    /trigger add marie_birthday signal day_changed
    /trigger set marie_birthday conditions "${tg_signal_data} =~ 03-22$"
    /trigger set marie_birthday command "/command -buffer ${sec.data.mariechannel} ruby /ruby eval -o print "BONNNE FÊTEEEE!!! BON #{${date:%Y} - 1984}ieme anniversaire!!!""

    The trigger _marie_birthday_ will be triggered the March 22 of each years at midnight to tell my friend "happy birthday"

    ---
    ### Holiday Friend

    /trigger add holiday_friend signal day_changed
    /trigger set holiday_friend conditions "${info:holiday,${date:%d-%m}}"
    /trigger set holiday_friend command "/command -buffer ${sec.data.mariechannel} irc /msg * ${info:holiday,${date:%d-%m}}"

    This trigger will check if today is a holiday (using the holiday_utils trigger so you need to add it. You can find it in the next section.) if so, I will tell my friend Merry Christmas, or Happy new year (so she can't be angry).

    ---
    ### Nick Validation

    ![WeeChat Screenshot](http://192.99.68.133/Peek-2019-01-22-01-08.gif)

  17. @pascalpoitras pascalpoitras revised this gist Jun 24, 2019. 1 changed file with 10 additions and 3 deletions.
    13 changes: 10 additions & 3 deletions myweechat.md
    Original file line number Diff line number Diff line change
    @@ -549,7 +549,9 @@ The trigger modifier_is_nick_valid will give you hint about max nickname length
    /trigger add escape info escape
    /trigger set escape conditions "${tg_arguments}"
    /trigger set escape regex "/.*/${tg_arguments}/tg_info ==\\\\==\\\\== /'/\'/"


    This info is used almost everytime I call ${info:ruby_eval or /ruby eval. It will escape any ' and any \ in the string before giving the result to ruby. I always call ruby with single quote string. It should also works with python and perl because single quote behave the same in these language AFAIK. So if you use double quote string, you need a different info.

    **example:** `/eval -n ${info:ruby_eval,puts '${info:escape,Hi' Everyone}'}` will result in Hi' Everyone

    ---
    @@ -558,7 +560,7 @@ The trigger modifier_is_nick_valid will give you hint about max nickname length
    /trigger set escape_shell_single_quote conditions "${tg_arguments}"
    /trigger set escape_shell_single_quote regex "/.*/${tg_arguments}/tg_info /'/'\''/"

    **note:** if you use /exec with -sh and the option _exec\_command\_shell_ is set to bash, escape sequence like \\n will not be interpreted as a new line. This is what I want so I configured this option to bash. In zsh, the \\n will be interpreted as a new line in a single quoted string. By default the option is set to sh but on my system _/bin/sh_ is a symbolic link to dash and dash behave like zsh. You need to keep this in mind!
    if you use /exec with -sh and the option _exec\_command\_shell_ is set to bash, escape sequence like \\n will not be interpreted as a new line. This is what I want so I configured this option to bash (if you use my configuration you should do the same). In zsh, the \\n will be interpreted as a new line in a single quoted string. By default the option is set to sh but on my system _/bin/sh_ is a symbolic link to dash and dash behave like zsh. You need to keep this in mind! And don't forget, this only works for single quote string, if you want to use it in a double quote string you need to create another info or modify this one.

    **example:** `/eval /exec -norc -sh echo '${info:escape_shell_single_quote,${plugins.var.text}}' | cowsay` will display a cow saying the content of plugins.var.text option

    @@ -568,6 +570,8 @@ The trigger modifier_is_nick_valid will give you hint about max nickname length
    /trigger set replace conditions "${tg_arguments} =~ ^[^,]+,[^,]+,.+$"
    /trigger set replace regex "/.*/${tg_arguments}/tg_info /^([^,]+),([^,]+),(.+)/${info:ruby_eval, puts '${info:escape,${re:3}}'.gsub(%r'${info:escape,${re:1}}', '${info:escape,${re:2}}')}/tg_info"

    Replace any match (global) of the pattern (argument #1) to the replacement given by argument #2 in the string (argument #3)

    **example:** (require escape trigger) `/eval ${info:replace,([0-9]),#\1,Press 1}` will result in Press #1

    ---
    @@ -576,9 +580,10 @@ The trigger modifier_is_nick_valid will give you hint about max nickname length
    /trigger set replace2 conditions "${tg_arguments} =~ ^[^,]+,[^,]+,.+$"
    /trigger set replace2 regex "/.*/${tg_arguments}/tg_info /^([^,]+),([^,]+),(.+)/${info:ruby_eval, require 're2'; puts RE2.GlobalReplace('${info:escape,${re:3}}', '${info:escape,${re:1}}', '${info:escape,${re:2}}')}/tg_info"

    **example:** (require escape trigger) `/eval ${info:replace2,[aeiou],*,hello}` will return h\*ll*.
    The difference between replace and replace2 is that replace use Oniguruma engine (if you are using Ruby 1.9 or later) while replace2 use re2. re2 does not support backreference and lookahead/lookbehind but is perfectly safe to use with untrusted data. You need to install the re2 library.

    **example:** (require escape trigger) `/eval ${info:replace2,[aeiou],*,hello}` will return h\*ll*.

    ---

    /trigger add length_utils info length
    @@ -592,6 +597,8 @@ The difference between replace and replace2 is that replace use Oniguruma engine
    /trigger set inc_utils conditions "${tg_arguments} =~ ^(-?[0-9]+)*,[0-9]+$"
    /trigger set inc_utils regex "/^,/1,/tg_arguments /.*/${tg_arguments}/the_number /^(-?[0-9]+),[0-9]+/${re:1}/the_number /^-?[0-9]+,([0-9]+)/${re:1}/tg_arguments /.*/${info:ruby_eval, puts((${tg_arguments} + ${the_number}).to_s)}/tg_info"

    Used to increment but also decrement if you use a negative number. If you omit number in argument #1, it will increment argument #2 by one

    **example:** `/eval -n ${info:inc,,7} and ${info:inc,5,${info:length,weechat}}` will result 8 and 12

    ---
  18. @pascalpoitras pascalpoitras revised this gist Jun 23, 2019. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions myweechat.md
    Original file line number Diff line number Diff line change
    @@ -531,6 +531,8 @@ The trigger _marie_birthday_ will be triggered the March 22 of each years at mid

    This trigger will check if today is a holiday (using the holiday_utils trigger so you need to add it. You can find it in the next section.) if so, I will tell my friend Merry Christmas, or Happy new year (so she can't be angry).

    ---

    ![WeeChat Screenshot](http://192.99.68.133/Peek-2019-01-22-01-08.gif)

    /trigger add modifier_is_nick_valid modifier input_text_display
  19. @pascalpoitras pascalpoitras revised this gist Jun 23, 2019. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion myweechat.md
    Original file line number Diff line number Diff line change
    @@ -515,12 +515,16 @@ This let you translate text with the translate-shell program (package has the sa

    The trigger _upgrade_scripts_ will update the local script cache and then upgrade all the installed scripts at midnight.

    ---

    /trigger add marie_birthday signal day_changed
    /trigger set marie_birthday conditions "${tg_signal_data} =~ 03-22$"
    /trigger set marie_birthday command "/command -buffer ${sec.data.mariechannel} ruby /ruby eval -o print "BONNNE FÊTEEEE!!! BON #{${date:%Y} - 1984}ieme anniversaire!!!""

    The trigger _marie_birthday_ will be triggered the March 22 of each years at midnight to tell my friend "happy birthday"

    ---

    /trigger add holiday_friend signal day_changed
    /trigger set holiday_friend conditions "${info:holiday,${date:%d-%m}}"
    /trigger set holiday_friend command "/command -buffer ${sec.data.mariechannel} irc /msg * ${info:holiday,${date:%d-%m}}"
  20. @pascalpoitras pascalpoitras revised this gist Jun 23, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions myweechat.md
    Original file line number Diff line number Diff line change
    @@ -544,10 +544,10 @@ The trigger modifier_is_nick_valid will give you hint about max nickname length
    /trigger set escape conditions "${tg_arguments}"
    /trigger set escape regex "/.*/${tg_arguments}/tg_info ==\\\\==\\\\== /'/\'/"

    ---

    **example:** `/eval -n ${info:ruby_eval,puts '${info:escape,Hi' Everyone}'}` will result in Hi' Everyone

    ---

    /trigger add escape_shell_single_quote info escape_shell_single_quote
    /trigger set escape_shell_single_quote conditions "${tg_arguments}"
    /trigger set escape_shell_single_quote regex "/.*/${tg_arguments}/tg_info /'/'\''/"
  21. @pascalpoitras pascalpoitras revised this gist Jun 23, 2019. 1 changed file with 16 additions and 0 deletions.
    16 changes: 16 additions & 0 deletions myweechat.md
    Original file line number Diff line number Diff line change
    @@ -544,6 +544,8 @@ The trigger modifier_is_nick_valid will give you hint about max nickname length
    /trigger set escape conditions "${tg_arguments}"
    /trigger set escape regex "/.*/${tg_arguments}/tg_info ==\\\\==\\\\== /'/\'/"

    ---

    **example:** `/eval -n ${info:ruby_eval,puts '${info:escape,Hi' Everyone}'}` will result in Hi' Everyone

    /trigger add escape_shell_single_quote info escape_shell_single_quote
    @@ -554,30 +556,40 @@ The trigger modifier_is_nick_valid will give you hint about max nickname length

    **example:** `/eval /exec -norc -sh echo '${info:escape_shell_single_quote,${plugins.var.text}}' | cowsay` will display a cow saying the content of plugins.var.text option

    ---

    /trigger add replace info replace
    /trigger set replace conditions "${tg_arguments} =~ ^[^,]+,[^,]+,.+$"
    /trigger set replace regex "/.*/${tg_arguments}/tg_info /^([^,]+),([^,]+),(.+)/${info:ruby_eval, puts '${info:escape,${re:3}}'.gsub(%r'${info:escape,${re:1}}', '${info:escape,${re:2}}')}/tg_info"

    **example:** (require escape trigger) `/eval ${info:replace,([0-9]),#\1,Press 1}` will result in Press #1

    ---

    /trigger add replace2 info replace2
    /trigger set replace2 conditions "${tg_arguments} =~ ^[^,]+,[^,]+,.+$"
    /trigger set replace2 regex "/.*/${tg_arguments}/tg_info /^([^,]+),([^,]+),(.+)/${info:ruby_eval, require 're2'; puts RE2.GlobalReplace('${info:escape,${re:3}}', '${info:escape,${re:1}}', '${info:escape,${re:2}}')}/tg_info"

    **example:** (require escape trigger) `/eval ${info:replace2,[aeiou],*,hello}` will return h\*ll*.
    The difference between replace and replace2 is that replace use Oniguruma engine (if you are using Ruby 1.9 or later) while replace2 use re2. re2 does not support backreference and lookahead/lookbehind but is perfectly safe to use with untrusted data. You need to install the re2 library.

    ---

    /trigger add length_utils info length
    /trigger set length_utils regex "/.*/${if:${tg_arguments}?${info:ruby_eval,puts '${info:escape,${tg_arguments}}'.size.to_s}:0}/tg_info"

    **example:** `/eval -n ${info:length,weechat}` will result in 7

    ---

    /trigger add inc_utils info inc
    /trigger set inc_utils conditions "${tg_arguments} =~ ^(-?[0-9]+)*,[0-9]+$"
    /trigger set inc_utils regex "/^,/1,/tg_arguments /.*/${tg_arguments}/the_number /^(-?[0-9]+),[0-9]+/${re:1}/the_number /^-?[0-9]+,([0-9]+)/${re:1}/tg_arguments /.*/${info:ruby_eval, puts((${tg_arguments} + ${the_number}).to_s)}/tg_info"

    **example:** `/eval -n ${info:inc,,7} and ${info:inc,5,${info:length,weechat}}` will result 8 and 12

    ---

    /trigger add ircbufstats_utils info ircbufstats
    /trigger set ircbufstats_utils conditions "${tg_arguments} =~ ^(all|server|channel|private)$"
    /trigger set ircbufstats_utils regex "/^(all|server|channel|private)$/${re:1}/tg_arguments /.*/${info:ruby_eval, infolist = Weechat.infolist_get('buffer', '', ''); buffers_stats = Hash.new do |hash,key| hash[key] = 0 end; while Weechat.infolist_next(infolist) != 0 do buffer_ptr = Weechat.infolist_pointer(infolist, 'pointer'); buffers_stats[Weechat.buffer_get_string(buffer_ptr, 'localvar_type')] += 1 if Weechat.infolist_string(infolist, 'plugin_name') == 'irc' end if infolist != 0; Weechat.infolist_free(infolist); puts '${tg_arguments}' == 'all' ? [buffers_stats['server'], buffers_stats['channel'], buffers_stats['private']].join(' ') : buffers_stats['${tg_arguments}'].to_s}/tg_info"
    @@ -586,12 +598,16 @@ The difference between replace and replace2 is that replace use Oniguruma engine

    **example:** same but faster (need the replace trigger) `/eval -n ${info:replace,([0-9]+) ([0-9]+) ([0-9]+),I am on \1 networks and \2 channels with \3 queries,${info:ircbufstats,all}}`

    ---

    /trigger add holiday_utils info holiday
    /trigger set holiday_utils conditions "${tg_arguments} =~ ^(0[1-9]|[1-2][0-9]|3[0-1])-(0[1-9]|1[0-2])$"
    /trigger set holiday_utils regex "/.*/${tg_arguments}/ /01-01/HAPPY NEW YEAR!/ /25-12/MERRY CHRISTMAS!/ /[0-9][0-9]-[0-9][0-9]//"

    **example:** `/eval ${if:${info:holiday,${date:%d-%m}}?Yes! today is a holiday \o/ -- ${info:holiday,${date:%d-%m}} all!:Go to work!}` will result in Yes! today is a holiday -- MERRY CHRISTMAS! all! if, of course we are December 25!

    ---

    hook_info triggers are new in WeeChat 2.5. The 5 triggers above are useful and some are used somewhere in the configuration. The escape trigger will escape single-quote and double quote characters. The escape_shell_single_quote is designed to escape single-quote in single-quoted string for the shell. The ircbufstats trigger return the number of servers, channels or query. The length return the length of the string. The inc is used to increment (or decrement with a negative number as the first number) a number. The holiday_utils trigger is useful for the weechat.look.day_change_message_1_date and _2dates. See these options at the bottom of my configuration. This trigger is also used from the holiday_friend trigger.


  22. @pascalpoitras pascalpoitras revised this gist Jun 23, 2019. 1 changed file with 9 additions and 1 deletion.
    10 changes: 9 additions & 1 deletion myweechat.md
    Original file line number Diff line number Diff line change
    @@ -549,7 +549,9 @@ The trigger modifier_is_nick_valid will give you hint about max nickname length
    /trigger add escape_shell_single_quote info escape_shell_single_quote
    /trigger set escape_shell_single_quote conditions "${tg_arguments}"
    /trigger set escape_shell_single_quote regex "/.*/${tg_arguments}/tg_info /'/'\''/"


    **note:** if you use /exec with -sh and the option _exec\_command\_shell_ is set to bash, escape sequence like \\n will not be interpreted as a new line. This is what I want so I configured this option to bash. In zsh, the \\n will be interpreted as a new line in a single quoted string. By default the option is set to sh but on my system _/bin/sh_ is a symbolic link to dash and dash behave like zsh. You need to keep this in mind!

    **example:** `/eval /exec -norc -sh echo '${info:escape_shell_single_quote,${plugins.var.text}}' | cowsay` will display a cow saying the content of plugins.var.text option

    /trigger add replace info replace
    @@ -670,6 +672,12 @@ The _weechat.color.chat_host_ option will also set this color for part and quit.
    /set weechat.color.chat_prefix_quit 131
    /set irc.color.message_quit 131


    ## exec options


    /set exec.command.shell bash


    ## The remaining IRC options

  23. @pascalpoitras pascalpoitras revised this gist Jun 23, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions myweechat.md
    Original file line number Diff line number Diff line change
    @@ -397,8 +397,8 @@ This trigger create a new buffer named chanmon. This buffer will contain all the

    /buffer_autoset add core.highmon title Highlight Monitor

    /trigger add highmon_like print ""
    /trigger set highmon_like conditions "${tg_highlight} == 1 && ${tg_displayed} == 1 && ${buffer.local_variables.type} == channel && ${tg_tags} =~ ,irc_privmsg,"
    /trigger add highmon_like print "*;irc_privmsg"
    /trigger set highmon_like conditions "${tg_highlight} == 1 && ${tg_displayed} == 1 && ${buffer.local_variables.type} == channel"
    /trigger set highmon_like command "/print -newbuffer highmon -tags ${tg_tags} ${color:${info:nick_color_name,${server}}}${cut:4,${color:${weechat.color.chat_prefix_more}}${weechat.look.prefix_buffer_align_more},${server}}${color:${info:nick_color_name,${channel}}}${channel}\t${if:${tg_tags} !~ ,irc_action,?${weechat.look.quote_nick_prefix}${tg_prefix}${color:reset}${weechat.look.quote_nick_suffix}:${tg_prefix}${color:reset}} ${tg_message}"


  24. @pascalpoitras pascalpoitras revised this gist Jun 23, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion myweechat.md
    Original file line number Diff line number Diff line change
    @@ -542,7 +542,7 @@ The trigger modifier_is_nick_valid will give you hint about max nickname length

    /trigger add escape info escape
    /trigger set escape conditions "${tg_arguments}"
    /trigger set escape regex "/.*/${tg_arguments}/tg_info /'/\'/ /\"/\\"/"
    /trigger set escape regex "/.*/${tg_arguments}/tg_info ==\\\\==\\\\== /'/\'/"

    **example:** `/eval -n ${info:ruby_eval,puts '${info:escape,Hi' Everyone}'}` will result in Hi' Everyone

  25. @pascalpoitras pascalpoitras revised this gist Jun 23, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion myweechat.md
    Original file line number Diff line number Diff line change
    @@ -562,7 +562,7 @@ The trigger modifier_is_nick_valid will give you hint about max nickname length
    /trigger set replace2 conditions "${tg_arguments} =~ ^[^,]+,[^,]+,.+$"
    /trigger set replace2 regex "/.*/${tg_arguments}/tg_info /^([^,]+),([^,]+),(.+)/${info:ruby_eval, require 're2'; puts RE2.GlobalReplace('${info:escape,${re:3}}', '${info:escape,${re:1}}', '${info:escape,${re:2}}')}/tg_info"

    **example:** (require escape trigger) `/eval ${info:replace2,[aeiou],*,hello}` will return h*ll*.
    **example:** (require escape trigger) `/eval ${info:replace2,[aeiou],*,hello}` will return h\*ll*.
    The difference between replace and replace2 is that replace use Oniguruma engine (if you are using Ruby 1.9 or later) while replace2 use re2. re2 does not support backreference and lookahead/lookbehind but is perfectly safe to use with untrusted data. You need to install the re2 library.

    /trigger add length_utils info length
  26. @pascalpoitras pascalpoitras revised this gist Jun 23, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions myweechat.md
    Original file line number Diff line number Diff line change
    @@ -344,7 +344,7 @@ Note: I changed the conditions to display the nicklist only on buffer of type ch
    /set plugins.var.python.text_item.line_number all|signal_sigwinch ${eval:${info:ruby_eval,puts (0...${info:term_height}).to_a.join('\${\n${esc:\x7D}')}}


    This is inspired from the excellent [vimode.py](https://github.com/GermainZ/weechat-vimode) script by GermainZ. A bar with line number will be show whenever you type /cursor go<space> and will dissapears 5 seconds later (you need to put the x coordinates before the y one (line number). example: /cursor go x,<the line number>. Of course, if you use the vimode.py script, don't add this bar to your config it will be pretty useless.
    This is inspired from the excellent [vimode.py](https://github.com/GermainZ/weechat-vimode) script by GermainZ. A bar with line number will be show whenever you type /cursor go<space> and will dissapears 5 seconds later (you need to put the x coordinates before the y one (line number). example: /cursor go x,\<the line number>. Of course, if you use the vimode.py script, don't add this bar to your config it will be pretty useless.


    ## Layouts
    @@ -562,7 +562,7 @@ The trigger modifier_is_nick_valid will give you hint about max nickname length
    /trigger set replace2 conditions "${tg_arguments} =~ ^[^,]+,[^,]+,.+$"
    /trigger set replace2 regex "/.*/${tg_arguments}/tg_info /^([^,]+),([^,]+),(.+)/${info:ruby_eval, require 're2'; puts RE2.GlobalReplace('${info:escape,${re:3}}', '${info:escape,${re:1}}', '${info:escape,${re:2}}')}/tg_info"

    **example:** (require escape trigger) `/eval ${info:replace2,[aeiou],*,hello} will return h*ll*.
    **example:** (require escape trigger) `/eval ${info:replace2,[aeiou],*,hello}` will return h*ll*.
    The difference between replace and replace2 is that replace use Oniguruma engine (if you are using Ruby 1.9 or later) while replace2 use re2. re2 does not support backreference and lookahead/lookbehind but is perfectly safe to use with untrusted data. You need to install the re2 library.

    /trigger add length_utils info length
  27. @pascalpoitras pascalpoitras revised this gist Jun 23, 2019. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions myweechat.md
    Original file line number Diff line number Diff line change
    @@ -557,7 +557,14 @@ The trigger modifier_is_nick_valid will give you hint about max nickname length
    /trigger set replace regex "/.*/${tg_arguments}/tg_info /^([^,]+),([^,]+),(.+)/${info:ruby_eval, puts '${info:escape,${re:3}}'.gsub(%r'${info:escape,${re:1}}', '${info:escape,${re:2}}')}/tg_info"

    **example:** (require escape trigger) `/eval ${info:replace,([0-9]),#\1,Press 1}` will result in Press #1

    /trigger add replace2 info replace2
    /trigger set replace2 conditions "${tg_arguments} =~ ^[^,]+,[^,]+,.+$"
    /trigger set replace2 regex "/.*/${tg_arguments}/tg_info /^([^,]+),([^,]+),(.+)/${info:ruby_eval, require 're2'; puts RE2.GlobalReplace('${info:escape,${re:3}}', '${info:escape,${re:1}}', '${info:escape,${re:2}}')}/tg_info"

    **example:** (require escape trigger) `/eval ${info:replace2,[aeiou],*,hello} will return h*ll*.
    The difference between replace and replace2 is that replace use Oniguruma engine (if you are using Ruby 1.9 or later) while replace2 use re2. re2 does not support backreference and lookahead/lookbehind but is perfectly safe to use with untrusted data. You need to install the re2 library.

    /trigger add length_utils info length
    /trigger set length_utils regex "/.*/${if:${tg_arguments}?${info:ruby_eval,puts '${info:escape,${tg_arguments}}'.size.to_s}:0}/tg_info"

  28. @pascalpoitras pascalpoitras revised this gist Jun 22, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion myweechat.md
    Original file line number Diff line number Diff line change
    @@ -339,7 +339,7 @@ Note: I changed the conditions to display the nicklist only on buffer of type ch

    /trigger add show_bar_cursor_go signal input_text_changed
    /trigger set show_bar_cursor_go conditions "${buffer[${tg_signal_data}].input_buffer} == /cursor go${esc:\x20}"
    /trigger set show_bar_cursor_go command "/bar show line_number;/wait 5s /bar hide line_number"
    /trigger set show_bar_cursor_go command "/bar show line_number;/wait 10s /bar hide line_number"

    /set plugins.var.python.text_item.line_number all|signal_sigwinch ${eval:${info:ruby_eval,puts (0...${info:term_height}).to_a.join('\${\n${esc:\x7D}')}}

  29. @pascalpoitras pascalpoitras revised this gist Jun 22, 2019. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions myweechat.md
    Original file line number Diff line number Diff line change
    @@ -335,6 +335,7 @@ Note: I changed the conditions to display the nicklist only on buffer of type ch


    /bar add line_number root left 5 1 line_number
    /bar set line_number hidden on

    /trigger add show_bar_cursor_go signal input_text_changed
    /trigger set show_bar_cursor_go conditions "${buffer[${tg_signal_data}].input_buffer} == /cursor go${esc:\x20}"
  30. @pascalpoitras pascalpoitras revised this gist Jun 22, 2019. 1 changed file with 19 additions and 6 deletions.
    25 changes: 19 additions & 6 deletions myweechat.md
    Original file line number Diff line number Diff line change
    @@ -237,9 +237,9 @@ Note: show channels and privates buffers under their respective server instead o
    /bar set buflist priority 2
    /bar set buflist size 15
    /bar set buflist items buflist
    /bar add buflist_hotlist root left 1 0 buflist2
    /bar add buflist_hotlist root left 1 1 buflist2
    /bar set buflist_hotlist priority 1
    /bar set buflist_hotlist size 3
    /bar set buflist_hotlist separator 1

    /set buflist.format.hotlist_highlight "${color:163}"
    /set buflist.format.hotlist_message "${color:229}"
    @@ -272,12 +272,11 @@ There's a lot going on here. I created a second bar, buflist_hotlist, that conta
    ### Bar active title


    /bar add activetitle window top 1 0 [#window_number],buffer_title
    /bar add activetitle window top 1 1 [#window_number],buffer_title
    /bar set activetitle priority 500
    /bar set activetitle conditions ${active}
    /bar set activetitle color_fg white
    /bar set activetitle color_bg 31
    /bar set activetitle separator 1


    Note: This bar will be different from the already created one. I set the conditions to ${active} so this bar will be displayed on the active window only. The other one will be used for other windows.
    @@ -295,10 +294,9 @@ Note: This bar will be different from the already created one. I set the conditi
    ### Bar status


    /bar add rootstatus root bottom 1 0 [time],[buffer_count],[buffer_plugin],buffer_number+:+buffer_name+(buffer_modes)+{buffer_nicklist_count}+buffer_filter,[bitlbee_typing_notice],[lag],[spell_dict],[spell_suggest],completion,scroll,conky_CPU,conky_RAM,conky_Swap,conky_Up,conky_Down
    /bar add rootstatus root bottom 1 1 [time],[buffer_count],[buffer_plugin],buffer_number+:+buffer_name+(buffer_modes)+{buffer_nicklist_count}+buffer_filter,[bitlbee_typing_notice],[lag],[spell_dict],[spell_suggest],completion,scroll,conky_CPU,conky_RAM,conky_Swap,conky_Up,conky_Down
    /bar set rootstatus color_fg 31
    /bar set rootstatus color_bg 234
    /bar set rootstatus separator 1
    /bar set rootstatus priority 500
    /bar del status
    /bar set rootstatus name status
    @@ -333,6 +331,21 @@ Note: the built-in input bar is of type window. I prefer a input bar of type roo
    Note: I changed the conditions to display the nicklist only on buffer of type channels _${nicklist}_ and on the window number 1, which is my chat window (2 being my highlight window and 3 my conky window). In my case, I could remove _${window.numer} == 1_ because the _highmon_ and _exec_ buffer (conky) are not of type channels so ${nicklist} is enough.


    ### Bar line_number


    /bar add line_number root left 5 1 line_number

    /trigger add show_bar_cursor_go signal input_text_changed
    /trigger set show_bar_cursor_go conditions "${buffer[${tg_signal_data}].input_buffer} == /cursor go${esc:\x20}"
    /trigger set show_bar_cursor_go command "/bar show line_number;/wait 5s /bar hide line_number"

    /set plugins.var.python.text_item.line_number all|signal_sigwinch ${eval:${info:ruby_eval,puts (0...${info:term_height}).to_a.join('\${\n${esc:\x7D}')}}


    This is inspired from the excellent [vimode.py](https://github.com/GermainZ/weechat-vimode) script by GermainZ. A bar with line number will be show whenever you type /cursor go<space> and will dissapears 5 seconds later (you need to put the x coordinates before the y one (line number). example: /cursor go x,<the line number>. Of course, if you use the vimode.py script, don't add this bar to your config it will be pretty useless.


    ## Layouts