From 7fb4781e28eaf2cb77fa772e860ede5b0912ed35 Mon Sep 17 00:00:00 2001 From: gotbletu Date: Mon, 15 Feb 2021 13:12:50 -0800 Subject: [PATCH] update any-term-dropdown, mountjutsu, fzf-nova --- any-term-dropdown | 39 + any_term_dropdown.sh | 45 - fzf_nova/_applauncher | 18 + fzf_nova/_bookmarks | 12 + fzf_nova/_bookmarks_private | 12 + fzf_nova/_calibre | 9 + fzf_nova/_chromium_history | 32 + fzf_nova/_cmus | 17 + fzf_nova/_cmus_next | 2 + fzf_nova/_cmus_playpause | 3 + fzf_nova/_cmus_prev | 2 + fzf_nova/_cmus_stop | 2 + fzf_nova/_emoji | 3779 +++++++++++++++++++++++++++++++++++ fzf_nova/_greenclip | 13 + fzf_nova/_locate | 17 + fzf_nova/_pipe_viewer | 3 + fzf_nova/_playonlinux | 12 + fzf_nova/_ranger_locate | 8 + fzf_nova/_redpill | 9 + fzf_nova/_snippet | 12 + fzf_nova/_snippet_multi | 13 + fzf_nova/_surfraw | 17 + fzf_nova/_surfraw_incognito | 19 + fzf_nova/fzf-nova | 17 + mountjutsu | 145 +- 25 files changed, 4206 insertions(+), 51 deletions(-) create mode 100755 any-term-dropdown delete mode 100755 any_term_dropdown.sh create mode 100755 fzf_nova/_applauncher create mode 100755 fzf_nova/_bookmarks create mode 100755 fzf_nova/_bookmarks_private create mode 100755 fzf_nova/_calibre create mode 100755 fzf_nova/_chromium_history create mode 100755 fzf_nova/_cmus create mode 100755 fzf_nova/_cmus_next create mode 100755 fzf_nova/_cmus_playpause create mode 100755 fzf_nova/_cmus_prev create mode 100755 fzf_nova/_cmus_stop create mode 100755 fzf_nova/_emoji create mode 100755 fzf_nova/_greenclip create mode 100755 fzf_nova/_locate create mode 100755 fzf_nova/_pipe_viewer create mode 100755 fzf_nova/_playonlinux create mode 100755 fzf_nova/_ranger_locate create mode 100755 fzf_nova/_redpill create mode 100755 fzf_nova/_snippet create mode 100755 fzf_nova/_snippet_multi create mode 100755 fzf_nova/_surfraw create mode 100755 fzf_nova/_surfraw_incognito create mode 100755 fzf_nova/fzf-nova diff --git a/any-term-dropdown b/any-term-dropdown new file mode 100755 index 0000000..8db6365 --- /dev/null +++ b/any-term-dropdown @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +# AUTHOR: gotbletu (@gmail|twitter|youtube|github|lbry) +# https://www.youtube.com/user/gotbletu +# DESC: turn any terminal into a dropdown terminal +# DEMO: https://www.youtube.com/watch?v=mVw2gD9iiOg +# DEPEND: coreutils xdotool wmutils (https://github.com/wmutils/core | https://aur.archlinux.org/packages/wmutils-git/) +# CLOG: 2021-02-10 use comm to match window name and class, this avoids terminal windows with different names +# 2015-02-15 0.1 + +# get screen resolution width and height +ROOT=$(lsw -r) +width=$(wattr w "$ROOT") +height=$(wattr h "$ROOT") + +# option 1: set terminal emulator manually +# my_term=urxvt +# my_term=sakura +my_term="xterm" +# my_term="alacritty" +# my_term=terminator +# my_term=gnome-terminal + +# option 2: auto detect terminal emulator (note: make sure to only open one) +# my_term="urxvt|xterm|uxterm|termite|sakura|lxterminal|terminator|mate-terminal|pantheon-terminal|konsole|gnome-terminal|xfce4-terminal" + +# get terminal emulator pid ex: 44040485 +# pid=$(xdotool search --class "$my_term" | tail -n1) + +# get terminal emulator and matching name pid ex: 44040485 +pid=$(comm -12 <(xdotool search --name "$my_term" | sort) <(xdotool search --class "$my_term" | sort)) + +# get windows id from pid ex: 0x2a00125% +wid=$(printf 0x%x "$pid") + +# maximize terminal emulator +wrs "$width" "$height" "$wid" + +# toggle show/hide terminal emulator +mapw -t "$wid" diff --git a/any_term_dropdown.sh b/any_term_dropdown.sh deleted file mode 100755 index 20301c4..0000000 --- a/any_term_dropdown.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash -# any_term_dropdown.sh - turns any terminal into a dropdown terminal -# tutorial video: https://www.youtube.com/watch?v=mVw2gD9iiOg -# License GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt -# _ _ _ _ -# __ _ ___ | |_| |__ | | ___| |_ _ _ -# / _` |/ _ \| __| '_ \| |/ _ \ __| | | | -#| (_| | (_) | |_| |_) | | __/ |_| |_| | -# \__, |\___/ \__|_.__/|_|\___|\__|\__,_| -# |___/ -# http://www.youtube.com/user/gotbletu -# https://twitter.com/gotbletu -# https://github.com/gotbletu - -# requires: -# xdotool -# wmutils https://github.com/wmutils/core -# https://aur.archlinux.org/packages/wmutils-git/ - -# get screen resolution width and height -ROOT=$(lsw -r) -width=$(wattr w $ROOT) -height=$(wattr h $ROOT) - -# option 1: set terminal emulator manually -# my_term=urxvt -# my_term=xterm -# my_term=terminator -# my_term=gnome-terminal - -# option 2: auto detect terminal emulator (note: make sure to only open one) -my_term="urxvt|xterm|uxterm|termite|sakura|lxterminal|terminator|mate-terminal|pantheon-terminal|konsole|gnome-terminal|xfce4-terminal" - -# get terminal emulator pid ex: 44040485 -pid=$(xdotool search --class "$my_term" | tail -n1) - -# get windows id from pid ex: 0x2a00125% -wid=$(printf 0x%x "$pid") - -# maximize terminal emulator -wrs "$width" "$height" "$wid" - -# toggle show/hide terminal emulator -mapw -t "$wid" - diff --git a/fzf_nova/_applauncher b/fzf_nova/_applauncher new file mode 100755 index 0000000..f072e19 --- /dev/null +++ b/fzf_nova/_applauncher @@ -0,0 +1,18 @@ +#!/usr/bin/env sh +# AUTHOR: gotbletu (@gmail|twitter|youtube|github|lbry) +# https://www.youtube.com/user/gotbletu +# DESC: launch app(s) with fzf like dmenu/rofi +# DEPEND: fzf sed coreutils findutils xdg-utils util-linux + +desktop_file() { + find /usr/share/applications -name "*.desktop" 2>/dev/null \ + && find /usr/local/share/applications -name "*.desktop" 2>/dev/null \ + && find "$HOME/.local/share/applications" -name "*.desktop" 2>/dev/null \ + && find /var/lib/flatpak/exports/share/applications -name "*.desktop" 2>/dev/null \ + && find "$HOME/.local/share/flatpak/exports/share/applications" -name "*.desktop" 2>/dev/null +} + +selected="$(desktop_file | sed 's/.desktop//g' | sort | fzf -e -i -m --reverse --delimiter / --with-nth -1)" +[ -z "$selected" ] && exit +cd || return +echo "$selected" | while read -r line ; do setsid xdg-open "$line".desktop ; done diff --git a/fzf_nova/_bookmarks b/fzf_nova/_bookmarks new file mode 100755 index 0000000..b583fde --- /dev/null +++ b/fzf_nova/_bookmarks @@ -0,0 +1,12 @@ +#!/usr/bin/env sh +# AUTHOR: gotbletu (@gmail|twitter|youtube|github|lbry) +# https://www.youtube.com/user/gotbletu +# DESC: open surfraw bookmarks with your deafult web browser ($BROWSER) +# DEPEND: fzf surfraw grep gawk coreutils +# REQD: make sure to set your browser variable in your shellrc +# vim ~/.bashrc +# export BROWSER=chromium + +selected="$(grep -E '^([[:alnum:]])' ~/.config/surfraw/bookmarks | sort -n | fzf -e -i -m --reverse | awk '{print $1}')" +[ -z "$selected" ] && exit +echo "$selected" | while read -r line ; do surfraw -browser="$BROWSER" "$line" ; done diff --git a/fzf_nova/_bookmarks_private b/fzf_nova/_bookmarks_private new file mode 100755 index 0000000..e362712 --- /dev/null +++ b/fzf_nova/_bookmarks_private @@ -0,0 +1,12 @@ +#!/usr/bin/env sh +# AUTHOR: gotbletu (@gmail|twitter|youtube|github|lbry) +# https://www.youtube.com/user/gotbletu +# DESC: open surfraw bookmarks with your deafult web browser private mode ($BROWSER_PRIVATE) +# DEPEND: fzf surfraw grep gawk coreutils util-linux +# REQD: make sure to set your private browser variable in your shellrc +# $EDITOR ~/.bashrc +# export BROWSER_PRIVATE="chromium --incognito" + +selected="$(grep -E '^([[:alnum:]])' ~/.config/surfraw/bookmarks | sort -n | fzf -e -i -m --reverse | awk '{print $1}')" +[ -z "$selected" ] && exit +echo "$selected" | while read -r line ; do URL="$(surfraw -p "$line")" && setsid -f $BROWSER_PRIVATE "$URL" ; done diff --git a/fzf_nova/_calibre b/fzf_nova/_calibre new file mode 100755 index 0000000..89974be --- /dev/null +++ b/fzf_nova/_calibre @@ -0,0 +1,9 @@ +#!/usr/bin/env sh +# AUTHOR: gotbletu (@gmail|twitter|youtube|github|lbry) +# https://www.youtube.com/user/gotbletu +# DESC: open only calibre ebooks +# DEPEND: fzf mlocate xdg-utils util-linux + +selected="$(locate -ir 'calibre.*\.\(cbz\|cbr\|epub\|pdf\|mobi\|azw3\)$' | fzf -e -i -m --reverse --delimiter / --with-nth -4,-3,-2,-1)" +[ -z "$selected" ] && exit +echo "$selected" | while read -r line ; do setsid xdg-open "$line" ; done diff --git a/fzf_nova/_chromium_history b/fzf_nova/_chromium_history new file mode 100755 index 0000000..e784b0a --- /dev/null +++ b/fzf_nova/_chromium_history @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +# AUTHOR: Junegunn Choi (https://github.com/junegunn) +# DESC: open chromium web history +# DEPEND: fzf chromium +# REFF: https://junegunn.kr/2015/04/browsing-chrome-history-with-fzf/ +# https://github.com/junegunn/fzf/wiki/examples#browsing-history + + +local cols sep +cols=$(( COLUMNS / 3 )) +sep='{::}' + +# MacOS +# \cp -f ~/Library/Application\ Support/Google/Chrome/Default/History /tmp/h + +# Linux +\cp -f ~/.config/chromium/Default/History /tmp/h + +sqlite3 -separator $sep /tmp/h \ + "select substr(title, 1, $cols), url + from urls order by last_visit_time desc" | +awk -F $sep '{printf "%-'$cols's \x1b[36m%s\x1b[m\n", $1, $2}' | +fzf --ansi --multi --reverse | sed 's#.*\(https*://\)#\1#' | xargs setsid xdg-open + +# MacOS +# fzf --ansi --multi | sed 's#.*\(https*://\)#\1#' | xargs open + +# selected="$(grep -E '^([[:alnum:]])' ~/.config/surfraw/bookmarks | sort -n | fzf -e -i -m | awk '{print $1}')" +# [ -z "$selected" ] && exit +# echo "$selected" | tr ' ' '\n' | while read -r line ; do surfraw -browser="$BROWSER" "$line" ; done + + diff --git a/fzf_nova/_cmus b/fzf_nova/_cmus new file mode 100755 index 0000000..dc14bdb --- /dev/null +++ b/fzf_nova/_cmus @@ -0,0 +1,17 @@ +#!/usr/bin/env sh +# AUTHOR: gotbletu (@gmail|twitter|youtube|github|lbry) +# https://www.youtube.com/user/gotbletu +# DESC: fuzzy find a song in cmus library and play +# DEPEND: fzf cmus coreutils + +selected="$( sort ~/.cmus/lib.pl | fzf -e -i +s -m --reverse --delimiter / --with-nth -2,-1 )" +[ -z "$selected" ] && exit + +# clear cmus queue +cmus-remote -c -q + +# add songs +echo "$selected" | while read -r line ; do cmus-remote -q "$line" ; done + +# play queued song +cmus-remote -n -p diff --git a/fzf_nova/_cmus_next b/fzf_nova/_cmus_next new file mode 100755 index 0000000..21720c8 --- /dev/null +++ b/fzf_nova/_cmus_next @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +cmus-remote --next diff --git a/fzf_nova/_cmus_playpause b/fzf_nova/_cmus_playpause new file mode 100755 index 0000000..cffcb85 --- /dev/null +++ b/fzf_nova/_cmus_playpause @@ -0,0 +1,3 @@ +#!/usr/bin/env sh +# toggle pause/play +cmus-remote --pause diff --git a/fzf_nova/_cmus_prev b/fzf_nova/_cmus_prev new file mode 100755 index 0000000..f7011aa --- /dev/null +++ b/fzf_nova/_cmus_prev @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +cmus-remote --prev diff --git a/fzf_nova/_cmus_stop b/fzf_nova/_cmus_stop new file mode 100755 index 0000000..6b77cbb --- /dev/null +++ b/fzf_nova/_cmus_stop @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +cmus-remote --stop diff --git a/fzf_nova/_emoji b/fzf_nova/_emoji new file mode 100755 index 0000000..02527cc --- /dev/null +++ b/fzf_nova/_emoji @@ -0,0 +1,3779 @@ +#!/usr/bin/env bash +# AUTHOR: gotbletu (@gmail|twitter|youtube|github|lbry) +# https://www.youtube.com/user/gotbletu +# DESC: copy emoji to clipboard +# DEPEND: fzf grep gawk coreutils xsel (or tmux) +# REFF: https://github.com/porras/dmenu-emoji/blob/master/dmenu-emoji.sh + +emoji_list() { +cat </dev/null 2>&1 & disown +# setsid playonlinux --run "$selected" >/dev/null 2>&1 & disown +setsid playonlinux --run "$selected" >/dev/null & disown diff --git a/fzf_nova/_ranger_locate b/fzf_nova/_ranger_locate new file mode 100755 index 0000000..e50b45d --- /dev/null +++ b/fzf_nova/_ranger_locate @@ -0,0 +1,8 @@ +#!/bin/bash +# AUTHOR: gotbletu (@gmail|twitter|youtube|github|lbry) +# https://www.youtube.com/user/gotbletu +# DESC: locate a file and go to that directory with ranger file manager +# DEMO: https://www.youtube.com/watch?v=C64LKCZFzME +# DEPEND: ranger locate + +ranger --cmd=fzf_locate diff --git a/fzf_nova/_redpill b/fzf_nova/_redpill new file mode 100755 index 0000000..7a3626b --- /dev/null +++ b/fzf_nova/_redpill @@ -0,0 +1,9 @@ +#!/usr/bin/env sh +# AUTHOR: gotbletu (@gmail|twitter|youtube|github|lbry) +# https://www.youtube.com/user/gotbletu +# DESC: open a cheatsheet to read notes +# DEPEND: fzf findutils coreutils + +selected="$(find ~/.config/redpill/ -type f | sort | fzf -e -i --reverse --delimiter / --with-nth -1 --preview 'cat {}')" +[ -z "$selected" ] && exit +"$EDITOR" "$selected" diff --git a/fzf_nova/_snippet b/fzf_nova/_snippet new file mode 100755 index 0000000..3d5e05e --- /dev/null +++ b/fzf_nova/_snippet @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +# AUTHOR: gotbletu (@gmail|twitter|youtube|github|lbry) +# https://www.youtube.com/user/gotbletu +# DESC: copy text snippet to clipboard +# DEMO: https://www.youtube.com/watch?v=Zew0mgJwAh8 +# DEPEND: fzf sed coreutils xsel (or tmux) + +# sort, delete empty line, remove tags, leading and trailing spaces, also no newline +selected="$(sort -n ~/.snippetrc | sed '/^$/d' | fzf -e -i --reverse | sed -e s/\;\;\.\*\$// | sed 's/^[ \t]*//;s/[ \t]*$//' | tr -d '\n')" +[ -z "$selected" ] && exit +printf "%s" "$selected" | xsel -b +printf "%s" "$selected" | tmux load-buffer - diff --git a/fzf_nova/_snippet_multi b/fzf_nova/_snippet_multi new file mode 100755 index 0000000..39e4ba4 --- /dev/null +++ b/fzf_nova/_snippet_multi @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +# AUTHOR: gotbletu (@gmail|twitter|youtube|github|lbry) +# https://www.youtube.com/user/gotbletu +# DESC: copy textblock to clipboard +# DEMO: https://www.youtube.com/watch?v=Zew0mgJwAh8 +# DEPEND: fzf sed coreutils findutils (xsel or tmux) + +selected="$(find ~/.multisnippet/ -type f | sort | fzf -e -i --reverse --delimiter / --with-nth -1 --preview 'cat {}')" +[ -z "$selected" ] && exit + +# add to tmux and X11 clipboard +xsel -b < "$selected" +tmux load-buffer "$selected" diff --git a/fzf_nova/_surfraw b/fzf_nova/_surfraw new file mode 100755 index 0000000..1fbbc49 --- /dev/null +++ b/fzf_nova/_surfraw @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# AUTHOR: gotbletu (@gmail|twitter|youtube|github|lbry) +# https://www.youtube.com/user/gotbletu +# DESC: search internet from a list of search engines +# DEPEND: fzf surfraw grep gawk coreutils util-linux +# REQD: make sure to set your browser variable in your shellrc +# vim ~/.bashrc +# export BROWSER=chromium + +# select your elvi +PREFIX=$(surfraw -elvi | grep -v 'LOCAL\|GLOBAL'| fzf -e -m --reverse | awk '{print $1}') +[ -z "$PREFIX" ] && exit +echo "Search Engine(s): $PREFIX" | tr '\n' ' ' +echo +read -r -e -p "Enter Keywords: " INPUT +# Note: dont qoute $INPUT it will mess up results +echo "$PREFIX" | while read -r line; do setsid -f surfraw -browser="$BROWSER" "$line" $INPUT ; done diff --git a/fzf_nova/_surfraw_incognito b/fzf_nova/_surfraw_incognito new file mode 100755 index 0000000..1930e48 --- /dev/null +++ b/fzf_nova/_surfraw_incognito @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# AUTHOR: gotbletu (@gmail|twitter|youtube|github|lbry) +# https://www.youtube.com/user/gotbletu +# DESC: search internet from a list of search engines (private/incognito mode) +# DEPEND: fzf surfraw grep gawk coreutils util-linux +# REQD: make sure to set your private browser variable in your shellrc +# vim ~/.bashrc +# export BROWSER_PRIVATE="chromium --incognito" + +# select your elvi +PREFIX=$(surfraw -elvi | grep -v 'LOCAL\|GLOBAL'| fzf -e -m --reverse | awk '{print $1}') +[ -z "$PREFIX" ] && exit +echo "Search Engine(s): $PREFIX" | tr '\n' ' ' +echo +read -r -e -p "[Private Mode] Enter Keywords: " INPUT + +# workaround: surfraw does not like multiple flags in -browser option +# e.g surfraw -browser="chromium --incognito" "$PREFIX" $INPUT +echo "$PREFIX" | while read -r line; do URL="$(surfraw -p "$line" $INPUT)" && setsid -f $BROWSER_PRIVATE "$URL" ; done diff --git a/fzf_nova/fzf-nova b/fzf_nova/fzf-nova new file mode 100755 index 0000000..ccc0062 --- /dev/null +++ b/fzf_nova/fzf-nova @@ -0,0 +1,17 @@ +#!/usr/bin/env sh +# AUTHOR: gotbletu (@gmail|twitter|youtube|github|lbry) +# https://www.youtube.com/user/gotbletu +# DESC: launch other fzf scripts +# DEMO: https://youtu.be/8SqakfCSzQk +# DEPEND: fzf grep findutils coreutils +# REFF: Xterm config https://www.youtube.com/watch?v=mAUQsNUnk9I + +# Hotkey Binding Examples ~/.xbindkeysrc +# "xterm -T fzf-nova -geometry 90x25+350+200 -fs 16 -e /path/to/script/fzf-nova" +# Mod4+space +# +# "alacritty -t fzf-nova --dimensions 90 20 --position 350 200 -e /path/to/script/fzf-nova" +# Mod4+space + +DIR="${0%/*}" +"$DIR"/"$(find "$DIR" -type f -exec basename {} \; | grep '^_' | sort | fzf -e -i --delimiter _ --with-nth='2..' --reverse --prompt="fzf-nova: ")" diff --git a/mountjutsu b/mountjutsu index b6acb99..4bcb774 100755 --- a/mountjutsu +++ b/mountjutsu @@ -16,11 +16,20 @@ ### Date : 20190626 ### Description : menu interface to mount, unmount, eject, clone, exactcopy, format, LUKS encryption ### Depends On : bash sudo grep gawk coreutils udisks2 util-linux -### gptfdisk dosfstools ntfs-3g hfsprogs exfat-utils e2fsprogs +### gptfdisk dosfstools ntfs-3g hfsprogs exfatprogs e2fsprogs ### cryptsetup clonezilla partclone partimage vlc cdw f3 smartmontools ### dvdbackup libdvdread libdvdcss cdrdao cdrtools(or cdrkit) ### Video Demo : https://www.youtube.com/watch?v=jipILuNW5Ks +### 2021-01-16 : change to exfatprogs, exFAT 32KB or 64KB cluster + +# Next improvements: 1) delete MBR on format https://www.cyberciti.biz/faq/linux-clearing-out-master-boot-record-dd-command/ +# clear out leftover label and fstype +# $ sudo dd if=/dev/zero of=/dev/sdX bs=446 count=1 + +# 2) blinking text warning + + #-------- Bash Color Code {{{ #------------------------------------------------------ # DESC: color code for bash compatible shell @@ -399,6 +408,112 @@ format2usb-exfat() { rmdir -v /tmp/testmount } +format2usb-exfat-32kbcluster() { + if [ $# -lt 2 ]; then + echo -e "format and create a partition that fills up the whole device" + echo -e "exFAT label max is 15 character and is all uppercase" + echo -e "\nUsage: $0