Minor fixes as well as clean-up surrounding internal functions.
This commit is contained in:
parent
405c1e7244
commit
e3a2efdb43
12 changed files with 218 additions and 134 deletions
67
README.md
67
README.md
|
|
@ -57,11 +57,11 @@ These are the included binaries and utilities:
|
||||||
- newday:
|
- newday:
|
||||||
A basic but powerful journaling system. Recommended
|
A basic but powerful journaling system. Recommended
|
||||||
to be set up via crontab. Can be used for everything
|
to be set up via crontab. Can be used for everything
|
||||||
from diaries to general file storage to even BTRFS
|
from diaries to general file storage to even BTRFS
|
||||||
snapshots.
|
snapshots.
|
||||||
- own:
|
- own:
|
||||||
A simple utility. It's effectively an alias for
|
A simple utility. It's effectively an alias for
|
||||||
"sudo chown -R user:user" on the target dir/file.
|
"sudo chown -R user:user" on the target dir/file.
|
||||||
Root permissions required!
|
Root permissions required!
|
||||||
- shrc:
|
- shrc:
|
||||||
This tool allows you to edit the RC file for your
|
This tool allows you to edit the RC file for your
|
||||||
|
|
@ -84,15 +84,15 @@ These are the included binaries and utilities:
|
||||||
a copy with a .bak suffix. Unbak reverses the process
|
a copy with a .bak suffix. Unbak reverses the process
|
||||||
by using sw and removes the backup.
|
by using sw and removes the backup.
|
||||||
- lsa:
|
- lsa:
|
||||||
A simple alias for ls -lah.
|
A simple alias for `ls -lah`.
|
||||||
- lsn:
|
- lsn:
|
||||||
A simple alias for ls -lah --sort=time --reverse.
|
A simple alias for `ls -lah --sort=time --reverse`.
|
||||||
- lss:
|
- lss:
|
||||||
A simple alias for ls -lah --sort=size --reverse.
|
A simple alias for `ls -lah --sort=size --reverse`.
|
||||||
- editbin:
|
- editbin:
|
||||||
An alias for editx $\(which <x>\). Saves on typing.
|
An alias for `editx $\(which <x>\)`. Saves on typing.
|
||||||
- editpeco:
|
- editpeco:
|
||||||
This function uses peco+tree like 'cdp', but opens
|
This function uses peco+tree like `cdp`, but opens
|
||||||
your editor on the selected file(s). After you exit
|
your editor on the selected file(s). After you exit
|
||||||
your editor(s), you are returned to peco where you left
|
your editor(s), you are returned to peco where you left
|
||||||
off.
|
off.
|
||||||
|
|
@ -103,37 +103,56 @@ These are the included binaries and utilities:
|
||||||
- cdf:
|
- cdf:
|
||||||
Use fzf to find a file and then cd to its location.
|
Use fzf to find a file and then cd to its location.
|
||||||
- cdp:
|
- cdp:
|
||||||
Similar to 'cdf' but uses tree+peco for the query.
|
Similar to `cdf` but uses tree+peco for the query.
|
||||||
- ldrc:
|
- ldrc:
|
||||||
Edits daisy.source and re-sources it, similarly to shrc.
|
Edits daisy.source and re-sources it, similarly to shrc.
|
||||||
- daisy_init:
|
- daisy_reload:
|
||||||
Alias for directly sourcing this file from any
|
Re-sources daisy.source. Essentially `ldrc` without
|
||||||
LACKADAISICAL binary. You may use this yourself.
|
editing.
|
||||||
- grab:
|
- grab:
|
||||||
Alias for "awk '{print $x}'", where x is a number.
|
Alias for `awk '{print $x}'`, where x is a number.
|
||||||
E.g. "echo 'a b c' | grab 2" returns 'b'.
|
E.g. `echo 'a b c' | grab 2` returns 'b'.
|
||||||
- daisy_cbin:
|
- daisy_cbin:
|
||||||
Contains the name of the current LACKADAISICAL
|
Contains the name of the current LACKADAISICAL
|
||||||
binary being run.
|
binary being run.
|
||||||
- daisy_enc:
|
- daisy_enc:
|
||||||
Converts a file/stdin to a base64 block that can be
|
Converts a file/stdin to a base64 block that can be
|
||||||
decoded by passing the output(s) to daisy_dec.
|
decoded by passing the output(s) to `daisy_dec`.
|
||||||
|
The output of `daisy_enc` can be concatenated with the
|
||||||
|
output of another encoded file to create a multi-file
|
||||||
|
base64 archive similar to `daisy_enc_multi`
|
||||||
- daisy_enc_multi:
|
- daisy_enc_multi:
|
||||||
A version of daisy_enc that encodes multiple
|
A version of `daisy_enc` that encodes multiple
|
||||||
files and outputs daisy_base64_data blocks to a file
|
files and outputs `daisy_base64_data` blocks to a file
|
||||||
or stdout.
|
or stdout. These outputs can be concatenated as well.
|
||||||
- daisy_dec:
|
- daisy_dec:
|
||||||
Converts daisy_base64_data blocks back to the form
|
Converts `daisy_base64_data` blocks back to the form
|
||||||
it was in originally.
|
it was in originally.
|
||||||
- daisy_dec_multi:
|
- daisy_dec_multi:
|
||||||
A version of daisy_dec that runs on multiple input
|
A version of daisy_dec that runs on multiple input
|
||||||
blocks that are either stored in a file or stdin.
|
blocks that are either stored in a file or stdin.
|
||||||
- daisy_alias/daisy_unalias:
|
- daisy_alias:
|
||||||
This utility sets persistent user aliases stored in
|
This utility sets persistent user aliases stored in
|
||||||
.daisy_aliases in the lackadaisical config folder.
|
"~/.config/lackadaisical/aliases.src".
|
||||||
They will remain persistent until unaliased.
|
They will remain persistent until unaliased with
|
||||||
Call 'daisy_alias' without parameters to get a list.
|
daisy_unalias.
|
||||||
Use 'daisy_unalias' to remove an alias.
|
Call daisy_alias using '' instead of "".
|
||||||
|
E.g. `daisy_alias hello='echo "Hello!"' - instead of
|
||||||
|
`daisy_alias hello="echo \"Hello!\"".
|
||||||
|
This prevents an early invocation of possible nested
|
||||||
|
aliases.
|
||||||
|
Call this function without arguments to get a list of
|
||||||
|
registered aliases as well as indices for easy unaliasing
|
||||||
|
using `daisy_unalias`.
|
||||||
|
- daisy_unalias:
|
||||||
|
This utility removes an alias from those registered with
|
||||||
|
daisy_alias. It accepts either an alias name, or an index
|
||||||
|
given by calling `daisy_alias` without arguments.
|
||||||
|
In case of a mistake, a backup is made under the filename
|
||||||
|
"~/.config/lackadaisical/aliases.src.bak".
|
||||||
|
To restore this file, you can use these commands:
|
||||||
|
`unbak ~/.config/lackadaisical/aliases.src'
|
||||||
|
`daisy_reload`
|
||||||
- daisy_list:
|
- daisy_list:
|
||||||
List all available commands without description.
|
List all available commands without description.
|
||||||
--- END OF DAISY HELP ---
|
--- END OF DAISY HELP ---
|
||||||
|
|
|
||||||
10
binbox
10
binbox
|
|
@ -3,21 +3,21 @@
|
||||||
# Symlinking to the resulting binary with the name of one of the original scripts will trigger
|
# Symlinking to the resulting binary with the name of one of the original scripts will trigger
|
||||||
# said script. The idea is similar to `busybox`.
|
# said script. The idea is similar to `busybox`.
|
||||||
|
|
||||||
DAISY_INTERNAL=1
|
LD_INTERNAL=1
|
||||||
. $(dirname $(realpath $0))/daisy.source
|
. $(dirname $(realpath $0))/daisy.source
|
||||||
|
|
||||||
args=$@
|
args=$@
|
||||||
|
|
||||||
function help()
|
function help()
|
||||||
{
|
{
|
||||||
echo "$DAISY_BIN is a utility that allows you to generate busybox-style combined binaries."
|
echo "$LD_BIN is a utility that allows you to generate busybox-style combined binaries."
|
||||||
echo "To access the original functionality of an input binary, you can either use a symlink or"
|
echo "To access the original functionality of an input binary, you can either use a symlink or"
|
||||||
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: $DAISY_BIN -o <BOXED_BIN> <-s source files> <-p include files verbatim> -i INPUT_BINS ..."
|
echo "Creating boxed binary: $LD_BIN -o <BOXED_BIN> <-s source files> <-p include files verbatim> -i INPUT_BINS ..."
|
||||||
echo "<X> Unpacking a boxed binary: $DAISY_BIN -e <BOXED_BIN>"
|
echo "<X> Unpacking a boxed binary: $LD_BIN -e <BOXED_BIN>"
|
||||||
echo "View this screen: $DAISY_BIN <noargs>"
|
echo "View this screen: $LD_BIN <noargs>"
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
2
calm
2
calm
|
|
@ -8,7 +8,7 @@
|
||||||
# set's NICE value to 0
|
# set's NICE value to 0
|
||||||
# need sudo
|
# need sudo
|
||||||
|
|
||||||
DAISY_INTERNAL=1
|
LD_INTERNAL=1
|
||||||
. $(dirname $(realpath $0))/daisy.source
|
. $(dirname $(realpath $0))/daisy.source
|
||||||
|
|
||||||
pids=$@
|
pids=$@
|
||||||
|
|
|
||||||
4
cdz
4
cdz
|
|
@ -1,8 +1,8 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
if [[ $DAISY_INTERNAL -ne 1 ]];
|
if [[ $LD_INTERNAL -ne 1 ]];
|
||||||
then
|
then
|
||||||
export DAISY_INTERNAL=1
|
export LD_INTERNAL=1
|
||||||
. $(dirname $(realpath $0))/daisy.source
|
. $(dirname $(realpath $0))/daisy.source
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
||||||
243
daisy.source
243
daisy.source
|
|
@ -9,11 +9,11 @@
|
||||||
# This file is also sourced in some of the scripts included within
|
# This file is also sourced in some of the scripts included within
|
||||||
# lackadaisical for common functionality. Some of the shared functionality is
|
# lackadaisical for common functionality. Some of the shared functionality is
|
||||||
# only included if sourced from one of the included scripts, though you are
|
# only included if sourced from one of the included scripts, though you are
|
||||||
# free to bypass this by setting env variable DAISY_INTERNAL to 1.
|
# free to bypass this by setting env variable LD_INTERNAL to 1.
|
||||||
|
|
||||||
if [[ $DAISY_INTERNAL -eq 1 ]];
|
if [[ $LD_INTERNAL -eq 1 ]];
|
||||||
then
|
then
|
||||||
export DAISY_BIN=$(basename $0)
|
export LD_BIN=$(basename $0)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Variables for use in other utilities
|
# Variables for use in other utilities
|
||||||
|
|
@ -32,47 +32,54 @@ function daisy_dependency_check
|
||||||
echo $(($res ^ 1))
|
echo $(($res ^ 1))
|
||||||
}
|
}
|
||||||
|
|
||||||
DAISY_HAS_fzf=$(daisy_dependency_check fzf)
|
LD_HAS_fzf=$(daisy_dependency_check fzf)
|
||||||
DAISY_HAS_md5sum=$(daisy_dependency_check md5sum)
|
LD_HAS_md5sum=$(daisy_dependency_check md5sum)
|
||||||
DAISY_HAS_peco=$(daisy_dependency_check peco)
|
LD_HAS_peco=$(daisy_dependency_check peco)
|
||||||
DAISY_HAS_tree=$(daisy_dependency_check tree)
|
LD_HAS_tree=$(daisy_dependency_check tree)
|
||||||
|
|
||||||
export DAISY_FOLDER=$(dirname $(realpath $arg))
|
export LD_FOLDER=$(dirname $(realpath $arg))
|
||||||
export DAISY_SOURCE_FILE=$(realpath $arg)
|
export LD_SOURCE_FILE=$(realpath $arg)
|
||||||
export DAISY_AVAILABLE=0
|
export LD_AVAILABLE=0
|
||||||
|
|
||||||
# Config folder setup
|
# Config folder setup
|
||||||
export DAISY_CONFIG_FOLDER="$HOME/.config/lackadaisical"
|
export LD_CONFIG_FOLDER="$HOME/.config/lackadaisical"
|
||||||
new_install=0
|
new_install=0
|
||||||
|
|
||||||
if [[ ! -d "$DAISY_CONFIG_FOLDER" ]];
|
if [[ ! -d "$LD_CONFIG_FOLDER" ]];
|
||||||
then
|
then
|
||||||
# Create the folder with its basics
|
# Create the folder with its basics
|
||||||
mkdir -p "$DAISY_CONFIG_FOLDER"
|
mkdir -p "$LD_CONFIG_FOLDER"
|
||||||
daisy_help
|
daisy_help
|
||||||
new_install=1
|
new_install=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Functions for aliases that are added once, but always available
|
# Multiple default source files
|
||||||
DAISY_ALIASFILE="$DAISY_CONFIG_FOLDER"/.daisy_aliases
|
# [LEA.TODO] Turn these into arrays
|
||||||
touch $DAISY_ALIASFILE
|
LD_ALIASFILE="$LD_CONFIG_FOLDER/aliases.src"
|
||||||
|
LD_EDITORFILE="$LD_CONFIG_FOLDER/editor.src"
|
||||||
|
touch $LD_ALIASFILE
|
||||||
|
touch $LD_EDITORFILE
|
||||||
|
|
||||||
# Source everything in the config folder
|
# Source everything in the config folder
|
||||||
for f in "$DAISY_CONFIG_FOLDER"; do
|
function _daisy_source_configs
|
||||||
[ -f "$file" ] && source "$f"
|
{
|
||||||
done
|
for f in `find "$LD_CONFIG_FOLDER" -name "*.src" -type f`;
|
||||||
|
do
|
||||||
|
source "$f"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
# Installation into PATH
|
# Installation into PATH
|
||||||
if [[ ! $PATH == *"$DAISY_FOLDER"* ]];
|
if [[ ! $PATH == *"$LD_FOLDER"* ]];
|
||||||
then
|
then
|
||||||
export PATH="$PATH:$DAISY_FOLDER"
|
export PATH="$PATH:$LD_FOLDER"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Set up the basic alias for `shrc`
|
# Set up the basic alias for `shrc`
|
||||||
# Do not set these up if DAISY_INTERNAL=1 is set, or infinite recursion could
|
# Do not set these up if LD_INTERNAL=1 is set, or infinite recursion could
|
||||||
# occur!
|
# occur!
|
||||||
if [[ ! -v DAISY_INTERNAL ]];
|
if [[ ! -v LD_INTERNAL ]];
|
||||||
then
|
then
|
||||||
alias shrc=". shrc"
|
alias shrc=". shrc"
|
||||||
fi
|
fi
|
||||||
|
|
@ -114,12 +121,17 @@ alias lss="ls -a -l -S -r -h"
|
||||||
# Simple version of `cdf`
|
# Simple version of `cdf`
|
||||||
function cdf
|
function cdf
|
||||||
{
|
{
|
||||||
|
if [[ $LD_HAS_fzf != 1 ]];
|
||||||
|
then
|
||||||
|
echo "This alias requires the utility 'fzf'. Please install it."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
cd $(dirname $(fzf))
|
cd $(dirname $(fzf))
|
||||||
}
|
}
|
||||||
|
|
||||||
function cdp
|
function cdp
|
||||||
{
|
{
|
||||||
if [[ $DAISY_HAS_peco != 1 || $DAISY_HAS_tree != 1 ]];
|
if [[ $LD_HAS_peco != 1 || $LD_HAS_tree != 1 ]];
|
||||||
then
|
then
|
||||||
echo "This alias requires the utilities 'peco' and 'tree'. Please install them."
|
echo "This alias requires the utilities 'peco' and 'tree'. Please install them."
|
||||||
echo "Consider using 'cdf' instead."
|
echo "Consider using 'cdf' instead."
|
||||||
|
|
@ -130,12 +142,12 @@ function cdp
|
||||||
|
|
||||||
function editpeco
|
function editpeco
|
||||||
{
|
{
|
||||||
if [[ $DAISY_HAS_peco != 1 ]];
|
if [[ $LD_HAS_peco != 1 || $LD_HAS_tree != 1 ]];
|
||||||
then
|
then
|
||||||
echo "This alias requires the utility 'peco'. Please install it."
|
echo "This alias requires the utilities 'peco' and 'tree'. Please install them."
|
||||||
|
echo "Consider using 'cdf' instead."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
tree --noreport -fia . | peco --prompt "Press CTRL+C to quit - query:" --exec "xargs -o -I{} $EDITOR {}"
|
tree --noreport -fia . | peco --prompt "Press CTRL+C to quit - query:" --exec "xargs -o -I{} $EDITOR {}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -155,7 +167,7 @@ function ched
|
||||||
available_editors=()
|
available_editors=()
|
||||||
for editor in "${editors[@]}";
|
for editor in "${editors[@]}";
|
||||||
do
|
do
|
||||||
editor_real=$(command -v "$editor")
|
editor_real=$(command -v "$editor")
|
||||||
if command -v "$editor_real" >/dev/null 2>&1;
|
if command -v "$editor_real" >/dev/null 2>&1;
|
||||||
then
|
then
|
||||||
if [[ $(realpath "$EDITOR") == "$editor_real" ]];
|
if [[ $(realpath "$EDITOR") == "$editor_real" ]];
|
||||||
|
|
@ -174,7 +186,7 @@ function ched
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Present all choices
|
# Present all choices
|
||||||
choice=$(dialog --output-fd 1 --clear --title "Select Text Editor (Recommendation: nano)" \
|
choice=$(dialog --output-fd 1 --clear --title "Select Text Editor" \
|
||||||
--menu "Choose one of the installed text editors:" 15 50 6 \
|
--menu "Choose one of the installed text editors:" 15 50 6 \
|
||||||
"${available_editors[@]}")
|
"${available_editors[@]}")
|
||||||
dialog_ret=$?
|
dialog_ret=$?
|
||||||
|
|
@ -185,12 +197,11 @@ function ched
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo export EDITOR=$choice > "$DAISY_CONFIG_FOLDER/editor.src"
|
echo export EDITOR=$choice > "$LD_EDITORFILE"
|
||||||
echo export DAISY_EDITOR=$choice >> "$DAISY_CONFIG_FOLDER/editor.src"
|
echo export LD_EDITOR=$choice >> "$LD_EDITORFILE"
|
||||||
echo export DAISY_OLD_EDITOR=$EDITOR >> "$DAISY_CONFIG_FOLDER/editor.src"
|
echo export LD_OLD_EDITOR=$EDITOR >>"$LD_EDITORFILE"
|
||||||
|
|
||||||
# Seems silly but this is also where we should export these
|
_daisy_source_configs
|
||||||
source "$DAISY_CONFIG_FOLDER/editor.src"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function wait_for_editor
|
function wait_for_editor
|
||||||
|
|
@ -212,44 +223,60 @@ function wait_for_editor
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function daisy_reload
|
||||||
|
{
|
||||||
|
FROM_RC=0 source "$LD_SOURCE_FILE"
|
||||||
|
}
|
||||||
|
|
||||||
function ldrc
|
function ldrc
|
||||||
{
|
{
|
||||||
FROM_RC=0 $EDITOR "$DAISY_SOURCE_FILE"
|
$EDITOR "$LD_SOURCE_FILE"
|
||||||
source "$DAISY_SOURCE_FILE"
|
FROM_RC=0 source "$LD_SOURCE_FILE"
|
||||||
}
|
}
|
||||||
|
|
||||||
function daisy_enc
|
function daisy_enc
|
||||||
{
|
{
|
||||||
has_file=$([[ ! -z $1 ]] && file $1 1>/dev/null; echo $?)
|
if [ -d $1 ];
|
||||||
has_file=$([[ has_file -eq 0 ]] && echo 1)
|
|
||||||
file_info="no data"
|
|
||||||
file_name="null"
|
|
||||||
if [[ has_file -eq 1 ]];
|
|
||||||
then
|
then
|
||||||
|
echo -e "daisy_create_folder=$1"
|
||||||
|
else
|
||||||
file_info=$(file $1)
|
file_info=$(file $1)
|
||||||
|
file_dir=$(dirname $1)
|
||||||
file_name=$(basename $1)
|
file_name=$(basename $1)
|
||||||
|
|
||||||
|
base64_inner=$(cat ${1:-/dev/stdin} | base64 | tr -d '\n')
|
||||||
|
|
||||||
|
# Print out our block
|
||||||
|
echo -e "daisy_folder_$file_name=$file_dir"
|
||||||
|
echo -e "daisy_data_base64_$file_name=\"$base64_inner\""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
base64_inner=$(cat ${1:-/dev/stdin} | base64 | tr -d '\n')
|
|
||||||
|
|
||||||
# Print out our block
|
|
||||||
echo -e "# File info: $file_info"
|
|
||||||
echo -e "daisy_data_base64_$file_name=\"$base64_inner\""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Will only take input files, always outputs to stdout
|
# Will only take input files, always outputs to stdout
|
||||||
function daisy_enc_multi
|
function daisy_enc_multi
|
||||||
{
|
{
|
||||||
for file in "$@"; do
|
for file in "$@"; do
|
||||||
if [[ -f "$file" ]]; then
|
daisy_enc "$file"
|
||||||
daisy_enc "$file"
|
|
||||||
echo # separate blocks with a newline
|
|
||||||
else
|
|
||||||
echo "daisy_enc_multi: Skipping non-file: $file"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function daisy_enc_folder
|
||||||
|
{
|
||||||
|
if [[ $LD_HAS_tree != 1 ]];
|
||||||
|
then
|
||||||
|
echo "This function requires the utiliy 'tree'. Please install it."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
dir="$1"
|
||||||
|
cd "$dir"
|
||||||
|
tree -fia --noreport . | sed 1d | while read -r item;
|
||||||
|
do
|
||||||
|
daisy_enc "$item"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function daisy_dec
|
function daisy_dec
|
||||||
{
|
{
|
||||||
data=$(cat ${1:-/dev/stdin} | grep -v "#" )
|
data=$(cat ${1:-/dev/stdin} | grep -v "#" )
|
||||||
|
|
@ -262,16 +289,28 @@ function daisy_dec_multi
|
||||||
{
|
{
|
||||||
[[ ! -f $1 ]] && echo "daisy_dec_multi: No input file specified" && return
|
[[ ! -f $1 ]] && echo "daisy_dec_multi: No input file specified" && return
|
||||||
[[ ! -d $2 ]] && echo "daisy_dec_multi: No output directory specified" && return
|
[[ ! -d $2 ]] && echo "daisy_dec_multi: No output directory specified" && return
|
||||||
declare -a vars=( $(cat $1 | grep -v "# File") )
|
|
||||||
for enc in "${vars[@]}";
|
|
||||||
do
|
|
||||||
file=$(echo -e "$enc" | cut -d "_" -f 4- | cut -d "=" -f 1)
|
|
||||||
|
|
||||||
if [[ ! "$file" == '' ]]
|
folder=
|
||||||
then
|
while IFS= read -r line; do
|
||||||
daisy_dec <(echo "$enc") > "$2"/"$file"
|
if [[ "$line" == "daisy_create_folder="* ]];
|
||||||
fi
|
then
|
||||||
done
|
folder=$(echo $line | cut -d "=" -f 2)
|
||||||
|
mkdir -p "$2/$folder"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$line" == "daisy_folder"* ]];
|
||||||
|
then
|
||||||
|
folder=$(echo -e $line | cut -d "=" -f 2)
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$line" == "daisy_data_base64"* ]];
|
||||||
|
then
|
||||||
|
file=$(echo -e $line | cut -d "_" -f 4- | cut -d "=" -f 1)
|
||||||
|
daisy_dec <(echo $line) > "$2/$folder/$file"
|
||||||
|
fi
|
||||||
|
|
||||||
|
done <<< $(cat "$1")
|
||||||
}
|
}
|
||||||
|
|
||||||
# Saves a bit on typing
|
# Saves a bit on typing
|
||||||
|
|
@ -285,6 +324,12 @@ function daisy_unalias
|
||||||
{
|
{
|
||||||
unalias_param=$@
|
unalias_param=$@
|
||||||
|
|
||||||
|
if [[ $unalias_param =~ '^[0-9]+$' ]]; then
|
||||||
|
selection=$(head -$unalias_param "$LD_ALIASFILE" | tail -1 | cut -d "=" -f 1 | grab 2)
|
||||||
|
daisy_unalias $selection
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -z $unalias_param ]]; then
|
if [[ -z $unalias_param ]]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
@ -292,8 +337,9 @@ function daisy_unalias
|
||||||
unalias $@ 2>/dev/null
|
unalias $@ 2>/dev/null
|
||||||
|
|
||||||
# Remove from aliases list
|
# Remove from aliases list
|
||||||
newdata=$(cat $DAISY_ALIASFILE | grep -v "alias $unalias_param")
|
newdata=$(cat "$LD_ALIASFILE" | grep -v "alias $unalias_param")
|
||||||
echo -e $newdata > $DAISY_ALIASFILE
|
bak "$LD_ALIASFILE" 1>/dev/null
|
||||||
|
echo -e $newdata > "$LD_ALIASFILE"
|
||||||
}
|
}
|
||||||
|
|
||||||
function daisy_alias
|
function daisy_alias
|
||||||
|
|
@ -301,31 +347,38 @@ function daisy_alias
|
||||||
alias_param="$@"
|
alias_param="$@"
|
||||||
|
|
||||||
if [[ -z $alias_param ]]; then
|
if [[ -z $alias_param ]]; then
|
||||||
|
linenum=1
|
||||||
echo "Active lackadaisical alias lines:"
|
echo "Active lackadaisical alias lines:"
|
||||||
cat $DAISY_ALIASFILE | sed 's/alias //g'
|
while IFS= read -r line; do
|
||||||
|
line=$(echo "$line" | sed 's/alias / /g')
|
||||||
|
echo "$linenum: $line"
|
||||||
|
linenum=$(($linenum + 1))
|
||||||
|
done < "$LD_ALIASFILE"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Plain name and contents
|
# Plain name and contents
|
||||||
alias_name=$(echo -e $alias_param | grep -o ".*=" | tr --delete =)
|
alias_name=$(echo -e $alias_param | grep -o ".*=" | tr --delete =)
|
||||||
|
|
||||||
|
if [[ $alias_name =~ '^[0-9]+$' ]]; then
|
||||||
|
echo "An alias cannot start with a number! Exiting."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Make persistent
|
# Make persistent
|
||||||
daisy_unalias $alias_name
|
daisy_unalias $alias_name
|
||||||
echo alias ${alias_param%=*}"="\"${alias_param#*=}\" >> $DAISY_ALIASFILE
|
echo alias ${alias_param%=*}"="\"${alias_param#*=}\" >> $LD_ALIASFILE
|
||||||
|
source $LD_ALIASFILE
|
||||||
alias $alias_param
|
|
||||||
}
|
}
|
||||||
|
|
||||||
source $DAISY_ALIASFILE
|
_daisy_source_configs
|
||||||
|
|
||||||
alias daisy_init='source "$DAISY_SOURCE_FILE"'
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# end of FUNCTIONS and ALIASES ################################################
|
# end of FUNCTIONS and ALIASES ################################################
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
# End of user section!
|
# End of user section!
|
||||||
export DAISY_AVAILABLE=1
|
export LD_AVAILABLE=1
|
||||||
|
|
||||||
# Start of internal section
|
# Start of internal section
|
||||||
function daisy_quit_if_no
|
function daisy_quit_if_no
|
||||||
|
|
@ -343,28 +396,27 @@ function daisy_quit_if_no
|
||||||
|
|
||||||
if [[ $has_dep -eq 0 ]];
|
if [[ $has_dep -eq 0 ]];
|
||||||
then
|
then
|
||||||
echo "$DAISY_BIN: The dependency $1 was not found! Please install it" \
|
echo "$LD_BIN: The dependency $1 was not found! Please install it" \
|
||||||
"to be able to use this utility!"
|
"to be able to use this utility!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
[ -d "$DAISY_FOLDER" ] && export DAISY_AVAILABLE=1
|
[ -d "$LD_FOLDER" ] && export LD_AVAILABLE=1
|
||||||
|
|
||||||
# Help function, courtesy of Google Gemini
|
# Help function, courtesy of Google Gemini
|
||||||
function daisy_help() {
|
function daisy_help() {
|
||||||
local target_tool="$1"
|
local target_tool="$1"
|
||||||
local file="$DAISY_FOLDER/README.md"
|
local file="$LD_FOLDER/README.md"
|
||||||
|
|
||||||
# 1. Extract the block between the new headers
|
|
||||||
sed -n '/--- BEGIN OF DAISY HELP ---/,/--- END OF DAISY HELP ---/{//!p;}' "$file" | \
|
|
||||||
|
|
||||||
|
# 1. Extract the block between the new headers
|
||||||
|
sed -n '/--- BEGIN OF DAISY HELP ---/,/--- END OF DAISY HELP ---/{//!p;}' "$file" |
|
||||||
if [ -z "$target_tool" ]; then
|
if [ -z "$target_tool" ]; then
|
||||||
# If no argument, print the whole help text
|
# If no argument, print the whole help text
|
||||||
cat
|
cat
|
||||||
else
|
else
|
||||||
# 2. Parse specific tool
|
# 2. Parse specific tool
|
||||||
awk -v query="$target_tool" '
|
awk -v query="$target_tool" '
|
||||||
BEGIN { found=0; printing=0 }
|
BEGIN { found=0; printing=0 }
|
||||||
|
|
||||||
# Match lines defining tools (e.g., " - calm:" or " - bak/unbak:")
|
# Match lines defining tools (e.g., " - calm:" or " - bak/unbak:")
|
||||||
|
|
@ -415,18 +467,31 @@ function daisy_help() {
|
||||||
|
|
||||||
# Courtesy of Google Gemini
|
# Courtesy of Google Gemini
|
||||||
daisy_list() {
|
daisy_list() {
|
||||||
local file="$DAISY_FOLDER/README.md"
|
local file="$LD_FOLDER/README.md"
|
||||||
echo "Available LACKADAISICAL commands:"
|
echo "Available LACKADAISICAL commands:"
|
||||||
|
|
||||||
# Extract block -> Find tool lines -> Clean formatting -> Print
|
# Extract block -> Find tool lines -> Clean formatting -> Print
|
||||||
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:]]*- / {
|
||||||
# Remove indentation and "- "
|
# Remove indentation and "- "
|
||||||
sub(/^[[:space:]]*- /, "");
|
sub(/^[[:space:]]*- /, "");
|
||||||
# Remove trailing ":"
|
# Remove trailing ":"
|
||||||
sub(/:[[:space:]]*$/, "");
|
sub(/:[[:space:]]*$/, "");
|
||||||
print " " $0
|
print " " $0
|
||||||
}
|
}
|
||||||
' | sort
|
' | sort
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Hide what we don't need
|
||||||
|
if [[ ! -v LD_INTERNAL ]];
|
||||||
|
then
|
||||||
|
unset -f _daisy_source_configs
|
||||||
|
unset -f wait_for_editor
|
||||||
|
unset -f daisy_quit_if_no
|
||||||
|
unset -f daisy_dependency_check
|
||||||
|
unset LD_HAS_fzf
|
||||||
|
unset LD_HAS_peco
|
||||||
|
unset LD_HAS_md5sum
|
||||||
|
unset LD_HAS_tree
|
||||||
|
fi
|
||||||
2
editx
2
editx
|
|
@ -2,7 +2,7 @@
|
||||||
# This utility pre-allocs a file and adds execution permissions. It also
|
# This utility pre-allocs a file and adds execution permissions. It also
|
||||||
# removes the resulting file if it is empty after the editor closes.
|
# removes the resulting file if it is empty after the editor closes.
|
||||||
|
|
||||||
DAISY_INTERNAL=1
|
LD_INTERNAL=1
|
||||||
. $(dirname $(realpath $0))/daisy.source
|
. $(dirname $(realpath $0))/daisy.source
|
||||||
|
|
||||||
if [[ -z $1 ]];
|
if [[ -z $1 ]];
|
||||||
|
|
|
||||||
2
filewait
2
filewait
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# A simple utility that waits for a file to become available, infinitely
|
# A simple utility that waits for a file to become available, infinitely
|
||||||
|
|
||||||
DAISY_INTERNAL=1
|
LD_INTERNAL=1
|
||||||
. $(dirname $(realpath $0))/daisy.source
|
. $(dirname $(realpath $0))/daisy.source
|
||||||
|
|
||||||
file=$@
|
file=$@
|
||||||
|
|
|
||||||
4
newday
4
newday
|
|
@ -14,7 +14,7 @@
|
||||||
# You can use this for a primitive form of note-taking, but aside from notes -
|
# You can use this for a primitive form of note-taking, but aside from notes -
|
||||||
# you can store any data this way.
|
# you can store any data this way.
|
||||||
|
|
||||||
DAISY_INTERNAL=1
|
LD_INTERNAL=1
|
||||||
. $(dirname $(realpath $0))/daisy.source
|
. $(dirname $(realpath $0))/daisy.source
|
||||||
|
|
||||||
dir_name=ByDate
|
dir_name=ByDate
|
||||||
|
|
@ -34,7 +34,7 @@ function errorFn()
|
||||||
error=$?
|
error=$?
|
||||||
if [[ $error -gt 0 ]];
|
if [[ $error -gt 0 ]];
|
||||||
then
|
then
|
||||||
echo "$DAISY_BIN error ($error): "
|
echo "$LD_BIN error ($error): "
|
||||||
perl -E 'say $!=shift' $error
|
perl -E 'say $!=shift' $error
|
||||||
fi
|
fi
|
||||||
exit $error
|
exit $error
|
||||||
|
|
|
||||||
6
own
6
own
|
|
@ -2,14 +2,14 @@
|
||||||
# Simple program that changes ownership to the current
|
# Simple program that changes ownership to the current
|
||||||
# user, recursively.
|
# user, recursively.
|
||||||
|
|
||||||
DAISY_INTERNAL=1
|
LD_INTERNAL=1
|
||||||
. $(dirname $(realpath $0))/daisy.source
|
. $(dirname $(realpath $0))/daisy.source
|
||||||
|
|
||||||
if [[ $@ == '' ]];
|
if [[ $@ == '' ]];
|
||||||
then
|
then
|
||||||
echo "$DAISY_BIN: Used to quickly take ownership of files/folders."
|
echo "$LD_BIN: Used to quickly take ownership of files/folders."
|
||||||
echo "Requires sudo. If sudo is not installed, this tool will fai."
|
echo "Requires sudo. If sudo is not installed, this tool will fai."
|
||||||
echo "Usage: $DAISY_BIN <folders or files>"
|
echo "Usage: $LD_BIN <folders or files>"
|
||||||
echo "Means: chown -R <youruser>:<youruser> <folders or files>"
|
echo "Means: chown -R <youruser>:<youruser> <folders or files>"
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
4
shrc
4
shrc
|
|
@ -5,9 +5,9 @@
|
||||||
# and sources the .rc afterwards!
|
# and sources the .rc afterwards!
|
||||||
|
|
||||||
# Source standard setup
|
# Source standard setup
|
||||||
if [[ $DAISY_INTERNAL -ne 1 ]];
|
if [[ $LD_INTERNAL -ne 1 ]];
|
||||||
then
|
then
|
||||||
DAISY_INTERNAL=1 source $DAISY_SOURCE_FILE
|
LD_INTERNAL=1 source $LD_SOURCE_FILE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function md5_opt()
|
function md5_opt()
|
||||||
|
|
|
||||||
6
sw
6
sw
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# It just swaps two files
|
# It just swaps two files
|
||||||
|
|
||||||
export DAISY_INTERNAL1
|
export LD_INTERNAL1
|
||||||
. $(dirname $(realpath $0))/daisy.source
|
. $(dirname $(realpath $0))/daisy.source
|
||||||
|
|
||||||
file1=$1
|
file1=$1
|
||||||
|
|
@ -13,9 +13,9 @@ function helpFn()
|
||||||
if [[ $error -gt 0 ]];
|
if [[ $error -gt 0 ]];
|
||||||
then
|
then
|
||||||
error_text=$(perl -E 'say $!=shift' $error)
|
error_text=$(perl -E 'say $!=shift' $error)
|
||||||
echo "$DAISY_BIN error ($error): $error_text"
|
echo "$LD_BIN error ($error): $error_text"
|
||||||
fi
|
fi
|
||||||
echo "Usage: $DAISY_BIN <file1> <file2>"
|
echo "Usage: $LD_BIN <file1> <file2>"
|
||||||
echo Swap two files in a filesystem.
|
echo Swap two files in a filesystem.
|
||||||
exit $error
|
exit $error
|
||||||
}
|
}
|
||||||
|
|
|
||||||
2
what
2
what
|
|
@ -23,7 +23,7 @@
|
||||||
# /usr/sbin/vsftpd
|
# /usr/sbin/vsftpd
|
||||||
#
|
#
|
||||||
|
|
||||||
DAISY_INTERNAL=1
|
LD_INTERNAL=1
|
||||||
. $(dirname $(realpath $0))/daisy.source
|
. $(dirname $(realpath $0))/daisy.source
|
||||||
|
|
||||||
pwd=/
|
pwd=/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue