diff --git a/LICENSE b/LICENSE old mode 100755 new mode 100644 diff --git a/README.md b/README.md old mode 100755 new mode 100644 index c19494c..450c3e3 --- a/README.md +++ b/README.md @@ -1,19 +1,31 @@ ----*This project is still under heavy development!*--- Please do not delete this file, as it is used to display help information. # L A C K A D A I S I C A L -A collection of easy-to-understand, easy-to-use scripts, functions and aliases. Designed to be beginner-friendly but also useful! +A collection of easy-to-understand, easy-to-use scripts, functions and aliases. +Designed to be beginner-friendly but also useful! Contains several tools you 0ccould ## Disclaimer -Some aspects of this project were generated by Google Gemini (in particular, daisy_help and daisy_liist). While we are generally against using LLMs for code, the added functionality of being able to get information for individual tools is useful and not considered to be vital functionality. +Some aspects of this project were generated by Google Gemini (in particular, +daisy_help and daisy_liist). While we are generally against using LLMs for +code, the added functionality of being able to easily update information for +individual tools is useful and not considered to be vital functionality. ## How to use -Simply open your shell's RC-file (.bashrc, .zshrc, etc) and include `source /daisy.source`, preferably at the bottom of the file. We recommend setting your editor before sourcing `lackadaisical`. For instance, putting `export EDITOR=/usr/bin/nano` near the top of your RC-file. It may later be overridden by `lackadaisical` itself if you use (or have used) `ched`. +Simply open your shell's RC-file (.bashrc, .zshrc, etc) and include +`source /ld.source`, preferably at the bottom of the file. +We recommend setting your editor before sourcing `lackadaisical`. For instance, +putting `export EDITOR=/usr/bin/nano` near the top of your RC-file. It may +later be overridden by `lackadaisical` itself if you use (or have used) `ched`. -You can also try out the utilities by simply sourcing the file while running your shell of choice. It will automatically include itself into your `PATH` variable. +You can also try out the utilities by simply sourcing the file while running +your shell of choice. It will automatically include itself into your `PATH` +variable. -At first use, `lackadaisical` will provide you with information via `daisy_help`. This information is identical to what can be read in the `Getting Started` section below. +At first use, `lackadaisical` will provide you with some information. This +information is identical to what can be read in the `Getting Started` section +below. + +Please use `daisy help` to see this message again if you get lost! ## Getting started ``` @@ -30,6 +42,10 @@ specifying an env value of; NO_ARCHIVEMOUNT=1. The standard script supports zip, tarballs, and rar archives. We recommend relying on archivemount` if you have it installed. Use "--check" to only check if a file is an archive. It returns 0 if it is, 1 otherwise. + +Usage: cdz + cdz --check +Returns: (with --check) 0 if file is archive, 1 if it is not. ················································································ < squasher > @@ -58,6 +74,9 @@ take the same folder argument: Uses your standard CLI editor to create/modify a file and make it executable. If the executable already exists in path, it will edit that instead. Should you not want this behavior, call the utility with the -n switch. + +Usage: editx + editx -n ················································································ < filewait > @@ -66,6 +85,9 @@ This tool is given a filename of a file that does not exist yet. When the file appears on disk, the tool quits and simply returns the filename. This can be used in personal workflows to stall a longer command that relies on the existence of said file. + +Usage: filewait +Returns: filename specified as argument ················································································ < agenda > @@ -78,6 +100,21 @@ automatically cleans up empty folders. A symbolic link to the base of the folder's tree, ".tree", is created in the root of the specified directly. Can be used for everything you'd like to sort by date. For example; a diary, browser downloads, backups, code. + +There is a switch available: +--view : Lists all entries recursively. For example, if used with a year + like "agenda --view "2026" ", you will get a full + directory listing of all entries in 2026 recursively. + If you specify a month as well, you get all the entries from + said month. You can also select a specific date, but it it does + not exist, you will not get any results. Additionally, you need + to use the date structure YYYY/MM/DD. + Each day will be listed with a full path, allowing you to cd to + them (hint: The ".tree" symlink in your folder also allows you + to browse the tree). + +Usage: agenda + agenda --view ················································································ < own > @@ -92,8 +129,12 @@ This is a wrapper for `ssh`, the meaning of the 'p' is "Plus". Integrates SSHFS support. If both client and host have SSHFS, this wrapper can be used to connect their file systems. For example, if you need to move files from one machine to another, you could do something like this: "sshp -m /:/mnt/pc -m -/home/claire:/home/claire claire@pyon.net" If privilege escalation is necessary -for FS access, you will be asked for a password. +/home/claire:/home/claire claire@pyon.net". Each "-m" switch indicates a +Docker-style mapping from a local directory to a remote directory. +If privilege escalation is necessary for FS access, you will be asked for a +password. + +Usage: sshp -m : [user@]host [ssh_options] ················································································ < shrc > @@ -114,10 +155,15 @@ returns partial matches. It can be used to search for binaries. ················································································ < scriptbox > -················································································ +························································q························ This tool can be used to pack bash scripts into one big megascript, much like how `busybox` works. You can also make symlinks to it to invoke a specific -script. +script. Standard binaries are not supported. + +Usage: +Creating boxed binary: scriptbox -o <-s source files> + <-p include files verbatim> -i INPUT_BINS ... +More information: scriptbox ················································································ < bak/unbak > @@ -174,19 +220,24 @@ Similar to `cdf` but uses tree+peco for the query. An extremely simple utility that functions as a clipboard of sorts. To set the variable, run "clip " or provide data via stdin. To get the variable, simply run clip without any arguments. The variable is stored locally in the -shell as "LD_CLIP". +shell as "LD_CLIP". Run with switch "-c" to clear LD_CLIP. + +Usage: clip + clip -c + clip +Returns: Without arguments, the contents of LD_CLIP. ················································································ < ldrc > ················································································ -Edits daisy.source and re-sources it, similarly to shrc. Append "-e" to edit +Edits ld.source and re-sources it, similarly to shrc. Append "-e" to edit "extra.src", to add custom functions in the lackadaisical namespace. Append "-d" to edit "daisy.command.source". ················································································ < daisy reload > ················································································ -Re-sources daisy.source. Essentially `ldrc` without editing. +Re-sources ld.source. Essentially `ldrc` without editing. ················································································ < grab > @@ -288,3 +339,7 @@ functions provided by `lackadaisical`. ················································································ ``` + +# Future plans +We will keep improving and enhancing the scripts. Possibly, we will add new +utilities. We hope you found LACKADAISICAL useful. diff --git a/agenda b/agenda index 0ab3fa5..5b9d88c 100755 --- a/agenda +++ b/agenda @@ -1,39 +1,15 @@ #!/usr/bin/env bash -# This script is intended to be run via cron. +# This script is intended to be run via cron. But you can run it manually as +# well # It creates a folder structure in home for the current date in the following format: -# $HOME//// +# //// # It also sets up a symlink for the tagged folder. # This symlink will always point to the folder for the current date. # Finally, it removes any folders without data, to prevent clutter. -LD_INTERNAL=1 -. $(dirname $(realpath $0))/daisy.source - -if [[ $1 == '' ]]; then - echo "Usage: $LD_BIN " - echo "Creates a folder within '.daisy' in the current directory containing" - echo "a tree of dates associated with the folder name given by argument." - echo "A symlink is (re-)created at the same time with the same folder name." - echo "For example, if given the folder 'notes', this utility will:" - echo "- Create a folder '/.daisy/notes///'." - echo "- Create a symlink named 'notes' that points to it." - echo "It is recommended to run this via cron." - exit 1 -fi - -dir=$(realpath -s "$1") -parent_dir=$(dirname "$dir") -name=$(basename "$dir") -root_dir="$parent_dir/.daisy/$name" -today_sym="$dir" - -# Present day -read year month day < <(date "+%Y %m %d") -today="$root_dir/$year/$month/$day" - set -e function errorFn @@ -50,11 +26,70 @@ function errorFn # Error handling trap errorFn ERR +# Source LD +LD_INTERNAL=1 +. $(dirname $(realpath $0))/ld.source + +if [[ $1 == '' ]]; then + echo "Usage: $LD_BIN " + echo "Creates a folder within '.daisy' in the current directory containing" + echo "a tree of dates associated with the folder name given by argument." + echo "A symlink is (re-)created at the same time with the same folder name." + echo "For example, if given the folder 'notes', this utility will:" + echo "- Create a folder '/.daisy/notes///'." + echo "- Create a symlink named 'notes' that points to it." + echo "It is recommended to run this via cron." + exit 1 +fi + +view=0 +view_date=0 + +if [[ "$1" == "--view" ]]; then + # We are only going to view the agenda + view_date=$2 + view=1 + shift 2 +fi + +dir=$(realpath -s "$1") +parent_dir=$(dirname "$dir") +name=$(basename "$dir") +root_dir="$parent_dir/.daisy/$name" +today_sym="$dir" + +# Present day +read year month day < <(date "+%Y %m %d") +today="$root_dir/$year/$month/$day" + # First we clear out empty folders, and remove the symlink if it exists -test -e "$root_dir" && find "$root_dir" -maxdepth 3 -type d -empty -delete +if test -e "$root_dir"; then + find "$root_dir" -name "More..." -delete + find "$root_dir" -depth -maxdepth 3 -type d \ + -not -path "$today" \ + -exec sh -c ' + if [ $(ls -A "$1" | wc -l) -eq 0 ]; then + rm -rf "$1" + fi + ' _ {} \; +fi + +if [[ $view == 1 ]]; then + # View mode + [[ ! -d "$root_dir/$view_date" ]] && echo "This date entry does not exist." && exit 1 + view_date="$root_dir/$view_date" + + # 1. -name "*.squashfs" -prune: If a folder ends in .squashfs, don't descend into it. + # 2. ! -name "*.squashfs": Inside the directory check, ignore squashfs files. + # 3. --ignore="*.squashfs": Tells ls to hide those entries from the final list. + find "$(realpath "$view_date")" -name "*.squashfs" -prune -o -type d -exec sh -c ' + find "$1" -maxdepth 1 -type f ! -name "*.squashfs" | read -r + ' _ {} \; -exec ls --color=always -lah --ignore="*.squashfs" {} + 2>/dev/null + exit 0 +fi # Now we can set up today's directory mkdir -p "$today" ln -snf "$today" "$today_sym" -ln -snf "$root_dir" "$dir/.tree" +ln -snf "$root_dir" "$dir/More..." exitcode=$? diff --git a/cdz b/cdz index 3b8d15a..275bf77 100755 --- a/cdz +++ b/cdz @@ -4,19 +4,20 @@ if [[ $LD_INTERNAL -ne 1 ]] then LD_INTERNAL=1 - . $(dirname $(realpath $0))/daisy.source + . $(dirname $(realpath $0))/ld.source fi is_archive() { local file="$1" local mime_type=$(file --mime-type -b "$file") - - if [[ $mime_type == *"tar"* || $file == *.tar* || $mime_type == "application/zip" || $mime_type == "application/x-rar" ]] + + if [[ $mime_type == *"tar"* || $file == *.tar* || \ + $mime_type == "application/zip" || $mime_type == "application/x-rar" ]] then return 0 fi - + if command -v archivemount >/dev/null 2>&1 then local test_dir=$(mktemp -d /tmp/cdz_check.XXXXXXXX) @@ -29,7 +30,7 @@ is_archive() rmdir "$test_dir" return $result fi - + return 1 } diff --git a/daisy.command.source b/daisy.command.source index 144be92..b825177 100755 --- a/daisy.command.source +++ b/daisy.command.source @@ -40,17 +40,20 @@ _daisy_enc() fi if [ -n "$1" ] && [ -d "$1" ]; then - echo -e "daisy_create_folder=$1" + printf "daisy_create_folder=%s\n" "$1" else - local file_dir="" + local file_dir="." local file_name="" local perms=755 + local input_source="/dev/stdin" local target=$1 if [[ ! -t 0 ]] && [[ $enc_is_folder == 0 ]]; then + input_source="$1" file_dir="." file_name="$1" elif [ -f "$1" ]; then + input_source="$1" file_dir=$(dirname "$1") file_name=$(basename "$1") perms=$(stat -c %a "$1") @@ -60,10 +63,10 @@ _daisy_enc() fi local base64_inner - base64_inner=$(cat "${1:-/dev/stdin}" | base64 | tr -d '\n') - echo -e "daisy_folder_$file_name=$file_dir" - echo -e "daisy_data_base64_$file_name=\"$base64_inner\"" - echo -e "daisy_perms_$file_name=$perms" + base64_inner=$(cat "${input_source:-/dev/stdin}" | base64 | tr -d '\n') + printf "daisy_folder_%s=%s\n" "$file_name" "$file_dir" + printf "daisy_data_base64_%s=\"%s\"\n" "$file_name" "$base64_inner" + printf "daisy_perms_%s=%s\n" "$file_name" "$perms" fi } @@ -73,16 +76,15 @@ _daisy_dec() echo "$0: No arguments or stdin specified!" return 1 fi - local data - data=$(cat "${1:-/dev/stdin}" | grep -v "#") - echo -e "$data" | cut -d "=" -f 2- | cut -b 2- | head -c -2 | base64 -d + sed -n "s/^daisy_data_base64_.*=\"\(.*\)\"$/\1/p" "${1:-/dev/stdin}" | base64 -d } _daisy_unalias() { local unalias_param="$1" if [[ $unalias_param =~ ^[0-9]+$ ]]; then - unalias_param=$(head -"$unalias_param" "$LD_ALIASFILE" 2>/dev/null | tail -1 | cut -d "=" -f 1 | awk '{print $2}') + unalias_param=$(head -"$unalias_param" "$LD_ALIASFILE" 2>/dev/null | \ + tail -1 | cut -d "=" -f 1 | awk '{print $2}') fi if [[ -z "$unalias_param" ]]; then return @@ -117,49 +119,49 @@ cmd_help() # Match lines defining tools (e.g., "< cdz >" or "< daisy welcome >") $0 ~ /^[[:space:]]*< .* >/ { - printing=0 # Stop printing previous tool + printing=0 # Stop printing previous tool - # Clean the line to get the "signature" - # "< daisy welcome >" becomes "daisy welcome" - sig = $0 - sub(/^[[:space:]]*< /, "", sig) - sub(/ >[[:space:]]*$/, "", sig) + # Clean the line to get the "signature" + # "< daisy welcome >" becomes "daisy welcome" + sig = $0 + sub(/^[[:space:]]*< /, "", sig) + sub(/ >[[:space:]]*$/, "", sig) - # Check for exact match OR match within a slash/space-separated list - split(sig, names, "[ /]") + # Check for exact match OR match within a slash/space-separated list + split(sig, names, "[ /]") - is_match = 0 - if (sig == query) is_match = 1 - else { - for (i in names) - { - if (names[i] == query) - { is_match = 1; break } - } - } + is_match = 0 + if (sig == query) is_match = 1 + else { + for (i in names) + { + if (names[i] == query) + { is_match = 1; break } + } + } - if (is_match) - { - printing=1 - found=1 - print $0 - next - } + if (is_match) + { + printing=1 + found=1 + print $0 + next + } } # Print description lines if we are in a "found" block printing { - # Stop if we hit the start of the NEXT tool - if ($0 ~ /^[[:space:]]*< /) - { printing=0; next } - print + # Stop if we hit the start of the NEXT tool + if ($0 ~ /^[[:space:]]*< /) + { printing=0; next } + print } END { - if (found == 0) - { - print "Tool '"'"'" query "'"'"' not found in README.md." - } + if (found == 0) + { + print "Tool '"'"'" query "'"'"' not found in README.md." + } } ' fi @@ -176,9 +178,9 @@ cmd_list() sed -n '/--- BEGIN OF DAISY HELP ---/,/--- END OF DAISY HELP ---/{//!p;}' "$file" | awk ' /^[[:space:]]*< / { - sub(/^[[:space:]]*< /, ""); - sub(/ >[[:space:]]*$/, ""); - print " " $0 + sub(/^[[:space:]]*< /, ""); + sub(/ >[[:space:]]*$/, ""); + print " " $0 } ' | sort } @@ -220,8 +222,8 @@ cmd_dec() local arg1=$1 local arg2=$2 if [ ! -t 0 ]; then - arg2=$1 - arg1=/dev/stdin + arg2=$1 + arg1=/dev/stdin fi [[ -t 0 ]] && [[ ! -f "$arg1" ]] && echo "daisy dec multi: No input file specified" && exit 1 [[ ! -d "$arg2" ]] && echo "daisy dec multi: No output directory specified" && exit 1 @@ -258,9 +260,9 @@ cmd_alias() local linenum=1 if [[ -f "$LD_ALIASFILE" ]]; then while IFS= read -r line; do - line=$(echo "$line" | sed 's/alias //g') - echo "$linenum: $line" - ((linenum++)) + line=$(echo "$line" | sed 's/alias //g') + echo "$linenum: $line" + ((linenum++)) done < "$LD_ALIASFILE" fi else @@ -321,7 +323,7 @@ cmd_check() check_bin sed "Stream editing" check_bin grep "Pattern matching" check_bin base64 "Data encoding" - check_bin realpath "Path resolution" + check_bin realpath "Path resolution" echo -e "\n--- Enhanced UI & Navigation ---" check_bin fzf "Used by cdf" @@ -398,9 +400,13 @@ daisy () dec) shift; cmd_dec "$@" ;; alias) shift; cmd_alias "$@" ;; unalias) shift; _daisy_unalias "$@" ;; - backup) shift; find "$LD_CONFIG_FOLDER" -name "*.src" -type f | while read -r f; do cp -R "$f" "$f.bak"; echo "Backup made: $f --> $f.bak"; done ;; + backup) shift; find "$LD_CONFIG_FOLDER" -name "*.src" -type f | \ + while read -r f; do \ + cp -R "$f" "$f.bak"; \ + echo "Backup made: $f --> $f.bak"; + done ;; clear) shift; cmd_clear ;; - check) shift; cmd_check ;; + check) shift; cmd_check ;; restore) shift; cmd_restore ;; combine) shift; cmd_combine ;; editor) shift; cmd_editor "$@" ;; diff --git a/daisy.source b/daisy.source deleted file mode 100755 index 1b5b165..0000000 --- a/daisy.source +++ /dev/null @@ -1,375 +0,0 @@ -#!/usr/bin/env bash -#!/usr/bin/env -S echo "This file can only be sourced, not run stand-alone." -# LACKADAISICAL SOURCE-ABLE FILE - -# Source this in your RC file or manually to receive some of the simpler -# utilities, as well as aliases for `shrc` and `cdf`. Set env variable -# FROM_RC to 1 when sourcing this file to get RC-related functionality: -# FROM_RC=1 source /daisy.source - -# This file is also sourced in some of the scripts included within -# lackadaisical for common functionality. Some of the shared functionality is -# only included if sourced from one of the included scripts, though you are -# free to bypass this by setting env variable LD_INTERNAL to 1. - -# Pass _LD_DEBUG=1 during sourcing to see debug information on a variety of things. - -if [[ $LD_INTERNAL == 1 ]]; -then - export LD_BIN=$(basename $0) -fi - -function ld_dbg -{ - if [[ $_LD_DEBUG == 1 ]]; - then - $@ - fi -} - -# Variables for use in other utilities -# Find the right argument for our folder -arg=$0 -if [[ ! $arg == *daisy.source* ]]; -then - arg="${BASH_SOURCE[0]}" -fi - -# Check for dependencies -function _daisy_dependency_check -{ - if command -v "$1" >/dev/null 2>&1; then - echo 1 - else - echo 0 - fi -} - -LD_HAS_fzf=$(_daisy_dependency_check fzf) -LD_HAS_md5sum=$(_daisy_dependency_check md5sum) -LD_HAS_peco=$(_daisy_dependency_check peco) -LD_HAS_tree=$(_daisy_dependency_check tree) -LD_HAS_dialog=$(_daisy_dependency_check dialog) - -ld_dbg echo "Presence of utils:" -ld_dbg echo fzf $LD_HAS_fzf -ld_dbg echo md5sum $LD_HAS_md5sum -ld_dbg echo peco $LD_HAS_peco -ld_dbg echo tree $LD_HAS_tree -ld_dbg echo dialog $LD_HAS_dialog - -export LD_FOLDER=$(dirname $(realpath $arg)) -export LD_SOURCE_FILE=$(realpath $arg) -export LD_AVAILABLE=0 - -# Config folder setup -export LD_CONFIG_FOLDER="$HOME/.config/lackadaisical" -export LD_NEW_INSTALL=0 - -if [[ ! -d "$LD_CONFIG_FOLDER" ]]; -then - # Create the folder with its basics - mkdir -p "$LD_CONFIG_FOLDER" - export LD_NEW_INSTALL=1 -fi - -# Multiple default source files -# [LEA.TODO] Turn these into arrays -export LD_ALIASFILE="$LD_CONFIG_FOLDER/aliases.src" -export LD_EDITORFILE="$LD_CONFIG_FOLDER/editor.src" -export LD_ESOURCEFILE="$LD_CONFIG_FOLDER/extra.src" -touch $LD_ALIASFILE -touch $LD_EDITORFILE -touch $LD_ESOURCEFILE - -ld_dbg echo "Sourced config contents:" -ld_dbg cat $LD_ALIASFILE -ld_dbg cat $LD_EDITORFILE -ld_dbg cat $LD_ESOURCEFILE - -# Source everything in the config folder -function _daisy_source_configs -{ - while IFS= read -r -d '' f; do - source "$f" - done < <(find "$LD_CONFIG_FOLDER" -name "*.src" -type f -print0) -} - -# Installation into PATH -if [[ ! $PATH == *"$LD_FOLDER"* ]]; -then - export PATH="$PATH:$LD_FOLDER" -fi - -# Set up the basic alias for `shrc` -# Do not set these up if LD_INTERNAL=1 is set, or infinite recursion could -# occur! -if [[ ! -v LD_INTERNAL ]]; -then - alias shrc=". shrc" -fi - -############################################################################### -# FUNCTIONS and ALIASES ####################################################### -############################################################################### - -function multicd -{ - cdpath="$@" - if [[ $cdpath == '' ]] - then - \cd - return - fi - - if cdz --check "$cdpath" >/dev/null 2>&1 - then - cdz "$cdpath" - return - fi - - if [[ -f "$cdpath/.needs_mount" ]] - then - squasher mount "$cdpath" - fi - \cd "$cdpath" -} - -alias cd=multicd - -# bak and unbak -function bak -{ - # Input: - target=$1 - - # Check if file exists - if ! test -f "$target"; - then - echo "Path not found: \"$target\"" - return 2 - fi - - # Handle both cases - if [[ $unbak_mode == 1 ]]; - then - cp -R "$target.bak" "$target" - rm -rf "$target.bak" - echo "Restored backup: $target <-- $target.bak" - else - cp -R "$target" "$target.bak" - echo "Backup made: $target --> $target.bak" - fi -} - -function unbak -{ - unbak_mode=1 bak $@ -} - -function lsa -{ - ls -a -l -h $@ -} - -function lsn -{ - ls -a -l -tu -r -h $@ -} - -function lss -{ - ls -a -l -S -r -h $@ -} - -# Simple version of `cdf` -function cdf -{ - if [[ $LD_HAS_fzf != 1 ]]; - then - echo "This function requires the utility 'fzf'. Please install it." - return 1 - fi - cd "$(dirname "$(fzf)")" -} - -function cdp -{ - if [[ $LD_HAS_peco != 1 || $LD_HAS_tree != 1 ]]; - then - echo "This function requires the utilities 'peco' and 'tree'. Please install them." - echo "Consider using 'cdf' instead." - return 1 - fi - cd $(dirname $(tree -fia --noreport . | peco)) -} - -function editpeco -{ - if [[ $LD_HAS_peco != 1 || $LD_HAS_tree != 1 ]]; - then - echo "This function requires the utilities 'peco' and 'tree'. Please install them." - echo "Consider using 'cdf' instead." - return 1 - fi - tree --noreport -fia . | peco --prompt "Press CTRL+C to quit - query:" --exec "xargs -o -I{} $EDITOR {}" -} - -# sets a new editor based on commony available ones, and some visual ones -function ched -{ - override=0 - if [[ $1 == "-g" ]]; - then - override=1 - fi - - if [[ $LD_HAS_dialog != 1 ]]; - then - echo "This function requires the utility 'dialog'. Please install it." - return 1 - fi - - editors=("nano" "vim" "nvim" "vi" "emacs" "gedit" "kate" "mousepad" "micro" \ - "code" "subl" "joe" "kwrite" "gnome-text-editor") - - # Find which editors are installed - available_editors=() - for editor in "${editors[@]}"; - do - editor_real=$(command -v "$editor") - if command -v "$editor_real" >/dev/null 2>&1; - then - if [[ $(realpath "$EDITOR") == "$editor_real" ]]; - then - available_editors+=("$editor_real" "$editor (current)") - elif [[ $LD_EDITOR == "$editor_real" ]]; - then - available_editors+=("$editor_real" "$editor (LD choice)") - else - available_editors+=("$editor_real" "$editor") - fi - fi - done - - if [[ $override == 0 ]] && [[ ! -z $@ ]]; - then - text="$@" - dialog --msgbox "$text" 0 0 - elif [[ $override == 1 ]]; - then - text="You have passed '-g'. Your choice of dialog will override any other choice or setting of 'EDITOR'." - dialog --msgbox "$text" 0 0 - fi - - # Present all choices - choice=$(dialog --output-fd 1 --clear --title "Select Text Editor" \ - --menu "Choose one of the installed text editors:" 15 100 6 \ - "${available_editors[@]}") - dialog_ret=$? - - if [ $dialog_ret -ne 0 ]; - then - dialog --msgbox "No editor selected. Variables will not be updated." 0 0 - return 0 - fi - - [[ $override == 0 ]] && echo export EDITOR="${EDITOR:-$choice}" > "$LD_EDITORFILE" - [[ $override == 1 ]] && echo export EDITOR="$choice" > "$LD_EDITORFILE" - echo export LD_EDITOR="$choice" >> "$LD_EDITORFILE" - echo export LD_OLD_EDITOR="$EDITOR" >> "$LD_EDITORFILE" - - source "$LD_EDITORFILE" -} - -function ldrc -{ - ARG=$1 - SOURCE="$LD_SOURCE_FILE" - [[ "$ARG" == "-e" ]] && SOURCE="$LD_ESOURCEFILE" - - daisy editor "$SOURCE" - LD_INTERNAL=0 source "$SOURCE" -} - -# Saves a bit on typing -function grab -{ - [[ -z $@ ]] && return; - awk '{print $'$1'}' -} - -function clip -{ - data="" - - if [ ! -t 0 ]; then - data="$(cat)" - elif [ "$*" != "" ]; then - data="$*" - else - echo $LD_CLIP - return 0 - fi - - # Export the variable - export LD_CLIP="$data" - echo "Variable set to \"$LD_CLIP\"." -} - -# Aliases for front-facing daisy commands -function _daisy_def_alias -{ - # Map underscores in name to spaces in command if needed - local cmd=$(echo $1 | tr '_' ' ') - alias ld_$1="daisy $cmd" - alias daisy_$1="daisy $cmd" -} - -_daisy_def_alias reload -_daisy_def_alias enc -_daisy_def_alias enc_multi -_daisy_def_alias enc_folder -_daisy_def_alias dec -_daisy_def_alias dec_multi -_daisy_def_alias alias -_daisy_def_alias unalias -_daisy_def_alias backup -_daisy_def_alias clear -_daisy_def_alias restore -_daisy_def_alias combine -_daisy_def_alias help -_daisy_def_alias list -_daisy_def_alias check - -_daisy_source_configs - -############################################################################### -# check for dependencies @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ -############################################################################### -if [[ LD_NEW_INSTALL -eq 1 ]]; -then - echo "Thank you for installing LACKADAISICAL!" - daisy list - echo "For more information, run 'daisy help'." - echo "For information on a specific command, run 'daisy help '." - echo -e "\nLACKADAISICAL has several dependencies, please run 'daisy check'" - echo "to check for dependencies and see what commands require them." - echo -e "\nTo uninstall LACKADAISICAL, simply remove the source line from your" - echo "shell RC, and reload it. This does not remove the files!" -fi - -############################################################################### -# end of FUNCTIONS and ALIASES ################################################ -############################################################################### - -source "/etc/lackadaisical/daisy.command.source" - -############################################################################### -# Autocomplete for `daisy` command ############################################ -############################################################################### - -# End of user section! -export LD_AVAILABLE=1 - -[ -d "$LD_FOLDER" ] && export LD_AVAILABLE=1 diff --git a/editx b/editx index ac031d9..f09eabf 100755 --- a/editx +++ b/editx @@ -3,7 +3,13 @@ # removes the resulting file if it is empty after the editor closes. LD_INTERNAL=1 -. $(dirname $(realpath $0))/daisy.source +. $(dirname $(realpath $0))/ld.source + +use_path=1 +if [[ $1 == "-n" ]]; then + shift + use_path=0 +fi if [[ -z $1 ]]; then @@ -13,7 +19,7 @@ fi if [[ -z "${EDITOR}" ]]; then - # ched is defined in daisy.source + # ched is defined in ld.source ched "EDITOR env variable not set! You will have to set it yourself in the next screen." fi @@ -23,7 +29,7 @@ file_in_path=$(whereis $1 | awk '{print $2}') path_exist=0 [[ -e "$file" ]] && file_exist=1 -[[ -n "$file_in_path" ]] && path_exist=1 +[[ $use_path == 1 ]] && [[ -n "$file_in_path" ]] && path_exist=1 if [[ $path_exist == 1 && $file_exist == 0 ]]; then file=$file_in_path @@ -37,14 +43,14 @@ elif [[ $path_exist == 1 && $file_exist == 1 ]]; then case "$choice" in 1) - file=$file - ;; + file=$file + ;; 2|"") - file="$file_in_path" - ;; + file="$file_in_path" + ;; *) - file="$file_in_path" - ;; + file="$file_in_path" + ;; esac fi fi diff --git a/filewait b/filewait index 2705a43..8f68340 100755 --- a/filewait +++ b/filewait @@ -2,7 +2,7 @@ # A simple utility that waits for a file to become available, infinitely LD_INTERNAL=1 -. $(dirname $(realpath $0))/daisy.source +. $(dirname $(realpath $0))/ld.source file=$@ while [ ! -f "$file" ] diff --git a/own b/own index 6db1b49..cc0d581 100755 --- a/own +++ b/own @@ -3,7 +3,7 @@ # user, recursively. LD_INTERNAL=1 -. $(dirname $(realpath $0))/daisy.source +. $(dirname $(realpath $0))/ld.source if [[ -z "$1" ]]; then echo "$LD_BIN: Quickly take ownership of files/folders." diff --git a/scriptbox b/scriptbox index 6ddaeb0..003bdca 100755 --- a/scriptbox +++ b/scriptbox @@ -4,7 +4,7 @@ # said script. The idea is similar to `busybox`. LD_INTERNAL=1 -. $(dirname $(realpath $0))/daisy.source +. $(dirname $(realpath $0))/ld.source args=$@ @@ -16,9 +16,9 @@ function help() echo "call the function like so: 'combi-bin input-bin ." echo "" echo "> Usage:" - echo "Creating boxed binary: $LD_BIN -o <-s source files> <-p include files verbatim> -i INPUT_BINS ..." - echo " Unpacking a boxed binary: $LD_BIN -e " - echo "View this screen: $LD_BIN " + echo "Boxing scripts: scriptbox -o <-s source files>" + echo " <-p include files verbatim> -i INPUT_BINS ..." + echo "View help: $LD_BIN " exit 0 } @@ -63,45 +63,45 @@ while [ $i -lt $# ]; do -i) ((i++)) while [ $i -lt $# ] && [[ ! "${args[$i]}" =~ ^- ]]; do - file="${args[$i]}" - ((i++)) - if [[ -e "$file" ]]; then - inputs+=("$file") - ((b++)) - else - echo "WARNING: Missing input binary: \"$file\"." - echo "Module will NOT be available!" - fi + file="${args[$i]}" + ((i++)) + if [[ -e "$file" ]]; then + inputs+=("$file") + ((b++)) + else + echo "WARNING: Missing input binary: \"$file\"." + echo "Module will NOT be available!" + fi done continue ;; -s) ((i++)) while [ $i -lt $# ] && [[ ! "${args[$i]}" =~ ^- ]]; do - file="${args[$i]}" - ((i++)) - if [[ -e "$file" ]]; then - sources+=("$file") - ((s++)) - else - echo "WARNING: Missing input source: \"$file\"." - echo "File will NOT be sourced!" - fi + file="${args[$i]}" + ((i++)) + if [[ -e "$file" ]]; then + sources+=("$file") + ((s++)) + else + echo "WARNING: Missing input source: \"$file\"." + echo "File will NOT be sourced!" + fi done continue ;; -p) ((i++)) while [ $i -lt $# ] && [[ ! "${args[$i]}" =~ ^- ]]; do - file="${args[$i]}" - ((i++)) - if [[ -e "$file" ]]; then - includes+=("$file") - ((p++)) - else - echo "WARNING: Missing input include: \"$file\"." - echo "File will NOT be included!" - fi + file="${args[$i]}" + ((i++)) + if [[ -e "$file" ]]; then + includes+=("$file") + ((p++)) + else + echo "WARNING: Missing input include: \"$file\"." + echo "File will NOT be included!" + fi done continue ;; diff --git a/squasher b/squasher index ec9a84d..a4abc1b 100755 --- a/squasher +++ b/squasher @@ -147,8 +147,8 @@ case "$COMMAND" in destroy) if [[ ! -f "$DIR/.needs_mount" ]]; then if ! mountpoint -q "$DIR"; then - echo "Error: $DIR is not a SquashFS directory." - exit 1 + echo "Error: $DIR is not a SquashFS directory." + exit 1 fi fi diff --git a/sshp b/sshp index bc50bb6..3d458cf 100755 --- a/sshp +++ b/sshp @@ -13,16 +13,18 @@ usage() } while [[ $# -gt 0 ]]; do - case "$1" in - -m) - if [[ -z "$2" ]]; then echo "Error: -m requires argument"; exit 1; fi - mounts+=("$2") - shift 2 - ;; - *) - ssh_args+=("$1") - shift - ;; + case "$1" in + -m) + if [[ -z "$2" ]]; then + echo "Error: -m requires argument"; exit 1; + fi + mounts+=("$2") + shift 2 + ;; + *) + ssh_args+=("$1") + shift + ;; esac done @@ -48,9 +50,9 @@ done remote_script=" if ! command -v sshfs >/dev/null 2>&1; then - echo 'WARNING: \"sshfs\" not found on remote host.' + echo 'WARNING: \"sshfs\" not found on remote host.' else - ${mount_logic} + ${mount_logic} fi \${SHELL:-bash}; ${unmount_logic} diff --git a/sw b/sw index 0971413..d542a11 100755 --- a/sw +++ b/sw @@ -2,7 +2,7 @@ # It just swaps two files LD_INTERNAL1 -. $(dirname $(realpath $0))/daisy.source +. $(dirname $(realpath $0))/ld.source file1=$1 file2=$2 diff --git a/what b/what index 707e0ce..196c182 100755 --- a/what +++ b/what @@ -24,7 +24,7 @@ # LD_INTERNAL=1 -. $(dirname $(realpath $0))/daisy.source +. $(dirname $(realpath $0))/ld.source all_bins=$(compgen -c | sort -u)