From 936ceae3009e528e352e9f2e12a504df9f145fe6 Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Thu, 23 Feb 2023 14:27:32 -0600 Subject: [PATCH] more zsh functions --- home/private_dot_config/zsh/functions/allexts | 4 ++ home/private_dot_config/zsh/functions/noext | 5 ++ .../zsh/functions/showcolors | 52 +++++++++++++++++++ home/private_dot_config/zsh/functions/weather | 3 ++ 4 files changed, 64 insertions(+) create mode 100644 home/private_dot_config/zsh/functions/allexts create mode 100644 home/private_dot_config/zsh/functions/noext create mode 100644 home/private_dot_config/zsh/functions/showcolors create mode 100644 home/private_dot_config/zsh/functions/weather diff --git a/home/private_dot_config/zsh/functions/allexts b/home/private_dot_config/zsh/functions/allexts new file mode 100644 index 0000000..3283ece --- /dev/null +++ b/home/private_dot_config/zsh/functions/allexts @@ -0,0 +1,4 @@ +#!/bin/zsh +##? Show all extensions in current folder structure. + +find . -not \( -path '*/.git/*' -prune \) -type f -name '*.*' | sed 's|.*\.|\.|' | sort | uniq -c diff --git a/home/private_dot_config/zsh/functions/noext b/home/private_dot_config/zsh/functions/noext new file mode 100644 index 0000000..383c2ec --- /dev/null +++ b/home/private_dot_config/zsh/functions/noext @@ -0,0 +1,5 @@ +#!/bin/zsh +##? noext - Find files with no file extension + +# for fun, rename with: noext -exec mv '{}' '{}.sql' \; +find . -not \( -path '*/.git/*' -prune \) -type f ! -name '*.*' diff --git a/home/private_dot_config/zsh/functions/showcolors b/home/private_dot_config/zsh/functions/showcolors new file mode 100644 index 0000000..13aaec7 --- /dev/null +++ b/home/private_dot_config/zsh/functions/showcolors @@ -0,0 +1,52 @@ +#!/bin/zsh +##? showcolors - display colors and color codes +##? +##? usage: showcolors + +# function showcolors { +local normal=$(tput sgr0) +typeset -A colors=( + 0 black + 1 red + 2 green + 3 yellow + 4 blue + 5 magenta + 6 cyan + 7 white + 8 brblack + 9 brred + 10 brgreen + 11 bryellow + 12 brblue + 13 brmagenta + 14 brcyan + 15 brwhite +) + +typeset -A effects=( + bold bold + dim dim + italic sitm + reverse rev + standout smso + underline smul +) + +local id +for id in ${(kno)colors}; do + color=$colors[$id] + printf "%5s %-25s %5s %-25s %-10s\n" $(tput setaf $id) "foreground ${color}" $(tput sgr0) "tput setaf $id" ${$(tput setaf $id):q} +done +for id in ${(kno)colors}; do + color=$colors[$id] + printf "%5s %-30s %11s %-25s %-10s\n" $(tput setab $id) "$(tput setaf 7)background $(tput setaf 0)${color}" $(tput sgr0) "tput setab $id" ${$(tput setab $id):q} +done + +local name code +for name in ${(kno)effects}; do + code=$effects[$name] + printf "%5s %-24s %5s %-25s %-10s\n" $(tput $code) "effect ${name}" $(tput sgr0) "tput $code" ${$(tput $code):q} +done +printf "%1s %-25s %-25s\n" "" "normal" "tput sgr0" +# } diff --git a/home/private_dot_config/zsh/functions/weather b/home/private_dot_config/zsh/functions/weather new file mode 100644 index 0000000..99e466b --- /dev/null +++ b/home/private_dot_config/zsh/functions/weather @@ -0,0 +1,3 @@ +#!/bin/zsh +# What is the weather? +curl "http://wttr.in/$1"