summaryrefslogtreecommitdiff
path: root/.local/bin
diff options
context:
space:
mode:
Diffstat (limited to '.local/bin')
-rwxr-xr-x.local/bin/desktop/setbg2
-rwxr-xr-x.local/bin/development/gh-clone-all2
-rwxr-xr-x.local/bin/development/gh-repo-size (renamed from .local/bin/development/github-repo-size)0
-rwxr-xr-x.local/bin/development/ghclone5
-rwxr-xr-x.local/bin/development/gitignore (renamed from .local/bin/shorts/gi)0
-rwxr-xr-x.local/bin/development/gitweb (renamed from .local/bin/development/gitw)0
-rwxr-xr-x.local/bin/fgr82
-rwxr-xr-x.local/bin/frg70
-rwxr-xr-x.local/bin/shortcuts24
-rwxr-xr-x.local/bin/shorts/mailsyncd2
-rwxr-xr-x.local/bin/statusbar/i3weather26
-rwxr-xr-x.local/bin/web/ytplaylist34
12 files changed, 121 insertions, 126 deletions
diff --git a/.local/bin/desktop/setbg b/.local/bin/desktop/setbg
index c288895..8277caf 100755
--- a/.local/bin/desktop/setbg
+++ b/.local/bin/desktop/setbg
@@ -36,6 +36,6 @@ else
[ -f "$zathuraconf.bak" ] && unlink "$zathuraconf" && mv "$zathuraconf.bak" "$zathuraconf"
fi
-xwallpaper --zoom "$bgloc"
+xwallpaper --focus "$bgloc"
# If running, dwm hit the key to refresh the color scheme.
pidof dwm >/dev/null && xdotool key super+F5
diff --git a/.local/bin/development/gh-clone-all b/.local/bin/development/gh-clone-all
index d2b3cdc..fed6efe 100755
--- a/.local/bin/development/gh-clone-all
+++ b/.local/bin/development/gh-clone-all
@@ -12,5 +12,5 @@ while [ "$page" -lt "$max" ]; do
page=$(( page + 1 ))
curl "https://api.github.com/$cntx/$name/repos?page=$page&per_page=100" |
sed -E '/^\s*"clone_url": "(.*)",$/!d; s//\1/' |
- xargs -L1 echo git clone
+ xargs -L1 git clone
done
diff --git a/.local/bin/development/github-repo-size b/.local/bin/development/gh-repo-size
index 0cedd88..0cedd88 100755
--- a/.local/bin/development/github-repo-size
+++ b/.local/bin/development/gh-repo-size
diff --git a/.local/bin/development/ghclone b/.local/bin/development/ghclone
new file mode 100755
index 0000000..2e11024
--- /dev/null
+++ b/.local/bin/development/ghclone
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+URL="https://github.com/$1/${2:-$1}"
+echo "Clone URL: $URL"
+git clone "$URL"
diff --git a/.local/bin/shorts/gi b/.local/bin/development/gitignore
index d78ff99..d78ff99 100755
--- a/.local/bin/shorts/gi
+++ b/.local/bin/development/gitignore
diff --git a/.local/bin/development/gitw b/.local/bin/development/gitweb
index 881c81c..881c81c 100755
--- a/.local/bin/development/gitw
+++ b/.local/bin/development/gitweb
diff --git a/.local/bin/fgr b/.local/bin/fgr
new file mode 100755
index 0000000..34d69cc
--- /dev/null
+++ b/.local/bin/fgr
@@ -0,0 +1,82 @@
+#!/bin/sh
+
+# https://junegunn.github.io/fzf/tips/ripgrep-integration/#6-bind-enter-to-become-action
+
+help() { echo "fgr - grep with fzf (fzf-grep)
+
+USAGE:
+ fgr [OPTION]... PATTERN
+
+OPTIONS:
+ -r real time grepping with fzf prompt
+ -h show this help message
+
+ENVIRONMENT VARIABLES:
+ FZF_GREP_COMMAND overrides the default grep command whose content is piped into fzf
+ FZF_GREP_OPENER overrides the default opener used to open selection on pressing 'enter'
+ "; }
+
+err() { printf '%s: %s\n' "$0" "$@" >&2; exit 1; }
+
+while getopts 'rh' o; do case "$o" in
+ r) rflag=1 ;;
+ h) help >&2; exit ;;
+ ?) err "invalid option passed" ;;
+esac done
+shift $((OPTIND - 1))
+
+[ -z "$FZF_HISTDIR" ] &&
+ export FZF_HISTDIR="${XDG_STATE_HOME:-$HOME/.local/state}/fzf"
+
+mkdir -pv "$FZF_HISTDIR"
+export FZF_HIST="$FZF_HISTDIR/grep_history"
+
+[ -z "$FZF_GREP_COMMAND" ] &&
+ if command -v rg >/dev/null; then
+ FZF_GREP_COMMAND="rg --smart-case --column --color=always"
+ elif command -v git >/dev/null; then
+ FZF_GREP_COMMAND="git grep -I --ignore-case --column --color=always"
+ else
+ FZF_GREP_COMMAND="grep -Rnsi --exclude-dir=.git --color=always"
+ fi
+
+[ -z "$FZF_GREP_RELOAD" ] &&
+ FZF_GREP_RELOAD="reload($FZF_GREP_COMMAND {q} || :)"
+
+[ -z "$FZF_GREP_OPENER" ] && FZF_GREP_OPENER='
+ if [[ $FZF_SELECT_COUNT -eq 0 ]]; then
+ $EDITOR {1} +{2} # No selection. Open the current line in Vim.
+ else
+ $EDITOR +cw -q {+f} # Build quickfix list for the selected items.
+ fi
+ '
+
+FZF_OPENER="
+ # update history
+ sed -i '\\|^{q}$|d' \"$FZF_HIST\"
+ echo {q} >> \"$FZF_HIST\"
+
+ $FZF_GREP_OPENER
+ "
+
+query="$*"
+
+fzf() { $FZF_GREP_COMMAND "$query" | command fzf "$@" \
+ --ansi --multi --exit-0 --header-first \
+ --history="$FZF_HIST" \
+ --bind "enter:execute($FZF_OPENER)" \
+ --bind "ctrl-o:become($FZF_OPENER)" \
+ --bind 'ctrl-v:toggle-preview,ctrl-space:toggle-preview' \
+ --bind "ctrl-r:reload($FZF_GREP_COMMAND '$query')" \
+ --bind 'alt-a:select-all,alt-d:deselect-all,ctrl-/:toggle-preview' \
+ --delimiter : \
+ --preview 'bat --style=full --color=always --highlight-line {2} {1}' \
+ --preview-window '~4,+{2}+4/3,<80(up)'; }
+
+if [ "$rflag" = 1 ]; then
+ fzf --disabled --query "$query" \
+ --header "COMMAND: $FZF_GREP_COMMAND <prompt-query>" \
+ --bind "change:$FZF_GREP_RELOAD"
+else
+ fzf --header "COMMAND: $FZF_GREP_COMMAND '$query'"
+fi
diff --git a/.local/bin/frg b/.local/bin/frg
deleted file mode 100755
index 97f703a..0000000
--- a/.local/bin/frg
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/bin/sh
-
-# https://junegunn.github.io/fzf/tips/ripgrep-integration/#6-bind-enter-to-become-action
-
-help() { echo "frg - grep with fzf
-
-USAGE:
- fgrp [OPTION]... PATTERN
-
-OPTIONS:
- -r real time grepping in fzf prompt
- -h show this help message"; }
-
-err() { printf '%s: %s\n' "$0" "$@" >&2; exit 1; }
-
-while getopts 'rh' o; do case "$o" in
- r) rflag=1 ;;
- h) help >&2; exit ;;
- ?) err "invalid option passed" ;;
-esac done
-shift $((OPTIND - 1))
-
-[ -z "$FZF_HISTDIR" ] &&
- export FZF_HISTDIR="${XDG_STATE_HOME:-$HOME/.local/state}/fzf"
-mkdir -pv "$FZF_HISTDIR"
-export FZF_HIST="$FZF_HISTDIR/grep_history"
-
-if command -v rg >/dev/null; then
- GREP_CMD="rg --smart-case --column --color=always"
-elif command -v git >/dev/null; then
- GREP_CMD="git grep -I --ignore-case --column --color=always"
-else
- GREP_CMD="grep -Rnsi --exclude-dir=.git --color=always"
-fi
-
-RELOAD="reload($GREP_CMD {q} || :)"
-
-OPENER='
- # update history
- sed -i \\\|^{q}$\|d "$FZF_HIST"
- echo {q} >> "$FZF_HIST"
-
- if [[ $FZF_SELECT_COUNT -eq 0 ]]; then
- $EDITOR {1} +{2} # No selection. Open the current line in Vim.
- else
- $EDITOR +cw -q {+f} # Build quickfix list for the selected items.
- fi
- '
-
-query="$*"
-
-fzf() { $GREP_CMD "$query" | command fzf "$@" \
- --ansi --multi --header-first \
- --history="$FZF_HIST" \
- --bind "enter:execute($OPENER)" \
- --bind "ctrl-o:become($OPENER)" \
- --bind 'ctrl-v:toggle-preview,ctrl-space:toggle-preview' \
- --bind "ctrl-r:reload($GREP_CMD '$query')" \
- --bind 'alt-a:select-all,alt-d:deselect-all,ctrl-/:toggle-preview' \
- --delimiter : \
- --preview 'bat --style=full --color=always --highlight-line {2} {1}' \
- --preview-window '~4,+{2}+4/3,<80(up)'; }
-
-if [ "$rflag" = 1 ]; then
- fzf --disabled --query "$query" \
- --header "COMMAND: $GREP_CMD <prompt-query>" \
- --bind "change:$RELOAD"
-else
- fzf --header "COMMAND: $GREP_CMD '$query'"
-fi
diff --git a/.local/bin/shortcuts b/.local/bin/shortcuts
index af3fe5b..91790e6 100755
--- a/.local/bin/shortcuts
+++ b/.local/bin/shortcuts
@@ -17,12 +17,13 @@ eval "echo \"$(cat "$bmdirs")\"" |
awk -F'\t' "
!/^\s*#/ && !/^\s*$/ {
gsub(\"\\\s*#.*$\", \"\");
- printf(\"c%s='cd %s && ls -A' \\\\\n\",\$1,\$2) >> \"$shell_shortcuts\"
- printf(\"d%s=\42%s\42 \\\\\n\", \$1, \$2) >> \"$shell_env_shortcuts\"
- printf(\"hash -d d%s=%s\n\", \$1, \$2) >> \"$zsh_named_dirs\"
- printf(\"map c%s :cd %s\n\", \$1, \$2) >> \"$lf_shortcuts\"
- printf(\"cmap ;d%s %s\n\", \$1, \$2) >> \"$vim_shortcuts\"
- printf(\"imap ;d%s %s\n\", \$1, \$2) >> \"$vim_shortcuts\"
+ printf(\"C%s='cd %s && ls -A' \\\\\n\",\$1,\$2) >> \"$shell_shortcuts\"
+ printf(\"D%s='cd %s && ls -A' \\\\\n\",\$1,\$2) >> \"$shell_shortcuts\"
+ printf(\"D%s=\42%s\42 \\\\\n\", \$1, \$2) >> \"$shell_env_shortcuts\"
+ printf(\"hash -d D%s=%s\n\", \$1, \$2) >> \"$zsh_named_dirs\"
+ printf(\"map C%s :cd %s\n\", \$1, \$2) >> \"$lf_shortcuts\"
+ printf(\"cmap ;D%s %s\n\", \$1, \$2) >> \"$vim_shortcuts\"
+ printf(\"imap ;D%s %s\n\", \$1, \$2) >> \"$vim_shortcuts\"
}
"
@@ -30,11 +31,12 @@ eval "echo \"$(cat "$bmfiles")\"" |
awk -F'\t' "
!/^\s*#/ && !/^\s*$/ {
gsub(\"\\\s*#.*$\", \"\");
- printf(\"e%s='\$EDITOR %s' \\\\\n\",\$1,\$2) >> \"$shell_shortcuts\"
- printf(\"export f%s=\42%s\42 \\\\\n\", \$1, \$2) >> \"$shell_env_shortcuts\"
- printf(\"hash -d f%s=%s\n\", \$1, \$2) >> \"$zsh_named_dirs\"
+ printf(\"E%s='\$EDITOR %s' \\\\\n\",\$1,\$2) >> \"$shell_shortcuts\"
+ printf(\"F%s='\$EDITOR %s' \\\\\n\",\$1,\$2) >> \"$shell_shortcuts\"
+ printf(\"F%s=\42%s\42 \\\\\n\", \$1, \$2) >> \"$shell_env_shortcuts\"
+ printf(\"hash -d F%s=%s\n\", \$1, \$2) >> \"$zsh_named_dirs\"
printf(\"map E%s $\$EDITOR %s\n\", \$1, \$2) >> \"$lf_shortcuts\"
- printf(\"cmap ;f%s %s\n\", \$1, \$2) >> \"$vim_shortcuts\"
- printf(\"imap ;f%s %s\n\", \$1, \$2) >> \"$vim_shortcuts\"
+ printf(\"cmap ;F%s %s\n\", \$1, \$2) >> \"$vim_shortcuts\"
+ printf(\"imap ;F%s %s\n\", \$1, \$2) >> \"$vim_shortcuts\"
}
"
diff --git a/.local/bin/shorts/mailsyncd b/.local/bin/shorts/mailsyncd
index 4b51c45..fdc132f 100755
--- a/.local/bin/shorts/mailsyncd
+++ b/.local/bin/shorts/mailsyncd
@@ -2,5 +2,5 @@
while true; do
mailsync
- sleep 5m
+ sleep 10m
done
diff --git a/.local/bin/statusbar/i3weather b/.local/bin/statusbar/i3weather
index d008deb..c894be6 100755
--- a/.local/bin/statusbar/i3weather
+++ b/.local/bin/statusbar/i3weather
@@ -2,20 +2,30 @@
# weather module for i3blocks
# output is set to 'WEATHER UNAVAILABLE' in case wttr.in is unreachable
+WTTR_CACHE_DIR="/tmp"
+WTTR_CACHE="$WTTR_CACHE_DIR/wttr.in"
+WTTR_TXT="$WTTR_CACHE_DIR/wttr.txt"
+WTTR_LOCATION="Vasai"
+WTTR_URL="https://wttr.in/$WTTR_LOCATION"
+
case "$BLOCK_BUTTON" in
- '') ;;
+ '') true ;;
1)
- $TERMINAL -e less -r ~/.cache/weather.txt & sleep 0.3
- i3-msg 'move to workspace "12: Weather"; workspace "12: Weather"' >/dev/null 2>&1
+ [ -f "$WTTR_CACHE" ] || BLOCK_BUTTON=5 i3weather
+ sed 's,\x1B\[[0-9;]*[a-zA-z],,g' "$WTTR_CACHE" > "$WTTR_TXT"
+ st -c "dropdown_weather" \
+ -g "$(wc -L < "$WTTR_TXT")x38" \
+ -e less -r "$WTTR_CACHE" & sleep 0.3
;;
2) $TERMINAL -e nvim "$0" ;;
*) notify-send "⛅ Refreshing weather info..." ;;
esac
-HTTP_WEATHER="https://wttr.in/Vasai"
-# weather="$(curl -s "$HTTP_WEATHER?format=%c%C++❄️+%t++☀️+%f++🌬️+%w")"
-weather="$(curl -Ss "$HTTP_WEATHER?0&T&Q" | cut -c 16- | head -2 |
- xargs echo "$(curl -s "$HTTP_WEATHER?format=%c")")"
+case "$1" in
+ 1) weather="$(curl -s "$WTTR_URL?format=%c")$WTTR_LOCATION $(curl -Ss "$WTTR_URL?0&T&Q" | sed -E '2,3!d; s/.{16}(.{13}).*/\1/; s/ {4}$//' | tr -d '\n')" ;;
+ 2) weather="$(curl -s "$WTTR_URL?format=%c%C")" ;;
+ *) weather="$(curl -s "$WTTR_URL?format=%c") $(curl -Ss "$WTTR_URL?0&T&Q" | cut -c 16- | head -2)" ;;
+esac
if [ "$(echo "$weather" | grep -Ec "(Unknown|curl|HTML)")" -gt 0 ]; then
echo "WEATHER UNAVAILABLE"
@@ -23,5 +33,5 @@ else
echo "${weather:-⛅ -- }"
fi
-curl -s "$HTTP_WEATHER" > ~/.cache/weather.txt
+curl -s "$WTTR_URL" > "$WTTR_CACHE"
diff --git a/.local/bin/web/ytplaylist b/.local/bin/web/ytplaylist
deleted file mode 100755
index 7bc9026..0000000
--- a/.local/bin/web/ytplaylist
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/bin/sh
-
-# Useful when creating a directory of videos sequenced as per a youtube
-# playlist.
-# Run this script from from the root of a directory that contains all the media
-# and metadata files.
-# The playlist file is expected to be in 'playlist' directory within the root
-# with .pl.txt extension. (playlist/PLAYLIST_NAME.pl.txt)
-# The new playlist directory will be created in the current directory i.e. the
-# root if no other destination is passed as the second argument.
-
-case "$1" in
- '') echo "ytplaylist - build a directory of sequenced videos using a playlist file\n
-USAGE:\n\tytplaylist <PLAYLIST_FILE> [DESTINATION_DIR] " >&2; exit ;;
- playlist/*.pl.txt) ;;
- *)
- printf "%s" "Unconventional file path, contniue? [y/N] "
- read -r ans
- case "$ans" in y) ;; *) exit 1 ;; esac
- ;;
-esac
-
-playlist="$(readlink -f $1)"
-i=1
-fpl "$playlist" | while read -r file; do
- if [ -z "$file" ]; then
- i=$(( $i + 1 ))
- continue
- fi
- dir="$(dirname "$file")"
- base="$(basename "$file")"
- rsync -Pru --mkpath "$file" \
- "${2:-$(basename "${playlist%.pl.txt}")}/${dir#$(readlink -f "$PWD")}/$(printf "%02d" "$i") $base"
-done