Skip to content

Instantly share code, notes, and snippets.

View GeneralD's full-sized avatar
💭
Alcohol makes better code 🥃

YUMENOSUKE GeneralD

💭
Alcohol makes better code 🥃
View GitHub Profile
function skim-gitignore() {
local api="https://www.toptal.com/developers/gitignore/api"
local gi=$(curl -sfL $api/list | tr "," "\n" | sk --query="$1" -m --preview "curl -sfLw '\n' $api/{} | bat --style=numbers --color=always --language='Git Ignore'")
if [[ $gi ]]; then
for prog in $(echo $gi); do;
curl -sfLw '\n' "$api/$prog" >> .gitignore;
echo "Added $prog to .gitignore";
done;
fi
#!/usr/bin/env zsh
keybind_as_widget() {
local hash=$(echo $2 | md5)
local widget_name="__widget_$hash"
eval "function $widget_name() { $2; }"
zle -N $widget_name
bindkey $1 $widget_name
}
#!/usr/bin/env zsh
# helper functions for https://github.com/Aloxaf/gencomp
clean-gencomp() {
for file in $GENCOMP_DIR/*; do
local cmd=$(basename $file | sed 's/^_//')
command -v $cmd &>/dev/null && continue
echo "Remove completion for $cmd? [y/N]"
read -q
function skim-nerdfont() {
(( $+commands[ascii2uni] )) || { echo "ascii2uni is not installed"; return 1; }
(( $+commands[rg] )) || { echo "rg is not installed"; return 1; }
local list=$(curl -s https://www.nerdfonts.com/cheat-sheet | rg '^ *\"(.+)\"\: ?\"([a-f0-9]{4})\",?$' --color=never --replace '\u$2 $1' | ascii2uni -a U -q)
local select=$(echo $list | sk --query="$1" --multi)
echo $select | awk '{print $1}' | tr '\n' ' ' | pbcopy
zle reset-prompt;
}