Major chhanges: daisy.source renamed to ld.source.
All files have been prettified by making sure we use 2-space indent. agenda: Instead of the hidden .tree file, a file created "More..." is made. You can use (ex) "agenda --view "2026" to get a full list of files from that year/date/day. Additionally, minor fixes have been made. clip: You can now use "-c" to clear the clipbaord.
This commit is contained in:
parent
056ab01ed4
commit
ab730db2f7
14 changed files with 264 additions and 534 deletions
0
LICENSE
Executable file → Normal file
0
LICENSE
Executable file → Normal file
83
README.md
Executable file → Normal file
83
README.md
Executable file → Normal file
|
|
@ -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.
|
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
|
# 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
|
## 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
|
## How to use
|
||||||
Simply open your shell's RC-file (.bashrc, .zshrc, etc) and include `source <la
|
Simply open your shell's RC-file (.bashrc, .zshrc, etc) and include
|
||||||
ckadaisical-folder>/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`.
|
`source <lackadaisical-folder>/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
|
## 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
|
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
|
have it installed. Use "--check" to only check if a file is an archive. It
|
||||||
returns 0 if it is, 1 otherwise.
|
returns 0 if it is, 1 otherwise.
|
||||||
|
|
||||||
|
Usage: cdz <archive>
|
||||||
|
cdz --check <archive>
|
||||||
|
Returns: (with --check) 0 if file is archive, 1 if it is not.
|
||||||
················································································
|
················································································
|
||||||
|
|
||||||
< squasher >
|
< squasher >
|
||||||
|
|
@ -58,6 +74,9 @@ take the same folder argument:
|
||||||
Uses your standard CLI editor to create/modify a file and make it executable.
|
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.
|
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.
|
Should you not want this behavior, call the utility with the -n switch.
|
||||||
|
|
||||||
|
Usage: editx <file_local_or_in_path>
|
||||||
|
editx -n <file>
|
||||||
················································································
|
················································································
|
||||||
|
|
||||||
< filewait >
|
< 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
|
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
|
used in personal workflows to stall a longer command that relies on the
|
||||||
existence of said file.
|
existence of said file.
|
||||||
|
|
||||||
|
Usage: filewait <inexistant_file>
|
||||||
|
Returns: filename specified as argument
|
||||||
················································································
|
················································································
|
||||||
|
|
||||||
< agenda >
|
< 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
|
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,
|
be used for everything you'd like to sort by date. For example; a diary,
|
||||||
browser downloads, backups, code.
|
browser downloads, backups, code.
|
||||||
|
|
||||||
|
There is a switch available:
|
||||||
|
--view <date>: Lists all entries recursively. For example, if used with a year
|
||||||
|
like "agenda --view "2026" <folder>", 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 <folder>
|
||||||
|
agenda --view <folder>
|
||||||
················································································
|
················································································
|
||||||
|
|
||||||
< own >
|
< 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
|
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
|
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
|
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
|
/home/claire:/home/claire claire@pyon.net". Each "-m" switch indicates a
|
||||||
for FS access, you will be asked for a password.
|
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 <local>:<remote> [user@]host [ssh_options]
|
||||||
················································································
|
················································································
|
||||||
|
|
||||||
< shrc >
|
< shrc >
|
||||||
|
|
@ -114,10 +155,15 @@ returns partial matches. It can be used to search for binaries.
|
||||||
················································································
|
················································································
|
||||||
|
|
||||||
< scriptbox >
|
< scriptbox >
|
||||||
················································································
|
························································q························
|
||||||
This tool can be used to pack bash scripts into one big megascript, much like
|
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
|
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 <BOXED_BIN> <-s source files>
|
||||||
|
<-p include files verbatim> -i INPUT_BINS ...
|
||||||
|
More information: scriptbox <no-args>
|
||||||
················································································
|
················································································
|
||||||
|
|
||||||
< bak/unbak >
|
< 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
|
An extremely simple utility that functions as a clipboard of sorts. To set the
|
||||||
variable, run "clip <data>" or provide data via stdin. To get the variable,
|
variable, run "clip <data>" or provide data via stdin. To get the variable,
|
||||||
simply run clip without any arguments. The variable is stored locally in the
|
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 <anystring>
|
||||||
|
clip -c
|
||||||
|
clip
|
||||||
|
Returns: Without arguments, the contents of LD_CLIP.
|
||||||
················································································
|
················································································
|
||||||
|
|
||||||
< ldrc >
|
< 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.
|
"extra.src", to add custom functions in the lackadaisical namespace.
|
||||||
Append "-d" to edit "daisy.command.source".
|
Append "-d" to edit "daisy.command.source".
|
||||||
················································································
|
················································································
|
||||||
|
|
||||||
< daisy reload >
|
< daisy reload >
|
||||||
················································································
|
················································································
|
||||||
Re-sources daisy.source. Essentially `ldrc` without editing.
|
Re-sources ld.source. Essentially `ldrc` without editing.
|
||||||
················································································
|
················································································
|
||||||
|
|
||||||
< grab >
|
< grab >
|
||||||
|
|
@ -288,3 +339,7 @@ functions provided by `lackadaisical`.
|
||||||
················································································
|
················································································
|
||||||
<!-- --- END OF DAISY HELP --- -->
|
<!-- --- END OF DAISY HELP --- -->
|
||||||
```
|
```
|
||||||
|
|
||||||
|
# Future plans
|
||||||
|
We will keep improving and enhancing the scripts. Possibly, we will add new
|
||||||
|
utilities. We hope you found LACKADAISICAL useful.
|
||||||
|
|
|
||||||
93
agenda
93
agenda
|
|
@ -1,39 +1,15 @@
|
||||||
#!/usr/bin/env bash
|
#!/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:
|
# It creates a folder structure in home for the current date in the following format:
|
||||||
# $HOME/<Tag>/<Year>/<Month>/<Day>
|
# <Dir>/<Tag>/<Year>/<Month>/<Day>
|
||||||
|
|
||||||
# It also sets up a symlink for the tagged folder.
|
# It also sets up a symlink for the tagged folder.
|
||||||
# This symlink will always point to the folder for the current date.
|
# This symlink will always point to the folder for the current date.
|
||||||
|
|
||||||
# Finally, it removes any folders without data, to prevent clutter.
|
# 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 <folder>"
|
|
||||||
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/<year>/<month>/<day>'."
|
|
||||||
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
|
set -e
|
||||||
|
|
||||||
function errorFn
|
function errorFn
|
||||||
|
|
@ -50,11 +26,70 @@ function errorFn
|
||||||
# Error handling
|
# Error handling
|
||||||
trap errorFn ERR
|
trap errorFn ERR
|
||||||
|
|
||||||
|
# Source LD
|
||||||
|
LD_INTERNAL=1
|
||||||
|
. $(dirname $(realpath $0))/ld.source
|
||||||
|
|
||||||
|
if [[ $1 == '' ]]; then
|
||||||
|
echo "Usage: $LD_BIN <folder>"
|
||||||
|
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/<year>/<month>/<day>'."
|
||||||
|
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
|
# 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
|
# Now we can set up today's directory
|
||||||
mkdir -p "$today"
|
mkdir -p "$today"
|
||||||
ln -snf "$today" "$today_sym"
|
ln -snf "$today" "$today_sym"
|
||||||
ln -snf "$root_dir" "$dir/.tree"
|
ln -snf "$root_dir" "$dir/More..."
|
||||||
exitcode=$?
|
exitcode=$?
|
||||||
|
|
|
||||||
11
cdz
11
cdz
|
|
@ -4,19 +4,20 @@
|
||||||
if [[ $LD_INTERNAL -ne 1 ]]
|
if [[ $LD_INTERNAL -ne 1 ]]
|
||||||
then
|
then
|
||||||
LD_INTERNAL=1
|
LD_INTERNAL=1
|
||||||
. $(dirname $(realpath $0))/daisy.source
|
. $(dirname $(realpath $0))/ld.source
|
||||||
fi
|
fi
|
||||||
|
|
||||||
is_archive()
|
is_archive()
|
||||||
{
|
{
|
||||||
local file="$1"
|
local file="$1"
|
||||||
local mime_type=$(file --mime-type -b "$file")
|
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
|
then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if command -v archivemount >/dev/null 2>&1
|
if command -v archivemount >/dev/null 2>&1
|
||||||
then
|
then
|
||||||
local test_dir=$(mktemp -d /tmp/cdz_check.XXXXXXXX)
|
local test_dir=$(mktemp -d /tmp/cdz_check.XXXXXXXX)
|
||||||
|
|
@ -29,7 +30,7 @@ is_archive()
|
||||||
rmdir "$test_dir"
|
rmdir "$test_dir"
|
||||||
return $result
|
return $result
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,17 +40,20 @@ _daisy_enc()
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$1" ] && [ -d "$1" ]; then
|
if [ -n "$1" ] && [ -d "$1" ]; then
|
||||||
echo -e "daisy_create_folder=$1"
|
printf "daisy_create_folder=%s\n" "$1"
|
||||||
else
|
else
|
||||||
local file_dir=""
|
local file_dir="."
|
||||||
local file_name=""
|
local file_name=""
|
||||||
local perms=755
|
local perms=755
|
||||||
|
local input_source="/dev/stdin"
|
||||||
local target=$1
|
local target=$1
|
||||||
|
|
||||||
if [[ ! -t 0 ]] && [[ $enc_is_folder == 0 ]]; then
|
if [[ ! -t 0 ]] && [[ $enc_is_folder == 0 ]]; then
|
||||||
|
input_source="$1"
|
||||||
file_dir="."
|
file_dir="."
|
||||||
file_name="$1"
|
file_name="$1"
|
||||||
elif [ -f "$1" ]; then
|
elif [ -f "$1" ]; then
|
||||||
|
input_source="$1"
|
||||||
file_dir=$(dirname "$1")
|
file_dir=$(dirname "$1")
|
||||||
file_name=$(basename "$1")
|
file_name=$(basename "$1")
|
||||||
perms=$(stat -c %a "$1")
|
perms=$(stat -c %a "$1")
|
||||||
|
|
@ -60,10 +63,10 @@ _daisy_enc()
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local base64_inner
|
local base64_inner
|
||||||
base64_inner=$(cat "${1:-/dev/stdin}" | base64 | tr -d '\n')
|
base64_inner=$(cat "${input_source:-/dev/stdin}" | base64 | tr -d '\n')
|
||||||
echo -e "daisy_folder_$file_name=$file_dir"
|
printf "daisy_folder_%s=%s\n" "$file_name" "$file_dir"
|
||||||
echo -e "daisy_data_base64_$file_name=\"$base64_inner\""
|
printf "daisy_data_base64_%s=\"%s\"\n" "$file_name" "$base64_inner"
|
||||||
echo -e "daisy_perms_$file_name=$perms"
|
printf "daisy_perms_%s=%s\n" "$file_name" "$perms"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -73,16 +76,15 @@ _daisy_dec()
|
||||||
echo "$0: No arguments or stdin specified!"
|
echo "$0: No arguments or stdin specified!"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
local data
|
sed -n "s/^daisy_data_base64_.*=\"\(.*\)\"$/\1/p" "${1:-/dev/stdin}" | base64 -d
|
||||||
data=$(cat "${1:-/dev/stdin}" | grep -v "#")
|
|
||||||
echo -e "$data" | cut -d "=" -f 2- | cut -b 2- | head -c -2 | base64 -d
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_daisy_unalias()
|
_daisy_unalias()
|
||||||
{
|
{
|
||||||
local unalias_param="$1"
|
local unalias_param="$1"
|
||||||
if [[ $unalias_param =~ ^[0-9]+$ ]]; then
|
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
|
fi
|
||||||
if [[ -z "$unalias_param" ]]; then
|
if [[ -z "$unalias_param" ]]; then
|
||||||
return
|
return
|
||||||
|
|
@ -117,49 +119,49 @@ cmd_help()
|
||||||
|
|
||||||
# Match lines defining tools (e.g., "< cdz >" or "< daisy welcome >")
|
# Match lines defining tools (e.g., "< cdz >" or "< daisy welcome >")
|
||||||
$0 ~ /^[[:space:]]*< .* >/ {
|
$0 ~ /^[[:space:]]*< .* >/ {
|
||||||
printing=0 # Stop printing previous tool
|
printing=0 # Stop printing previous tool
|
||||||
|
|
||||||
# Clean the line to get the "signature"
|
# Clean the line to get the "signature"
|
||||||
# "< daisy welcome >" becomes "daisy welcome"
|
# "< daisy welcome >" becomes "daisy welcome"
|
||||||
sig = $0
|
sig = $0
|
||||||
sub(/^[[:space:]]*< /, "", sig)
|
sub(/^[[:space:]]*< /, "", sig)
|
||||||
sub(/ >[[:space:]]*$/, "", sig)
|
sub(/ >[[:space:]]*$/, "", sig)
|
||||||
|
|
||||||
# Check for exact match OR match within a slash/space-separated list
|
# Check for exact match OR match within a slash/space-separated list
|
||||||
split(sig, names, "[ /]")
|
split(sig, names, "[ /]")
|
||||||
|
|
||||||
is_match = 0
|
is_match = 0
|
||||||
if (sig == query) is_match = 1
|
if (sig == query) is_match = 1
|
||||||
else {
|
else {
|
||||||
for (i in names)
|
for (i in names)
|
||||||
{
|
{
|
||||||
if (names[i] == query)
|
if (names[i] == query)
|
||||||
{ is_match = 1; break }
|
{ is_match = 1; break }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_match)
|
if (is_match)
|
||||||
{
|
{
|
||||||
printing=1
|
printing=1
|
||||||
found=1
|
found=1
|
||||||
print $0
|
print $0
|
||||||
next
|
next
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Print description lines if we are in a "found" block
|
# Print description lines if we are in a "found" block
|
||||||
printing {
|
printing {
|
||||||
# Stop if we hit the start of the NEXT tool
|
# Stop if we hit the start of the NEXT tool
|
||||||
if ($0 ~ /^[[:space:]]*< /)
|
if ($0 ~ /^[[:space:]]*< /)
|
||||||
{ printing=0; next }
|
{ printing=0; next }
|
||||||
print
|
print
|
||||||
}
|
}
|
||||||
|
|
||||||
END {
|
END {
|
||||||
if (found == 0)
|
if (found == 0)
|
||||||
{
|
{
|
||||||
print "Tool '"'"'" query "'"'"' not found in README.md."
|
print "Tool '"'"'" query "'"'"' not found in README.md."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
'
|
'
|
||||||
fi
|
fi
|
||||||
|
|
@ -176,9 +178,9 @@ cmd_list()
|
||||||
sed -n '/--- BEGIN OF DAISY HELP ---/,/--- END OF DAISY HELP ---/{//!p;}' "$file" |
|
sed -n '/--- BEGIN OF DAISY HELP ---/,/--- END OF DAISY HELP ---/{//!p;}' "$file" |
|
||||||
awk '
|
awk '
|
||||||
/^[[:space:]]*< / {
|
/^[[:space:]]*< / {
|
||||||
sub(/^[[:space:]]*< /, "");
|
sub(/^[[:space:]]*< /, "");
|
||||||
sub(/ >[[:space:]]*$/, "");
|
sub(/ >[[:space:]]*$/, "");
|
||||||
print " " $0
|
print " " $0
|
||||||
}
|
}
|
||||||
' | sort
|
' | sort
|
||||||
}
|
}
|
||||||
|
|
@ -220,8 +222,8 @@ cmd_dec()
|
||||||
local arg1=$1
|
local arg1=$1
|
||||||
local arg2=$2
|
local arg2=$2
|
||||||
if [ ! -t 0 ]; then
|
if [ ! -t 0 ]; then
|
||||||
arg2=$1
|
arg2=$1
|
||||||
arg1=/dev/stdin
|
arg1=/dev/stdin
|
||||||
fi
|
fi
|
||||||
[[ -t 0 ]] && [[ ! -f "$arg1" ]] && echo "daisy dec multi: No input file specified" && exit 1
|
[[ -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
|
[[ ! -d "$arg2" ]] && echo "daisy dec multi: No output directory specified" && exit 1
|
||||||
|
|
@ -258,9 +260,9 @@ cmd_alias()
|
||||||
local linenum=1
|
local linenum=1
|
||||||
if [[ -f "$LD_ALIASFILE" ]]; then
|
if [[ -f "$LD_ALIASFILE" ]]; then
|
||||||
while IFS= read -r line; do
|
while IFS= read -r line; do
|
||||||
line=$(echo "$line" | sed 's/alias //g')
|
line=$(echo "$line" | sed 's/alias //g')
|
||||||
echo "$linenum: $line"
|
echo "$linenum: $line"
|
||||||
((linenum++))
|
((linenum++))
|
||||||
done < "$LD_ALIASFILE"
|
done < "$LD_ALIASFILE"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
|
@ -321,7 +323,7 @@ cmd_check()
|
||||||
check_bin sed "Stream editing"
|
check_bin sed "Stream editing"
|
||||||
check_bin grep "Pattern matching"
|
check_bin grep "Pattern matching"
|
||||||
check_bin base64 "Data encoding"
|
check_bin base64 "Data encoding"
|
||||||
check_bin realpath "Path resolution"
|
check_bin realpath "Path resolution"
|
||||||
|
|
||||||
echo -e "\n--- Enhanced UI & Navigation ---"
|
echo -e "\n--- Enhanced UI & Navigation ---"
|
||||||
check_bin fzf "Used by cdf"
|
check_bin fzf "Used by cdf"
|
||||||
|
|
@ -398,9 +400,13 @@ daisy ()
|
||||||
dec) shift; cmd_dec "$@" ;;
|
dec) shift; cmd_dec "$@" ;;
|
||||||
alias) shift; cmd_alias "$@" ;;
|
alias) shift; cmd_alias "$@" ;;
|
||||||
unalias) shift; _daisy_unalias "$@" ;;
|
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 ;;
|
clear) shift; cmd_clear ;;
|
||||||
check) shift; cmd_check ;;
|
check) shift; cmd_check ;;
|
||||||
restore) shift; cmd_restore ;;
|
restore) shift; cmd_restore ;;
|
||||||
combine) shift; cmd_combine ;;
|
combine) shift; cmd_combine ;;
|
||||||
editor) shift; cmd_editor "$@" ;;
|
editor) shift; cmd_editor "$@" ;;
|
||||||
|
|
|
||||||
375
daisy.source
375
daisy.source
|
|
@ -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 <lackadaisical-root>/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: <file>
|
|
||||||
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 <cmd>'."
|
|
||||||
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
|
|
||||||
24
editx
24
editx
|
|
@ -3,7 +3,13 @@
|
||||||
# removes the resulting file if it is empty after the editor closes.
|
# removes the resulting file if it is empty after the editor closes.
|
||||||
|
|
||||||
LD_INTERNAL=1
|
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 ]];
|
if [[ -z $1 ]];
|
||||||
then
|
then
|
||||||
|
|
@ -13,7 +19,7 @@ fi
|
||||||
|
|
||||||
if [[ -z "${EDITOR}" ]];
|
if [[ -z "${EDITOR}" ]];
|
||||||
then
|
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."
|
ched "EDITOR env variable not set! You will have to set it yourself in the next screen."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -23,7 +29,7 @@ file_in_path=$(whereis $1 | awk '{print $2}')
|
||||||
path_exist=0
|
path_exist=0
|
||||||
|
|
||||||
[[ -e "$file" ]] && file_exist=1
|
[[ -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
|
if [[ $path_exist == 1 && $file_exist == 0 ]]; then
|
||||||
file=$file_in_path
|
file=$file_in_path
|
||||||
|
|
@ -37,14 +43,14 @@ elif [[ $path_exist == 1 && $file_exist == 1 ]]; then
|
||||||
|
|
||||||
case "$choice" in
|
case "$choice" in
|
||||||
1)
|
1)
|
||||||
file=$file
|
file=$file
|
||||||
;;
|
;;
|
||||||
2|"")
|
2|"")
|
||||||
file="$file_in_path"
|
file="$file_in_path"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
file="$file_in_path"
|
file="$file_in_path"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
2
filewait
2
filewait
|
|
@ -2,7 +2,7 @@
|
||||||
# A simple utility that waits for a file to become available, infinitely
|
# A simple utility that waits for a file to become available, infinitely
|
||||||
|
|
||||||
LD_INTERNAL=1
|
LD_INTERNAL=1
|
||||||
. $(dirname $(realpath $0))/daisy.source
|
. $(dirname $(realpath $0))/ld.source
|
||||||
|
|
||||||
file=$@
|
file=$@
|
||||||
while [ ! -f "$file" ]
|
while [ ! -f "$file" ]
|
||||||
|
|
|
||||||
2
own
2
own
|
|
@ -3,7 +3,7 @@
|
||||||
# user, recursively.
|
# user, recursively.
|
||||||
|
|
||||||
LD_INTERNAL=1
|
LD_INTERNAL=1
|
||||||
. $(dirname $(realpath $0))/daisy.source
|
. $(dirname $(realpath $0))/ld.source
|
||||||
|
|
||||||
if [[ -z "$1" ]]; then
|
if [[ -z "$1" ]]; then
|
||||||
echo "$LD_BIN: Quickly take ownership of files/folders."
|
echo "$LD_BIN: Quickly take ownership of files/folders."
|
||||||
|
|
|
||||||
62
scriptbox
62
scriptbox
|
|
@ -4,7 +4,7 @@
|
||||||
# said script. The idea is similar to `busybox`.
|
# said script. The idea is similar to `busybox`.
|
||||||
|
|
||||||
LD_INTERNAL=1
|
LD_INTERNAL=1
|
||||||
. $(dirname $(realpath $0))/daisy.source
|
. $(dirname $(realpath $0))/ld.source
|
||||||
|
|
||||||
args=$@
|
args=$@
|
||||||
|
|
||||||
|
|
@ -16,9 +16,9 @@ function help()
|
||||||
echo "call the function like so: 'combi-bin input-bin <input-bin args>."
|
echo "call the function like so: 'combi-bin input-bin <input-bin args>."
|
||||||
echo ""
|
echo ""
|
||||||
echo "> Usage:"
|
echo "> Usage:"
|
||||||
echo "Creating boxed binary: $LD_BIN -o <BOXED_BIN> <-s source files> <-p include files verbatim> -i INPUT_BINS ..."
|
echo "Boxing scripts: scriptbox -o <BOXED_BIN> <-s source files>"
|
||||||
echo "<X> Unpacking a boxed binary: $LD_BIN -e <BOXED_BIN>"
|
echo " <-p include files verbatim> -i INPUT_BINS ..."
|
||||||
echo "View this screen: $LD_BIN <noargs>"
|
echo "View help: $LD_BIN <noargs>"
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -63,45 +63,45 @@ while [ $i -lt $# ]; do
|
||||||
-i)
|
-i)
|
||||||
((i++))
|
((i++))
|
||||||
while [ $i -lt $# ] && [[ ! "${args[$i]}" =~ ^- ]]; do
|
while [ $i -lt $# ] && [[ ! "${args[$i]}" =~ ^- ]]; do
|
||||||
file="${args[$i]}"
|
file="${args[$i]}"
|
||||||
((i++))
|
((i++))
|
||||||
if [[ -e "$file" ]]; then
|
if [[ -e "$file" ]]; then
|
||||||
inputs+=("$file")
|
inputs+=("$file")
|
||||||
((b++))
|
((b++))
|
||||||
else
|
else
|
||||||
echo "WARNING: Missing input binary: \"$file\"."
|
echo "WARNING: Missing input binary: \"$file\"."
|
||||||
echo "Module will NOT be available!"
|
echo "Module will NOT be available!"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
continue
|
continue
|
||||||
;;
|
;;
|
||||||
-s)
|
-s)
|
||||||
((i++))
|
((i++))
|
||||||
while [ $i -lt $# ] && [[ ! "${args[$i]}" =~ ^- ]]; do
|
while [ $i -lt $# ] && [[ ! "${args[$i]}" =~ ^- ]]; do
|
||||||
file="${args[$i]}"
|
file="${args[$i]}"
|
||||||
((i++))
|
((i++))
|
||||||
if [[ -e "$file" ]]; then
|
if [[ -e "$file" ]]; then
|
||||||
sources+=("$file")
|
sources+=("$file")
|
||||||
((s++))
|
((s++))
|
||||||
else
|
else
|
||||||
echo "WARNING: Missing input source: \"$file\"."
|
echo "WARNING: Missing input source: \"$file\"."
|
||||||
echo "File will NOT be sourced!"
|
echo "File will NOT be sourced!"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
continue
|
continue
|
||||||
;;
|
;;
|
||||||
-p)
|
-p)
|
||||||
((i++))
|
((i++))
|
||||||
while [ $i -lt $# ] && [[ ! "${args[$i]}" =~ ^- ]]; do
|
while [ $i -lt $# ] && [[ ! "${args[$i]}" =~ ^- ]]; do
|
||||||
file="${args[$i]}"
|
file="${args[$i]}"
|
||||||
((i++))
|
((i++))
|
||||||
if [[ -e "$file" ]]; then
|
if [[ -e "$file" ]]; then
|
||||||
includes+=("$file")
|
includes+=("$file")
|
||||||
((p++))
|
((p++))
|
||||||
else
|
else
|
||||||
echo "WARNING: Missing input include: \"$file\"."
|
echo "WARNING: Missing input include: \"$file\"."
|
||||||
echo "File will NOT be included!"
|
echo "File will NOT be included!"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
continue
|
continue
|
||||||
;;
|
;;
|
||||||
|
|
|
||||||
4
squasher
4
squasher
|
|
@ -147,8 +147,8 @@ case "$COMMAND" in
|
||||||
destroy)
|
destroy)
|
||||||
if [[ ! -f "$DIR/.needs_mount" ]]; then
|
if [[ ! -f "$DIR/.needs_mount" ]]; then
|
||||||
if ! mountpoint -q "$DIR"; then
|
if ! mountpoint -q "$DIR"; then
|
||||||
echo "Error: $DIR is not a SquashFS directory."
|
echo "Error: $DIR is not a SquashFS directory."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
||||||
26
sshp
26
sshp
|
|
@ -13,16 +13,18 @@ usage()
|
||||||
}
|
}
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-m)
|
-m)
|
||||||
if [[ -z "$2" ]]; then echo "Error: -m requires argument"; exit 1; fi
|
if [[ -z "$2" ]]; then
|
||||||
mounts+=("$2")
|
echo "Error: -m requires argument"; exit 1;
|
||||||
shift 2
|
fi
|
||||||
;;
|
mounts+=("$2")
|
||||||
*)
|
shift 2
|
||||||
ssh_args+=("$1")
|
;;
|
||||||
shift
|
*)
|
||||||
;;
|
ssh_args+=("$1")
|
||||||
|
shift
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
@ -48,9 +50,9 @@ done
|
||||||
|
|
||||||
remote_script="
|
remote_script="
|
||||||
if ! command -v sshfs >/dev/null 2>&1; then
|
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
|
else
|
||||||
${mount_logic}
|
${mount_logic}
|
||||||
fi
|
fi
|
||||||
\${SHELL:-bash};
|
\${SHELL:-bash};
|
||||||
${unmount_logic}
|
${unmount_logic}
|
||||||
|
|
|
||||||
2
sw
2
sw
|
|
@ -2,7 +2,7 @@
|
||||||
# It just swaps two files
|
# It just swaps two files
|
||||||
|
|
||||||
LD_INTERNAL1
|
LD_INTERNAL1
|
||||||
. $(dirname $(realpath $0))/daisy.source
|
. $(dirname $(realpath $0))/ld.source
|
||||||
|
|
||||||
file1=$1
|
file1=$1
|
||||||
file2=$2
|
file2=$2
|
||||||
|
|
|
||||||
2
what
2
what
|
|
@ -24,7 +24,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
LD_INTERNAL=1
|
LD_INTERNAL=1
|
||||||
. $(dirname $(realpath $0))/daisy.source
|
. $(dirname $(realpath $0))/ld.source
|
||||||
|
|
||||||
all_bins=$(compgen -c | sort -u)
|
all_bins=$(compgen -c | sort -u)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue