Skip to content

Instantly share code, notes, and snippets.

View kelvinauta's full-sized avatar

Kelvinauta kelvinauta

View GitHub Profile
# Use: `man somthing`
# Desc: This function adds the man command but opens it with nvim if it exists for your zsh or bash configuration.
function man() {
if ! command -v nvim &> /dev/null; then
echo "nvim is not installed, using normal man command"
command man "$@"
else
command man "$@" | col -bx | nvim -R - +'set ft=man'
fi
}
@kelvinauta
kelvinauta / print_nodeinfo_bspwm.sh
Last active June 7, 2025 09:56
Print useful information about the window node by retrieving data from bspwm and X11 Also displays it via notify-send
#!/usr/bin/env bash
# Print useful information about the window node by retrieving data from bspwm, X11 and Process Info (PID, RAM, CPU)
# Also displays it via notify-send
# Recommended usage: Add a keybinding in sxhkdrc to execute this script and run it only on the currently focused window to receive a notification with useful node information
# Requirements: bspwm (bspc), jq, xprop (x11-utils), notify-send (libnotify), servidor X11
set -e
node_id=${1:-$(bspc query -N -n focused)}
if [[ -z "$node_id" ]]; then
@kelvinauta
kelvinauta / remove_comments.lua
Created July 2, 2025 04:07
This function removes all comments from your code using treesitter in nvim.
local RemoveComments = function()
local ts = vim.treesitter
local bufnr = vim.api.nvim_get_current_buf()
local ft = vim.bo[bufnr].filetype
local lang = ts.language.get_lang(ft) or ft
local ok, parser = pcall(ts.get_parser, bufnr, lang)
if not ok then return vim.notify("No parser for " .. ft, vim.log.levels.WARN) end
local tree = parser:parse()[1]