Blog: Fr. Robert

VimWiki outside of Vim Revisted

Since me last post about VimWiki on the command line I have created a new script. I have also decided to run it as a function rather than an alias.

The new function is as follows

#!/bin/sh

function notesfind(){

wordfind=$1

/bin/grep -rwi "$wordfind" /home/frrobert/Nextcloud/vimwiki | fzf |cut -f1 -d":" | xargs cat

}

The function searchs within VimWiki documents to find a word match based on the word given. They syntax is notesfind followed by the word you are searching for. The results from grep are sent to fzf where a menu is presented with all the files that include the word along with the line of the file where the word is found. Once you select the file you are interested in, the file is displayed on the command line.

To the use the script simply copy the text of the script to an empty file and change the path to the location of your VimWiki files.. The way it is written is it can be used as a shell function or a shell script.

Remember this is not designed to replace the search VimWiki but a way to access a VimWiki document without having to switch to Vim when you are doing other work on the command line.

Bibliography

VimWiki https://github.com/vimwiki/vimwiki

cheat.sh https://github.com/chubin/cheat.sh

fzf https://github.com/junegunn/fzf

Luke Smith's fzf Video https://www.youtube.com/watch?v=vt33Hp-4RXg

The Editor Wars a Different Take

Vim or Emacs which is the best? The question that will never be fully answered or decided.

a Vim user and I think it is great. I have tried Emacs a few times and I could not stay with it longer then a few hours. But why? Both are good editors and both are very useful. The problem I have with Emacs is the same problem I have Vim both were designed with two handed typist in mind. There is the rub. What if you type one handed? What are you to do?

If you home row is f g h j and you only can type using five fingers you have to rethink much of your computer use.

Keyboard driven programs are the best. They don't require the use of the mouse. Using the mouse for the one handed typist means leaving the keyboard completely and going to the mouse and then coming back. The idea of using the mouse and a key combination at the same time is a huge pain.

Any two key combinations are a pain in the hand. Try doing the Windows key and the enter key at the same time on a laptop keyboard. That is a very far reach. There is the problem with Emacs with all it key combinations it is very hard and uncomfortable for the one handed typist. That is where Vim's modal design shines for the one handed typist. The modal design of Vim makes it much easier for me to type and edit one handed. The uncomfortable key combinations are left behind and you can type much faster and much more comfortably.

I can hear people now saying what about the escape key and the colon key. Both keys are a difficult keys for the one handed typist. I have swapped the Escape key and the Caps Lock key at the OS level. I have also swapped the colon and the semicolon at the Vim Normal mode.

The escape key is used so much in and out of Vim I did the swap at the OS level. Since the colon is used mostly in the Vim Normal mode and the semicolon more during typing of text I did that change in Vim.

While I have no idea which editor is best for the two handed typist, Vim wins hand down for the one handed typist.

VimWiki outside of Vim

I am a big fan of Vim. I use it to do my general word processing, to keep a diary, and to keep general notes. A plugin called VimWiki helps me to the last two. VimWiki allows you to keep notes and a diary. The notes in my Wiki are varied but one thing I keep in the wiki is little notes about commands I use in the shell. Often I forgot the syntax of a command while I am working on the command line but I know I have notes in my wiki on how to do what I want. So I have to go to Vim find the entry I want then go back to command line and type the command. This is assuming I haven't forgotten what the wiki said by the time I get back to the command line.

I found a neat little utility call cheat.sh. It will bring up an abbreviated cheat sheet for the command you typed in. I wanted to do something similarly but with my VimWiki entries. If I know the wiki entry file name I could just use the cat command to show it on the screen. I am too old for that. I remember coming across a YouTube Video by Luke Smith about fzf.

So between the video and fzf I came up with an alias to allow me to find wiki entries.

alias notes='du -a /home/frrobert/Nextcloud/vimwiki/* |awk "{print$2}" | fzf | xargs -r cat'

I type notes and hit enter and a list of wiki entries come up and I type what I think may be the file name and fzf finds it for me. One more strike of the enter key and the article is there on the command line.

Bibliography

VimWiki https://github.com/vimwiki/vimwiki

cheat.sh https://github.com/chubin/cheat.sh

fzf https://github.com/junegunn/fzf

Luke Smith's fzf Video https://www.youtube.com/watch?v=vt33Hp-4RXg

Fortune

Fortune is a Unix/Linux program that will generate a pseudo random fortune / quote from a text based database. Fortune comes with several databases by default that are of no real interest to me. My interest in fortune is the ability to create and use your own databases. Rather than having a fortune come up I wanted a quote from a church father to come up.

Creating a database with quotes from the church fathers is a two step process.

The first step is is to create an Linux/Unix based text file with quotes that you want to you use. Between each quote there should be a single line with a single %

An example being:

Affliction was allowed to make those afflicted more careful and more pious.
--Saint John Chrysostom
%
What rain is for seeds tears are for those who are afflicted…
--Saint John Chrysostom

Once you save your file run the following command from the terminal in the directory your file is located

strfile YourTextFile

This will create YourTextFile.dat

If you type fortune /pathtoyourfile/YourTextFile

A "fortune" in this case a saying from the Church Fathers will be generated at the command line. You can pipe this into other programs such as cowsay or xcowsay. I added to my .zshrc file so every time I start a new terminal I get a saying of a church father. I also created an alias for clear so every time I clear my terminal I get a saying from a church father. You can create a simple script that pipes fortune into xcowsay or notify-file to get a popup in your xwindow session based on either an action or based on a time frame. There is a php version of fortune that allows you to add random sayings to your website.

Replacing the Ancient Faith Android App Updated Again

If you are like me you appreciate the content of Ancient Faith Radio, but if you are also like me and have a lower end Android phone you can not get the app to run on your phone without crashing. I have found a decent workaround for the issue. To be specific there are actual two different workarounds. The first is a replacement for the two streaming radio stations, music and talk. The other workaround is for streaming or downloading podcasts.

The first workaround for streaming radio is using a music player that suppports network streaming protocals. I have tried two that work very well. The first is VLC for Android and the second is Foobar2000. If you have not used a streaming music player before , I would recommend VLC as it is much easier to setup.

To use VLC after installing the app and opening it you select Stream as your source. You then will be asked for a network address. The url for Music on Ancient Faith is http://ancientfaith.streamguys1.com/mp3music and the url for talk is http://ancientfaith.streamguys1.com/mp3talk. By entering the appropriate network address the music player will play the live stream.

To download podcasts on Android the best tool I found is Google Podcasts. You can download podcasts to listen off-line or listen online. You can subscribe to any of the Ancient Faith Podcasts you wish and it does of very good job of keeping track of the podcasts you have listened to and the ones you have downloaded.

This post is not intended to be a full set of instructions but a suggestion of how to work around the issues with the Ancient Faith App. Please feeel free to contact me if you want me to post a detailed instructions.