{"id":28146855,"url":"https://github.com/susam/inwee","last_synced_at":"2025-05-14T23:15:52.296Z","repository":{"id":33244982,"uuid":"36889333","full_name":"susam/inwee","owner":"susam","description":"Conveniently send text and commands from file or standard input to WeeChat with this wrapper around WeeChat's FIFO pipe","archived":false,"fork":false,"pushed_at":"2017-12-21T03:14:37.000Z","size":22,"stargazers_count":24,"open_issues_count":1,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2023-03-24T08:32:30.904Z","etag":null,"topics":["configuration","irc","weechat"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/susam.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-04T18:55:57.000Z","updated_at":"2023-02-22T13:54:00.000Z","dependencies_parsed_at":"2022-08-17T21:40:16.818Z","dependency_job_id":null,"html_url":"https://github.com/susam/inwee","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/susam%2Finwee","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/susam%2Finwee/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/susam%2Finwee/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/susam%2Finwee/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/susam","download_url":"https://codeload.github.com/susam/inwee/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254243312,"owners_count":22038048,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["configuration","irc","weechat"],"created_at":"2025-05-14T23:14:46.353Z","updated_at":"2025-05-14T23:15:52.287Z","avatar_url":"https://github.com/susam.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"InWee\n=====\nInWee is a convenience wrapper script to send text messages and commands\nto WeeChat from shell or from within WeeChat via\n[WeeChat's FIFO pipe][1].\n\n[![Download][SHIELD]][DOWNLOAD]\n\n[1]: http://www.weechat.org/files/doc/stable/weechat_user.en.html#fifo_plugin\n[SHIELD]: https://img.shields.io/badge/download-inwee-brightgreen.svg\n[DOWNLOAD]: https://github.com/susam/inwee/releases/download/0.2.0/inwee\n\n\nContents\n--------\n* [Necessity](#necessity)\n* [Installation](#installation)\n  * [Manual](#manual)\n  * [With wget](#with-wget)\n  * [With git](#with-git)\n* [Getting Started](#getting-started)\n  * [Using from Shell](#using-from-shell)\n  * [Using from WeeChat](#using-from-weechat)\n* [Without InWee](#without-inwee)\n* [Credits](#credits)\n* [License](#license)\n* [Contact](#contact)\n\n\nNecessity\n---------\nWeeChat keeps configuration in several .conf files in ~/.weechat\ndirectory. The configuration can be edited with WeeChat `/set` commands.\nUnfortunately, the same .conf files contain both the default\nconfiguration options that have not been altered by the user as well as\ncustom configuration options specified by the user. This makes it\nclumsy to pick only the user specific custom configuration, save it in a\nseparate file as backup, so that it can be applied later when needed,\nsay after reinstallation of operating system or on a new system.\n\nOne solution to this problem is to keep all the user specific\nconfiguration in the form of `/set` commands in a file, say\nsettings.txt, as shown below.\n\n     /set irc.server.freenode.nicks humpty,humpty_\n     /set irc.server.freenode.username humpty\n     /set irc.server.freenode.realname \"Humpty Dumpty\"\n     /set irc.server.freenode.autojoin #weechat,#test,#freenode\n     /save irc\n     /print Saved configuration\n\nThis file can be fed into WeeChat's FIFO pipe while WeeChat is running\nusing the following shell command.\n\n    sed 's/^/*/' settings.txt \u003e ~/.weechat/weechat_fifo_*\n\nThe command first prefixes every line in the file with `*` (asterisk)\nbecause that is how WeeChat's FIFO pipe expects the input to be. Then it\nfeeds the lines to WeeChat's FIFO pipe.\n\nIf the above solution is good enough for you, then there is no real\nreason to use InWee. In that case, you can skip directly to the\n[Without InWee](#without-inwee) section and read about how everything\nthat can be done with InWee can also be done without it.\n\nInWee only makes the above solution more convenient. For example, the\ncommands in settings.txt can be fed to WeeChat with InWee by entering\nthe following command while WeeChat is running.\n\n    inwee settings.txt\n\nThis simple command offers the following advantages over the earlier\ncommand involving sed command's output redirection.\n\n 1. It is simpler and easier to type.\n 2. It automatically prefixes every command in the input file with `*`\n    (asterisk).\n 3. It automatically checks if the FIFO pipe exists at ~/.weechat. If\n    it does not exist, it quits with an error.\n 4. It supports comments in the input file. Any line in the file where\n    `#` (hash) is the first non-whitespace character is ignored as\n    comment.\n\nWeeChat can execute external commands with the `/exec` command and it\naccepts the `-r` option to run commands after startup, so when WeeChat\nis not running, it can be made to run the commands in settings.txt after\nstarting up as follows.\n\n    weechat -r '/exec inwee settings.txt'\n\n\nGetting Started\n---------------\nInWee is a single-file executable script: [`inwee`][DOWNLOAD].\n\nCopy it to a directory specified in the PATH environment variable and\nmake it executable: `chmod u+x inwee`. In many Linux systems,\n`/usr/local/bin` or `~/bin` is a good location to copy this script to.\n\nInWee may be invoked directly from the shell using the `inwee` command\nor from WeeChat using its `/exec` command. Several examples of both\nways of usage are provided below.\n\n### Using from Shell ###\nThe following list shows various ways to use InWee from the shell.\n\n 1. Here is a typical example of using InWee from the shell. Say\n    you are in a Linux support channel such as ##linux, #debian,\n    #centos, etc. and you need to share the network controller details\n    of your system with the channel while asking for help. To do this\n    with InWee, you can run the commands you need to get this\n    output and pipe it into `inwee` as shown below to send the output\n    to the current buffer in WeeChat.\n\n        lspci | grep -i network | inwee\n\n 2. Here are some general examples of sending text or commands from\n    standard input to the current buffer in WeeChat. Any text or\n    WeeChat command you pipe into the standard input of InWee is sent\n    to WeeChat.\n\n        echo hello world | inwee\n        echo '/join #test' | inwee\n        echo /part | inwee\n        echo /nick newnick | inwee\n\n    Note that comments in shell begin with `#`, therefore the WeeChat\n    `join` command in the second shell command above is quoted. Any\n    text beginning with `/` (slash), followed by a word and whitespace\n    is considered as a WeeChat command. All other text is considered as\n    text messages to be sent on chat.\n\n 3. Multiple texts and/or commands must be separated by a newline.\n\n        printf '/join #test\\n/join #flood\\n' | inwee\n\n    Every line of text or command must also end with a newline. Since\n    `printf` does not append a newline in the end like `echo` does, we\n    end the strings passed to `printf` in each command above with a\n    newline.\n\n    Blank lines, lines that consist only of whitespace characters and\n    lines that contain `#`, i.e. hash, as the first non-whitespace\n    character are ignored.\n\n 4. The previous example may also be conveniently written in the\n    following manner.\n\n        echo '/join #flood\n        /join #test' | inwee\n\n 5. Text or commands may be sent to a specific WeeChat buffer with the\n    `-b` or `--buffer` option.\n\n        echo hello world | inwee -b 'irc.freenode.#test'\n\n    With the above command, the text is sent to #test channel even when\n    this channel is not in the current buffer.\n\n 6. Send text or commands from a file by specifying the path to the\n    file as an argument.\n\n        inwee input.txt\n\n    The file may contain one or more lines of text or commands. Blank\n    lines, lines that consist only of whitespace characters and lines\n    that contain `#`, i.e. hash, as the first non-whitespace character\n    are ignored. Therefore, `#` can be used to begin single line\n    comments.\n\n 7. To use a custom FIFO path with WeeChat.\n\n        echo \"hello world\" | inwee --fifo \"$HOME/.weechat/weechat_fifo\"\n\n    This will make inwee use a custom FIFO path to communicate with\n    WeeChat.\n\n### Using from WeeChat ###\nFrom WeeChat's perspective, InWee is an external command that can be\ninvoked with the `inwee` command. WeeChat's `/exec` command executes\nexternal commands inside WeeChat and displays the output locally, or\nsends it to a buffer. Therefore, `inwee` can be used within WeeChat\nusing WeeChat's `/exec` command. This section shows a few such examples.\nNote that unlike in the previous section where the command examples are\nmeant to be run in the shell, the commands below are meant to be run\ninside WeeChat directly.\n\n 1. Send text or commands from a file to the current buffer.\n\n        /exec inwee input.txt\n\n 2. Send text or commands from a file to #test channel.\n\n        /exec inwee -b irc.freenode.#test input.txt\n\n\nWithout InWee\n-------------\nEverything that can be done with InWee can be done without it, although\nit can be a little clumsy for some cases. This section is written for\nthose who do not want to use InWee but do what can be done with InWee by\nworking directly with WeeChat's FIFO pipe or WeeChat's `/exec` command.\nWeeChat's FIFO pipe is located at ~/.weechat by default and named as\n`weechat_fifo_\u003cPID\u003e` where `\u003cPID\u003e` stands for the PID of the currently\nrunning instance of WeeChat.\n\nAssuming WeeChat is currently running and there is a FIFO pipe for\nWeeChat at ~/.weechat, the list below explains how something that can be\ndone with InWee can also be done without it.\n\n 1. Send the output of a shell command from shell to WeeChat.\n\n    With InWee:\n\n        lspci | grep -i network | inwee\n\n    Without InWee:\n\n        lspci | grep -i network | sed 's/^/*/' \u003e ~/.weechat/weechat_fifo_*\n\n 2. Send a message to a WeeChat channel from shell.\n\n    With InWee:\n\n        echo hello world | inwee\n\n    Without InWee:\n\n        echo '*hello world' \u003e ~/.weechat/weechat_fifo_*\n\n 3. Send a WeeChat command from shell to WeeChat.\n\n    With InWee:\n\n        echo /nick newnick | inwee\n\n    Without InWee:\n\n        echo */nick newnick \u003e ~/.weechat/weechat_fifo_*\n\n 4. Send text or command to a specific WeeChat buffer from shell.\n\n    With InWee:\n\n        echo hello world | inwee -b irc.freenode#test\n\n    Without InWee:\n\n        echo 'irc.freenode.#test *hello world' \u003e ~/.weechat/weechat_fifo_*\n\n 5. Send text or commands in a file to WeeChat from shell.\n\n    With InWee:\n\n        inwee input.txt\n\n    Without InWee:\n\n        sed 's/^/*/' input.txt \u003e ~/.weechat/weechat_fifo_*\n\n 6. Send the output of a simple shell command in WeeChat to a channel.\n\n    With InWee:\n\n        /exec -sh uname -a | inwee\n\n    Without InWee:\n\n        /exec -o uname -a\n\n    The `-sh` option is necessary in the first command to ensure that\n    the `/exec` command uses the shell to execute the specified shell\n    command. This ensures that `|` is interpreted as the pipeline\n    operator by the shell. Without the `-sh` option, the `/exec`\n    command executes the specified command itself and it would\n    interpret `|` as just another argument.\n\n    The `-o` command is necessary in the second command to ensure that\n    the output of the shell command is sent to the channel as chat\n    message. Without this option, the output is only printed locally\n    and not shared with the channel. There is no need of `-o` option in\n    the first command because InWee takes care of sending the output as\n    text message to the channel's buffer via WeeChat's FIFO pipe.\n\n 7. Send output to a specific channel in WeeChat.\n\n    With InWee:\n\n        /exec -sh uname -a | inwee -b irc.freenode.#test\n\n    Without InWee:\n\n        /exec -sh -o -buffer irc.freenode.#test uname -a\n\n 8. Send the output of a little more complex shell command, say\n    involving pipeline operators, in WeeChat.\n\n    With InWee:\n\n        /exec -sh lspci | grep -i network | inwee\n\n    Without InWee:\n\n        /exec -sh -o lspci | grep -i network\n\n 9. Send text or commands in a file to the current buffer in WeeChat.\n\n    With InWee:\n\n        /exec inwee input.txt\n\n    Without InWee:\n\n        /exec -sh sed 's/^/*/' input.txt \u003e ~/.weechat/weechat_fifo_$(pidof weechat)\n\n\nCredits\n-------\nThank you, [Dom Rodriguez][C1], for adding support for WeeChat 1.7.\n\n[C1]: https://github.com/shymega\n\n\nLicense\n-------\nThis is free and open source software. You can use, copy, modify,\nmerge, publish, distribute, sublicense, and/or sell copies of it,\nunder the terms of the MIT License. See [LICENSE.md][L] for details.\n\nThis software is provided \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nexpress or implied. See [LICENSE.md][L] for details.\n\n[L]: LICENSE.md\n\n\nContact\n-------\nTo report bugs, suggest improvements, or ask questions, please create a\nnew issue at \u003chttp://github.com/susam/inwee/issues\u003e.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsusam%2Finwee","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsusam%2Finwee","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsusam%2Finwee/lists"}