From a17e26f339d10a381ad32621a179ed49da23ba45 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 16 Mar 2026 16:05:17 +0000 Subject: [PATCH 1/3] Initial plan From 1056efcabbde88c98d4a03fde3a0609e083a7627 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 16 Mar 2026 16:11:41 +0000 Subject: [PATCH 2/3] feat: add extract, rgf, mkd, ps-fzf, tldrf helper functions Co-authored-by: tin900 <113692500+tin900@users.noreply.github.com> --- bash/.config/bash/functions | 82 +++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/bash/.config/bash/functions b/bash/.config/bash/functions index 13a3775..4e62627 100644 --- a/bash/.config/bash/functions +++ b/bash/.config/bash/functions @@ -65,6 +65,29 @@ EOF # ===================== compress() { tar -czf "${1%/}.tar.gz" "${1%/}"; } +extract() { + if [ -z "$1" ]; then + echo "Usage: extract " + return 1 + fi + if [ ! -f "$1" ]; then + echo "'$1' is not a file" + return 1 + fi + case "$1" in + *.tar.gz|*.tgz) tar -xzf "$1" ;; + *.tar.bz2|*.tbz2) tar -xjf "$1" ;; + *.tar.xz) tar -xJf "$1" ;; + *.tar) tar -xf "$1" ;; + *.zip) unzip "$1" ;; + *.gz) gunzip "$1" ;; + *.bz2) bunzip2 "$1" ;; + *.xz) unxz "$1" ;; + *) echo "Cannot extract '$1': unsupported format" ; return 1 ;; + esac +} +# Usage: extract – auto-detect and extract any common archive format + # ===================== # CSV Exploration Helper # ===================== @@ -79,6 +102,26 @@ csvlens() { } # Usage: csvlens (fuzzy-pick CSV), csvlens file.csv (direct open) +# ===================== +# Interactive Content Search +# ===================== +rgf() { + if [ "$#" -eq 0 ]; then + echo "Usage: rgf [rg options]" + return 1 + fi + local result + result=$( + rg --color=always --line-number --no-heading "$@" 2>/dev/null | + fzf --ansi \ + --delimiter ':' \ + --preview 'batcat --color=always --style=numbers --highlight-line {2} {1}' \ + --preview-window 'up,60%,border-bottom,+{2}+3/3,~3' + ) + [ -n "$result" ] && echo "$result" +} +# Usage: rgf – ripgrep search with fzf preview; outputs the selected file:line + # ===================== # APT & Package Management # ===================== @@ -132,6 +175,9 @@ apt-fzf-purge() { # ===================== # Shell & History Utilities # ===================== +mkd() { mkdir -p "$@" && cd "${!#}"; } +# Usage: mkd path/to/dir – create directory (and parents) then cd into it + zd() { if [ $# -eq 0 ]; then builtin cd ~ && return @@ -150,6 +196,42 @@ __fzf_history__() { fi } bind -x '"\C-r": __fzf_history__' + +# ===================== +# Interactive Process Management +# ===================== +ps-fzf() { + local pid + pid=$(ps aux | + fzf --header-lines=1 \ + --prompt='Kill process> ' \ + --preview 'echo {}' \ + --preview-window=down:3:wrap | + awk '{print $2}') + if [ -n "$pid" ]; then + read -r -p "Send SIGTERM to PID $pid? [y/N] " confirm + [[ "$confirm" =~ ^[Yy]$ ]] && kill "$pid" && echo "Sent SIGTERM to PID $pid" || echo "Aborted." + fi +} +# Usage: ps-fzf – interactively select a running process and send SIGTERM + +# ===================== +# Documentation & Help +# ===================== +tldrf() { + if ! command -v tldr >/dev/null 2>&1; then + echo "tldr (tealdeer) is not installed." + return 1 + fi + local cmd + cmd=$(tldr --list 2>/dev/null | + fzf --prompt='tldr> ' \ + --preview='tldr {}' \ + --preview-window='right:70%:wrap') + [ -n "$cmd" ] && tldr "$cmd" +} +# Usage: tldrf – fuzzy-pick a command to view its tldr (tealdeer) page + # ===================== # GitHub Clone Helper # ===================== From b34a933d9eafb70948b9938f7f8eb12d2e9979a7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 16 Mar 2026 16:18:06 +0000 Subject: [PATCH 3/3] feat: add glf, jqf, envf, ghpr helper functions Co-authored-by: tin900 <113692500+tin900@users.noreply.github.com> --- bash/.config/bash/functions | 78 +++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/bash/.config/bash/functions b/bash/.config/bash/functions index 4e62627..c1df09b 100644 --- a/bash/.config/bash/functions +++ b/bash/.config/bash/functions @@ -232,6 +232,84 @@ tldrf() { } # Usage: tldrf – fuzzy-pick a command to view its tldr (tealdeer) page +# ===================== +# Git Log Browser +# ===================== +glf() { + if ! git rev-parse --git-dir >/dev/null 2>&1; then + echo "Not inside a git repository." + return 1 + fi + local commit + commit=$( + git log --oneline --color=always "$@" | + fzf --ansi \ + --prompt='git log> ' \ + --preview 'git show --stat --color=always {1}' \ + --preview-window='right:60%:wrap' + ) || return + [ -n "$commit" ] && git show "$(echo "$commit" | awk '{print $1}')" +} +# Usage: glf [git-log options] – browse git history; preview and show diff of selected commit + +# ===================== +# JSON Explorer +# ===================== +jqf() { + local file + if [ "$#" -eq 0 ]; then + file=$(fdfind . . --type f --extension json 2>/dev/null | fzf --prompt='JSON file> ' --preview 'jq -C . {}') + [ -z "$file" ] && return + else + file="$1" + fi + if [ ! -f "$file" ]; then + echo "'$file' is not a file" + return 1 + fi + jq -C . "$file" | batcat --language=json --style=plain --color=always +} +# Usage: jqf [file.json] – fuzzy-pick or open a JSON file, pretty-print with jq + batcat + +# ===================== +# Environment Variables +# ===================== +envf() { + local var + var=$(env | sort | + fzf --prompt='env> ' \ + --preview 'echo {}' \ + --preview-window=down:3:wrap) + [ -n "$var" ] && echo "$var" +} +# Usage: envf – fuzzy-search current environment variables + +# ===================== +# GitHub PR Checkout +# ===================== +ghpr() { + if ! command -v gh >/dev/null 2>&1; then + echo "gh CLI is not installed." + return 1 + fi + local pr + pr=$( + gh pr list \ + --json number,title,author,headRefName \ + --jq '.[] | "\(.number)\t\(.title)\t@\(.author.login)\t\(.headRefName)"' | + fzf --prompt='Checkout PR> ' \ + --with-nth=1,2,3 \ + --delimiter='\t' \ + --ansi \ + --preview 'gh pr view {1}' \ + --preview-window='right:60%:wrap' | + cut -f1 + ) || return 1 + [ -z "$pr" ] && echo "No PR selected" && return 1 + gh pr checkout "$pr" +} +# Usage: ghpr – fuzzy-pick an open pull request and check it out locally + # ===================== # GitHub Clone Helper # =====================