Skip to content

Instantly share code, notes, and snippets.

@Konfekt
Konfekt / mailcap
Last active November 2, 2024 05:33
mailcap file to display files in and outside of terminal for mutt, less, ranger / lf, ..
# Save as ~/.mailcap. Then use run-mailcap to:
#
# - open files by `run-mailcap --action=view <file>`, or
# - view them in the terminal by `run-mailcap --action=cat <file>`.
#
# Useful
#
# - in mutt by `set mailcap_file $HOME/.mailcap`
# - in Vim by adding to your vimrc
#
@Konfekt
Konfekt / highlight-unicode-homoglyphs.vim
Last active June 27, 2019 09:54
highlight common unicode homoglyphs as error in Vim
" TODO Update to list at https://www.irongeek.com/homoglyph-attack-generator.php
augroup vimrc
autocmd!
autocmd ColorScheme *
\ highlight homoglyphfg cterm=underline ctermfg=DarkGreen ctermbg=NONE gui=undercurl guifg=DarkGreen guibg=NONE |
\ highlight homoglyphbg ctermfg=NONE ctermbg=DarkGreen guifg=NONE guibg=DarkGreen
augroup END
silent doautocmd vimrc ColorScheme
" Highlight non-breaking white space characters
1match homoglyphbg '[\x0b\x0c\u00a0\u1680\u180e\u2000-\u200a\u2028\u202f\u205f\u3000\u3164\ufeff]'
@Konfekt
Konfekt / okular-markdown-preview-vim.md
Last active October 29, 2024 22:30
A dead-simple markdown previewer in Vim thanks to KDE's document viewer Okular

KDE's document viewer Okular renders markdown as HTML (and reloads it automatically on changes.) Thus, simply open the markdown file currently edited in Vim in Okular to be all set!

To start an GUI application from Vim, without freezing, hit-<enter> prompts or scrambling screen lines, one can add a command such as

if has('unix')
 command! -complete=shellcmd -nargs=1 -bang Silent execute ':silent !' . (0 ? 'nohup ' .  . '/dev/null 2&gt;&amp;1 &amp;' : ) | execute ':redraw!'
@Konfekt
Konfekt / opensuse-add-packages-school.sh
Last active June 2, 2021 10:32
Installation von openSUSE zusätzlichen Programmpaketen für die Oberstufe nach Installation des Betriebssystems
# Zum Installieren:
#
# 0. Mit dem Internet verbinden.
# 1. Windowstaste drücken
# 2. Konsole eingeben und Eingabetaste drücken
# 3. In der Konsole eingeben:
#
# curl -s https://gist.githubusercontent.com/Konfekt/33a3adfc7ad5f5f0bd55dee290654e02/raw/6c44d19be3011e1ff32b42243d1e6c1ce05bddfd/opensuse-essentials.sh | sudo bash /dev/stdin
#
# und Eingabetaste drücken.
@Konfekt
Konfekt / opensuse-add-packages.sh
Last active June 6, 2023 05:33
add useful program packages after installation of openSUSE
if [ $(id -u) -ne 0 ]; then
echo "Please run as root, for example, by sudo!"
exit
fi
. /etc/os-release
version="$VERSION_ID"
z="sudo zypper --non-interactive --ignore-unknown --gpg-auto-import-keys --no-gpg-checks"
zin="$z install --download in-advance --recommends --auto-agree-with-licenses --replacefiles --force-resolution --no-confirm"
@Konfekt
Konfekt / windows10-add-packages.ps1
Last active September 6, 2024 04:22
add useful chocolatey packages after installation of Windows 10
Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
choco feature enable -n=allowGlobalConfirmation
# remove bloat as in
# https://lifehacker.com/you-can-get-rid-of-windows-bloatware-with-one-command-1848707156
iwr -useb https://git.io/debloat | iex
iwr -useb https://christitus.com/win | iex
@Konfekt
Konfekt / zathist.sh
Last active April 17, 2020 19:28
zathura MRU: filter in rofi all files viewed in zathura ordered by recency and view selection
#! /bin/sh
#
# Save this script as executable ~/bin/zathist.sh and
# add to ~/.xbindkeysrc the shortcut
#
# "$HOME/bin/zathist.sh"
# Control + Alt + z
#
# PDFs whose path matches this pattern will not be listed
@Konfekt
Konfekt / markdown-to-html.muttrc
Last active May 9, 2023 19:29
mutt key binding to compile markdown to HTML
# press M in the mutt compose menu before sending to convert
# the markdown syntax of the e-mail text into an HTML e-mail
macro compose M "<pipe-entry>tee /tmp/message.txt | pandoc --standalone --from markdown --to html --metadata title=Message --output=/tmp/message.html<enter><attach-file>/tmp/message.txt<enter><toggle-disposition><edit-description>Message in TEXT format<enter><edit-type><kill-line>text/plain; charset=utf-8<Enter><first-entry><detach-file><attach-file>/tmp/message.html<enter><toggle-disposition><edit-description>Message in HTML format<enter><edit-type><kill-line>text/html; charset=utf-8<Enter>" "attach HTML message converted from Markdown"
# alternatively, use discount instead of pandoc ...
# macro compose M "<pipe-entry>tee /tmp/message.txt | mkd2html > /tmp/message.html<enter>"
@Konfekt
Konfekt / kc-sms.sh
Last active May 8, 2020 14:54
kc-sms - send SMS using KDEconnect on the command line
#!/bin/sh
if ! command -v kdeconnect-cli >/dev/null 2>&1; then
echo "kde-connect-cli not found! Please install KDE Connect."
exit 1
fi
if [ $# -eq 0 ] || [ "$1" = -h ] || [ "$1" = --help ]; then
echo "kc-sms - send SMS using KDE Connect on the command line"
echo "usage: kc-sms <Phone Number> <Message> [Parameters]"
@Konfekt
Konfekt / any2webm.sh
Last active March 13, 2021 09:31
convert video files into the WebM format in batches using ffmpeg (and preferrably GNU parallel)
#!/bin/sh
# convert video files into the WebM format in batches using ffmpeg (and preferrably GNU parallel)
# exit on error or use of undeclared variable or pipe error:
set -o errexit -o nounset -o pipefail
# -crf 10 : Constant Rate Factor (crf) gives video quality from 0 (lossless) to 63 (worst); default is 23.
# -c:a/v ... = transform the audio/video data using ...
# -b:a/v ... = audio/video bitrate is ...