Here, we're definitely doing that, and even keeping them in Vim's swap files (if you haven't changed that setting). Keybase doesn't lack a spellcheck because the devs are lazy-they kept it out because they were concerned about security risks of sending keystrokes outside the program. More importantly, depending on your threat model, their could be security risks to using this approach. But if they annoy you, just remember to delete them. This doesn't bother me I just keep them in a keybase-chat directory and can then tab-complete to open them again later. Less importantly: because this command saves the file, it will leave behind a file with the name you gave it. ( ggdG should do the trick).Ĭonversely, you might want to keep your sent message until you manually delete it, in which case you can just cut the part of autocmd that deletes the current line. If you prefer to send longer messages, you might want to remove the insert-mode mapping and change the script to delete the whole message instead of just the current line. This setup is optimized for sending one-line chat messages: since we've remapped enter in insert mode, it's very difficult to send multi-line messages. We clear the current line ( dd) and drop back into insert mode ( i) so that we can send our next message. This sends the message.Īfter this, we're just dealing with some cleanup. So, instead, we invoke the expression register ( =) and give it the name of our variable.įinally, we pipe in the contents of the current file ( < %) and enter our command. Need to get at the variable we've saved-but we can't access it directly within the ex command we're running. That terminal command invokes the keybase cli and tells it to send a chat message ( keybase chat send).Īt this point, we need to specify the target of the chat message. Each of these keys now saves the current file ( :w) and then runs a terminal command ( :!). Next, these commands cause Vim to remap enter in insert mode and enter in normal mode. It then saves this extension to the variable conversation. What does this command do? Well, first, the command looks at the current file ( %) and grabs its extension ( :e). But here's what's going on:įirst, we create a group of commands to be run automatically, and we tell Vim to run those commands whenever the filename includes the string "keybase-outbox". How does this work? Well, I don't claim to be a vimsrcipt master (I'm still halfway through Learn Vimscript the Hard Way and probably won't get around to finishing it for quite some time). I still have the keybase app up in a split-screen window with Vim next to it. I'm sure you could do that if you really want to live in the terminal (using the keybase chat read in a loop should do the trick) but that's not the exercise here. Note that this doesn't display your chat messages in vim/the terminal. This will send your chat, clear the file, and drop you back into insert mode, ready to type your next message. Or, if you're in normal mode, hit and then enter. Type your message and then (while still in insert mode) hit enter to send it (just like you would in a chat client). (so, if you wanted to message me, you'd type vim desections). Then, to send a chat message to a keybase use vim to open a file with the filename keybase-outbox. augroup keybaseĪutocmd BufNewFile, BufRead * keybase-outbox * let conversation = expand ( '%:e' )Īutocmd BufNewFile, BufRead * keybase-outbox * inoremap :w :!keybase chat send =conversation ddiĪutocmd BufNewFile, BufRead * keybase-outbox * nnoremap :w :!keybase chat send =conversation ddi vimrc file (or ~/.config/nvim/init.vim file for Neovim users). And you'll obviously need vim/neovim installed too. If you don't have it, you can get it from their website. How Toįirst, you'll need to have the keybase app installed, which will automatically install their command-line client. I'll give you the tl dr how-to version quickly, and then I'll walk though what we're doing in a little more detail and talk about how you could customize it for your use-case. I thought this would be a pretty rare use case (how many other people really care about spelling, or want to edit one-line chat messages in Vim?) But a number of people expressed interest, so I decided to write this post as a how-to. I found a way to fix it: I now write my chat messages in Vim and then pipe them to keybase chat. Except … I just started using keybase.io's chat program, and it doesn't check spelling. Luckily, this isn't an issue 99% of the time as an adult, because I'm never asked to operate in an environment without a spellcheck. Like, was-sent-to-special-classes-as-a-child-and-they-gave-up-on-me cannot spell. Sending Keybase Chats Using Vim | CodeSections
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |