diff options
Diffstat (limited to 'home-manager/config/lf/cmds')
22 files changed, 399 insertions, 0 deletions
diff --git a/home-manager/config/lf/cmds/archive.sh b/home-manager/config/lf/cmds/archive.sh new file mode 100644 index 00000000..48544365 --- /dev/null +++ b/home-manager/config/lf/cmds/archive.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# shellcheck disable=SC2086 +# shellcheck source=/home/dt/.local/lib/shell/lib +. ~/.local/lib/shell/lib + + +# Option '-f' disables pathname expansion which can be useful when $f, $fs, and +# $fx variables contain names with '*' or '?' characters. However, this option +# is used selectively within individual commands as it can be limiting at +# times. +set -f + +fx="$*" + +archivers=$(mktmp) +echo "tar+zip tar+xz 7z zip" > $archivers; + +readp "File Name: " name + + +case $(awk '{for (i=1; i<=NF; i++) print $i}' $archivers | fzf) in + "tar+zip") + tar -czf "$name".tar.gz "$name" + ;; + "tar+xz") + tar -cf "$name".tar $fx + xz -z -9 -e -T0 "$name".tar + ;; + "7z") + 7z a "$name".7z $fx + ;; + "zip") + zip -r "$name".zip $fx + ;; +esac + + + + +if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/config/lf/cmds/broot_jump.sh b/home-manager/config/lf/cmds/broot_jump.sh new file mode 100644 index 00000000..188c9508 --- /dev/null +++ b/home-manager/config/lf/cmds/broot_jump.sh @@ -0,0 +1,19 @@ +#!/bin/sh +# shellcheck disable=SC2086 +# shellcheck source=/dev/null +. ~/.local/lib/shell/lib + +f=$(mktemp) +res="$(broot --outcmd $f && cat $f | sed 's/cd //')" +rm -f "$f" +if [ -f "$res" ]; then + cmd="select" +elif [ -d "$res" ]; then + cmd="cd" +fi +lf -remote "send $id $cmd \"$res\"" + + + + +if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/config/lf/cmds/chmod.sh b/home-manager/config/lf/cmds/chmod.sh new file mode 100644 index 00000000..f6a87336 --- /dev/null +++ b/home-manager/config/lf/cmds/chmod.sh @@ -0,0 +1,17 @@ +#!/bin/sh +# shellcheck disable=SC2086 +# shellcheck source=/dev/null +. ~/.local/lib/shell/lib + + +readp "Mode Bits: " ans + +for file in $fx +do + chmod "$ans" "$file" +done + +lf -remote 'send reload' + + +if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/config/lf/cmds/clear_trash.sh b/home-manager/config/lf/cmds/clear_trash.sh new file mode 100644 index 00000000..c02321f2 --- /dev/null +++ b/home-manager/config/lf/cmds/clear_trash.sh @@ -0,0 +1,10 @@ +#!/bin/sh +# shellcheck disable=SC2086 +# shellcheck source=/dev/null +. ~/.local/lib/shell/lib + + +trash-empty + + +if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/config/lf/cmds/dl_file.sh b/home-manager/config/lf/cmds/dl_file.sh new file mode 100644 index 00000000..9cb9023c --- /dev/null +++ b/home-manager/config/lf/cmds/dl_file.sh @@ -0,0 +1,36 @@ +#!/bin/sh +# shellcheck disable=SC2086 +# shellcheck source=/dev/null +. ~/.local/lib/shell/lib + +# Provides the ability to download a file by dropping it into a window + +url=$(dragon-drop -t -x) + +if [ -n "$url" ]; then + printf "File Name: " + name="" + while [ -z $name ] || [ -e $name ] + do + read -r name + if [ -e "$name" ]; then + printf "File already exists, overwrite (y|n): " + read -r ans + + if [ "$ans" = "y" ]; then + break + else + printf "File Name: " + fi + fi + done + + # Download the file with curl + [ -n "$name" ] && curl -o "$name" "$url" || exit 1 +else + exit 1 +fi + + + +if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/config/lf/cmds/dragon.sh b/home-manager/config/lf/cmds/dragon.sh new file mode 100644 index 00000000..36e94706 --- /dev/null +++ b/home-manager/config/lf/cmds/dragon.sh @@ -0,0 +1,11 @@ +#!/bin/sh +# shellcheck disable=SC2086 +# shellcheck source=/dev/null +. ~/.local/lib/shell/lib + +dragon-drop -a -x "$fx" + + + + +if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/config/lf/cmds/dragon_individual.sh b/home-manager/config/lf/cmds/dragon_individual.sh new file mode 100644 index 00000000..abcadb13 --- /dev/null +++ b/home-manager/config/lf/cmds/dragon_individual.sh @@ -0,0 +1,10 @@ +#!/bin/sh +# shellcheck disable=SC2086 +# shellcheck source=/dev/null +. ~/.local/lib/shell/lib + +dragon-drop "$fx" + + + +if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/config/lf/cmds/dragon_stay.sh b/home-manager/config/lf/cmds/dragon_stay.sh new file mode 100644 index 00000000..60195d09 --- /dev/null +++ b/home-manager/config/lf/cmds/dragon_stay.sh @@ -0,0 +1,11 @@ +#!/bin/sh +# shellcheck disable=SC2086 +# shellcheck source=/dev/null +. ~/.local/lib/shell/lib + +dragon-drop -a "$fx" + + + + +if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/config/lf/cmds/fzf_jump.sh b/home-manager/config/lf/cmds/fzf_jump.sh new file mode 100644 index 00000000..688efdb9 --- /dev/null +++ b/home-manager/config/lf/cmds/fzf_jump.sh @@ -0,0 +1,17 @@ +#!/bin/sh +# shellcheck disable=SC2086 +# shellcheck source=/dev/null +. ~/.local/lib/shell/lib + +res="$(find . -maxdepth 3 | fzf --reverse --header='Jump to location')" +if [ -f "$res" ]; then + cmd="select" +elif [ -d "$res" ]; then + cmd="cd" +fi +lf -remote "send $id $cmd \"$res\"" + + + + +if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/config/lf/cmds/help.sh b/home-manager/config/lf/cmds/help.sh new file mode 100644 index 00000000..8fedd0ea --- /dev/null +++ b/home-manager/config/lf/cmds/help.sh @@ -0,0 +1,10 @@ +#!/bin/sh +# shellcheck disable=SC2086 +# shellcheck source=/dev/null +. ~/.local/lib/shell/lib + + +cat ~/.config/lf/lfrc + + +if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/config/lf/cmds/mk_dir.sh b/home-manager/config/lf/cmds/mk_dir.sh new file mode 100644 index 00000000..bfa0627d --- /dev/null +++ b/home-manager/config/lf/cmds/mk_dir.sh @@ -0,0 +1,12 @@ +#!/bin/sh +# shellcheck disable=SC2086 +# shellcheck source=/dev/null +. ~/.local/lib/shell/lib + + +readp "Directory Name: " ans +mkdir $ans + + + +if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/config/lf/cmds/mk_file.sh b/home-manager/config/lf/cmds/mk_file.sh new file mode 100644 index 00000000..044016a6 --- /dev/null +++ b/home-manager/config/lf/cmds/mk_file.sh @@ -0,0 +1,11 @@ +#!/bin/sh +# shellcheck disable=SC2086 +# shellcheck source=/dev/null +. ~/.local/lib/shell/lib + + +readp "File Name: " name +$EDITOR "$name" + + +if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/config/lf/cmds/mk_ln.sh b/home-manager/config/lf/cmds/mk_ln.sh new file mode 100644 index 00000000..71a70a36 --- /dev/null +++ b/home-manager/config/lf/cmds/mk_ln.sh @@ -0,0 +1,43 @@ +#!/bin/sh +# shellcheck disable=SC2086 +# shellcheck source=/dev/null +. ~/.local/lib/shell/lib + +while IFS= read -r i;do + set -- "$@" "$i" +done < "$(tmp "cat ~/.local/share/lf/files")" + +mode="$1" +shift + +if [ "$#" -lt 1 ]; then + msg "no files to link" + exit 0 +fi + + +case "$mode" in + copy) + while [ "$#" -gt 0 ]; do + file=$1 + ans="$(basename "$file")" + + while ls -a "$(pwd)" | grep --word-regexp "$ans" > /dev/null;do + printf "\"%s\" already exists, new name for link: " "$ans" + read -r ans + done + + ln -s "$file" "$(pwd)/$ans" + + + shift + done + ;; +esac +rm ~/.local/share/lf/files +# lf -remote "send clear" + + + + +if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/config/lf/cmds/mk_scr.sh b/home-manager/config/lf/cmds/mk_scr.sh new file mode 100644 index 00000000..b6c17458 --- /dev/null +++ b/home-manager/config/lf/cmds/mk_scr.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# shellcheck disable=SC2086 +# shellcheck source=/dev/null +. ~/.local/lib/shell/lib + +star=$(mktmp) +cat << EOF > $star +#!/bin/sh +# shellcheck disable=SC2086 +# shellcheck source=/dev/null +. ~/.local/lib/shell/lib + + + + + +if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi +EOF + +readp "Script Name: " script_name +scr="$(pwd)"/"$script_name" + +[ -e $scr ] && die "$script_name exitst, exiting.." + +cat "$star" > $scr +chmod +x $scr +if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi + +$VISUAL $scr diff --git a/home-manager/config/lf/cmds/open.sh b/home-manager/config/lf/cmds/open.sh new file mode 100644 index 00000000..8376be21 --- /dev/null +++ b/home-manager/config/lf/cmds/open.sh @@ -0,0 +1,16 @@ +#!/bin/sh +# shellcheck disable=SC2086 +# shellcheck source=/dev/null +. ~/.local/lib/shell/lib + + +case $(file --mime-type "$f" -bL) in + text/*|application/json) $EDITOR "$f";; + image/*) $IVIEWER "$f";; + *) xdg-open "$f" ;; +esac + + + + +if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/config/lf/cmds/open_config.sh b/home-manager/config/lf/cmds/open_config.sh new file mode 100644 index 00000000..93c174d7 --- /dev/null +++ b/home-manager/config/lf/cmds/open_config.sh @@ -0,0 +1,10 @@ +#!/bin/sh +# shellcheck disable=SC2086 +# shellcheck source=/dev/null +. ~/.local/lib/shell/lib + +$EDITOR "$(bookmenu -b ~/.config/bookmenu/configs -f fzf -o)" + + + +if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/config/lf/cmds/restore_trash.sh b/home-manager/config/lf/cmds/restore_trash.sh new file mode 100644 index 00000000..432e9e9b --- /dev/null +++ b/home-manager/config/lf/cmds/restore_trash.sh @@ -0,0 +1,10 @@ +#!/bin/sh +# shellcheck disable=SC2086 +# shellcheck source=/dev/null +. ~/.local/lib/shell/lib + + +trash-restore + + +if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/config/lf/cmds/set_wall_paper.sh b/home-manager/config/lf/cmds/set_wall_paper.sh new file mode 100644 index 00000000..4599de2a --- /dev/null +++ b/home-manager/config/lf/cmds/set_wall_paper.sh @@ -0,0 +1,15 @@ +#!/bin/sh +# shellcheck disable=SC2086 +# shellcheck source=/dev/null +. ~/.local/lib/shell/lib + + +die "No yet implemented" +#sed -i "s,export AWMWALLPAPER='.*',export AWMWALLPAPER='${f}'," ${ZDOTDIR}/.zshenv +#swaybg -i "$f" & +#feh --bg-max --no-fehbg "$f" + + + + +if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/config/lf/cmds/stripspace.sh b/home-manager/config/lf/cmds/stripspace.sh new file mode 100644 index 00000000..c7f68767 --- /dev/null +++ b/home-manager/config/lf/cmds/stripspace.sh @@ -0,0 +1,10 @@ +#!/bin/sh +# shellcheck disable=SC2086 +# shellcheck source=/dev/null +. ~/.local/lib/shell/lib + + +stripspace "$f" + + +if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/config/lf/cmds/sudo_mk_file.sh b/home-manager/config/lf/cmds/sudo_mk_file.sh new file mode 100644 index 00000000..1f06a92f --- /dev/null +++ b/home-manager/config/lf/cmds/sudo_mk_file.sh @@ -0,0 +1,13 @@ +#!/bin/sh +# shellcheck disable=SC2086 +# shellcheck source=/dev/null +. ~/.local/lib/shell/lib + + +readp "File Name: " ans +sudo $EDITOR "$ans" + + + + +if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/config/lf/cmds/trash.sh b/home-manager/config/lf/cmds/trash.sh new file mode 100644 index 00000000..4598b4fd --- /dev/null +++ b/home-manager/config/lf/cmds/trash.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# shellcheck disable=SC2086 +# shellcheck source=/dev/null +. ~/.local/lib/shell/lib + +files=$(printf "$fx" | tr '\n' ';') + +while [ "$files" ]; do + # extract the substring from start of string up to delimiter. + # this is the first "element" of the string. + file=${files%%;*} + + trash-put "$(basename "$file")" + # if there's only one element left, set `files` to an empty string. + # this causes us to exit this `while` loop. + # else, we delete the first "element" of the string from files, and move onto the next. + if [ "$files" = "$file" ]; then + files='' + else + files="${files#*;}" + fi +done + + + + +if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/config/lf/cmds/unarchive.sh b/home-manager/config/lf/cmds/unarchive.sh new file mode 100644 index 00000000..47a713fa --- /dev/null +++ b/home-manager/config/lf/cmds/unarchive.sh @@ -0,0 +1,22 @@ +#!/bin/sh +# shellcheck disable=SC2086 +# shellcheck source=/dev/null +. ~/.local/lib/shell/lib + + +# extract the current file with the right command +# (xkcd link: https://xkcd.com/1168/) +set -f +case "$f" in + *.tar.bz|*.tar.bz2|*.tbz|*.tbz2) tar xjvf $f;; + *.tar.gz|*.tgz) tar xzvf $f;; + *.tar.xz|*.txz) tar xJvf $f;; + *.zip) unzip $f;; + *.rar) unrar x $f;; + *.7z) 7z x $f;; + *) warning "Unsupported format" ;; +esac + + + +if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi |