Complete overhaul of how daisy core tools are called, as well as changes to the help system
This commit is contained in:
parent
74ed7582f9
commit
3fa3daacba
9 changed files with 1263 additions and 682 deletions
486
README.md
486
README.md
|
|
@ -17,211 +17,287 @@ At first use, `lackadaisical` will provide you with information via `daisy_help`
|
|||
|
||||
## Getting started
|
||||
```
|
||||
--- BEGIN OF DAISY HELP ---
|
||||
===============================================================================
|
||||
Thanks for installing LACKADAISICAL!
|
||||
This project aims to provide useful utilities as well as learning material.
|
||||
|
||||
It is still under heavy development, not all of the things on this
|
||||
list are present/implemented. Utils marked with * are incomplete.
|
||||
|
||||
This suite provides a number of functions, aliases and scripts.
|
||||
They are all aimed at enhancing your efficiency.
|
||||
|
||||
To uninstall LACKADAISICAL, simply remove the source line from your
|
||||
shell RC, and reload it. This does not remove the files!
|
||||
You will also need to manually clear the configuration data in '<home>/.config/
|
||||
lackadaisical` if you so desire.
|
||||
|
||||
To read this notice again, call the function 'daisy_help'.
|
||||
<!-- --- BEGIN OF DAISY HELP --- -->
|
||||
===============================================================================
|
||||
These are the included binaries and utilities:
|
||||
- cdz:
|
||||
This utility extracts an archive to /tmp and changes
|
||||
directory to it in a new shell instance. Upon exit,
|
||||
the files are wiped. If `archivemount` is present,
|
||||
it will be used to mount the archive instead! You can
|
||||
bypass this behavior by 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.
|
||||
- squasher:
|
||||
These convenient set of tools allow you to easily create
|
||||
XZ-compressed SquashFS images from existing folders to save
|
||||
disk space. The resulting folder is still writable since it is
|
||||
mounted using an 'overlay' system. You can use 'squasher make'
|
||||
to compresses an existing folder. These folders are automatically
|
||||
mounted when you use 'cd' to navigate to them (via an alias).
|
||||
When using 'make-squash-image' on an already mounted folder, it will
|
||||
instead update the existing image. As of writing, we do not have a
|
||||
SystemD service to auto-mount, however, you cam easily add auto-mount
|
||||
as a cron job. Here is a list of tools, they all take the same
|
||||
folder argument:
|
||||
> squasher make: Converts the folder into a hidden image
|
||||
on the same disk as the folder.
|
||||
> squasher mount: Sets up a mount for the XZ image alongside
|
||||
directories for changes
|
||||
> squasher umount: Self-explanatory.
|
||||
> squasher destroy: Extracts the image and essentially reverts
|
||||
everything. File changes are kept, however.
|
||||
- editx:
|
||||
Uses your standard CLI editor to create/modify a
|
||||
file and make it executable.
|
||||
- filewait:
|
||||
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.
|
||||
- agenda:
|
||||
Sets up a folder that is backed by a date-based tree
|
||||
directory structure. Requires an argument for the name
|
||||
of the folder to generate. Generates a symlink in this
|
||||
name to a date sub-folder in a local '.daisy' folder.
|
||||
Format is <dir> -> .daisy/<dir>/<year>/<month>/<day>.
|
||||
Recommended to run via crontab - 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.
|
||||
- own:
|
||||
A simple utility. It's effectively an alias for
|
||||
"sudo chown -R user:user" on the target dir/file.
|
||||
Root permissions required!
|
||||
- sshp:
|
||||
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.
|
||||
- shrc:
|
||||
This tool allows you to edit the RC file for your
|
||||
shell in your preferred editor. After saving, the
|
||||
file is sourced by your shell if modified.
|
||||
- sw:
|
||||
A basic function that swaps two files by content.
|
||||
Useful for restoring backups.
|
||||
- what:
|
||||
This is a tool similar to which and others, the key
|
||||
difference is that it returns partial matches. It can
|
||||
be used to search for binaries.
|
||||
- scripbox:
|
||||
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.
|
||||
- bak/unbak:
|
||||
These small utilities make backups of files by making
|
||||
a copy with a .bak suffix. Unbak reverses the process
|
||||
by using sw and removes the backup.
|
||||
- lsa:
|
||||
A simple alias for `ls -lah`.
|
||||
- lsn:
|
||||
A simple alias for `ls -lah --sort=time --reverse`.
|
||||
- lss:
|
||||
A simple alias for `ls -lah --sort=size --reverse`.
|
||||
- editbin:
|
||||
An alias for `editx $\(which <x>\)`. Saves on typing.
|
||||
- editpeco:
|
||||
This function uses peco+tree like `cdp`, but opens
|
||||
your editor on the selected file(s). After you exit
|
||||
your editor(s), you are returned to peco where you left
|
||||
off.
|
||||
- ched:
|
||||
Like chsh but for your editor (EDITOR env). A list
|
||||
from which you can choose an installed editor
|
||||
(CLI or GUI) is shown. This list is by no means complete.
|
||||
The editor for LACKADAISICAL and the global editor are
|
||||
separate. If the EDITOR variable is already defined,
|
||||
only LD_EDITOR will be changed. LD_EDITOR is the editor
|
||||
used by LACKADAISICAL utilities.
|
||||
To override the global EDITOR variable, pass "-g".
|
||||
To restore the normal behavior of checking for an earlier
|
||||
definition of EDITOR after passing "-g", run `ched` without
|
||||
arguments.
|
||||
- cdf:
|
||||
Use fzf to find a file and then cd to its location.
|
||||
- cdp:
|
||||
Similar to `cdf` but uses tree+peco for the query.
|
||||
- clip:
|
||||
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, simply run clip without any arguments.
|
||||
The variable is stored locally in the shell as "LD_CLIP".
|
||||
- ldrc:
|
||||
Edits daisy.source and re-sources it, similarly to shrc.
|
||||
Append "-e" to edit "extra.src", to add custom functions in the
|
||||
lackadaisical namespace.
|
||||
- daisy_reload:
|
||||
Re-sources daisy.source. Essentially `ldrc` without
|
||||
editing.
|
||||
- grab:
|
||||
Alias for `awk '{print $x}'`, where x is a number.
|
||||
E.g. `echo 'a b c' | grab 2` returns 'b'.
|
||||
- daisy_cbin:
|
||||
Contains the name of the current LACKADAISICAL
|
||||
binary being run.
|
||||
- daisy_enc:
|
||||
Converts a file/stdin to a base64 block that can be
|
||||
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`.
|
||||
Does not support symlinks yet, and will instead treat it
|
||||
as a full input file (reads the data of the linked file).
|
||||
When using stdin, please provide a filename as argument.
|
||||
- daisy_enc_multi:
|
||||
A version of `daisy_enc` that encodes multiple
|
||||
files and outputs `daisy_base64_data` blocks to a file
|
||||
or stdout. These outputs can be concatenated as well.
|
||||
- daisy_dec:
|
||||
Converts `daisy_base64_data` blocks back to the form
|
||||
it was in originally.
|
||||
- daisy_dec_multi:
|
||||
A version of daisy_dec that runs on multiple input
|
||||
blocks that are either stored in a file or stdin.
|
||||
- daisy_alias:
|
||||
This utility sets persistent user aliases stored in
|
||||
"~/.config/lackadaisical/aliases.src".
|
||||
They will remain persistent until unaliased with
|
||||
daisy_unalias.
|
||||
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:
|
||||
List all available commands without description.
|
||||
- daisy_clear:
|
||||
Removes all configuration, including aliases.
|
||||
A backup is made and can be restored using "daisy_restore".
|
||||
Triggers a reload.
|
||||
- daisy_backup:
|
||||
Backs up all config files. These can be restored using
|
||||
"daisy_restore".
|
||||
- daisy_restore:
|
||||
Undoes "daisy_clear" by restoring config files.
|
||||
Triggers a reload.
|
||||
- ld_*:
|
||||
All functions prefixed by "daisy_" are also available with
|
||||
the prefix "ld_" via aliases provided in daisy.source.
|
||||
--- END OF DAISY HELP ---
|
||||
················································································
|
||||
< cdz >
|
||||
················································································
|
||||
This utility extracts an archive to /tmp and changes directory to it in a new
|
||||
shell instance. Upon exit, the files are wiped. If `archivemount` is present,
|
||||
it will be used to mount the archive instead! You can bypass this behavior by
|
||||
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.
|
||||
················································································
|
||||
|
||||
< squasher >
|
||||
················································································
|
||||
These convenient set of tools allow you to easily create XZ-compressed SquashFS
|
||||
images from existing folders to save disk space. The resulting folder is still
|
||||
writable since it is mounted using an 'overlay' system. You can use 'squasher
|
||||
make' to compresses an existing folder. These folders are automatically mounted
|
||||
when you use 'cd' to navigate to them (via the 'multicd' alias). When using
|
||||
'make-squash-image' on an already mounted folder, it will update the existing
|
||||
image. As of writing, we do not have a SystemD service to auto-mount, however,
|
||||
you cam easily add auto-mount as a cron job. Here is a list of tools, they all
|
||||
take the same folder argument:
|
||||
- squasher make: Converts the folder into an image on the same disk as the
|
||||
folder.
|
||||
- squasher mount: Sets up a mount for the XZ image alongside
|
||||
OverlayFS for changes.
|
||||
- squasher umount: Fully unmounts the image and overlay filesystem.
|
||||
- squasher destroy: Extracts the image and essentially reverts everything.
|
||||
All file changes are kept and applied to the unextracted
|
||||
data.
|
||||
················································································
|
||||
|
||||
< editx >
|
||||
················································································
|
||||
Uses your standard CLI editor to create/modify a file and make it executable.
|
||||
················································································
|
||||
|
||||
< filewait >
|
||||
················································································
|
||||
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.
|
||||
················································································
|
||||
|
||||
< agenda >
|
||||
················································································
|
||||
Sets up a folder that is backed by a date-based tree directory structure.
|
||||
Requires an argument for the name of the folder to generate. Generates a
|
||||
symlink in this name to a date sub-folder in a local '.daisy' folder. Format is
|
||||
<dir> -> .daisy/<dir>/<year>/<month>/<day>. Recommended to run via crontab -
|
||||
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.
|
||||
················································································
|
||||
|
||||
< own >
|
||||
················································································
|
||||
A simple utility. It's effectively an alias for "sudo chown -R user:user" on
|
||||
the target dir/file. Root permissions required!
|
||||
················································································
|
||||
|
||||
< sshp >
|
||||
················································································
|
||||
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.
|
||||
················································································
|
||||
|
||||
< shrc >
|
||||
················································································
|
||||
This tool allows you to edit the RC file for your shell in your preferred
|
||||
editor. After saving, the file is sourced by your shell if modified.
|
||||
················································································
|
||||
|
||||
< sw >
|
||||
················································································
|
||||
A basic function that swaps two files by content. Useful for restoring backups.
|
||||
················································································
|
||||
|
||||
< what >
|
||||
················································································
|
||||
This is a tool similar to which and others, the key difference is that it
|
||||
returns partial matches. It can be used to search for binaries.
|
||||
················································································
|
||||
|
||||
< scriptbox >
|
||||
················································································
|
||||
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.
|
||||
················································································
|
||||
|
||||
< bak/unbak >
|
||||
················································································
|
||||
These small utilities make backups of files by making a copy with a .bak
|
||||
suffix. Unbak reverses the process by using sw and removes the backup.
|
||||
················································································
|
||||
|
||||
< lsa >
|
||||
················································································
|
||||
A simple alias for `ls -lah`.
|
||||
················································································
|
||||
|
||||
< lsn >
|
||||
················································································
|
||||
A simple alias for `ls -lah --sort=time --reverse`.
|
||||
················································································
|
||||
|
||||
< lss >
|
||||
················································································
|
||||
A simple alias for `ls -lah --sort=size --reverse`.
|
||||
················································································
|
||||
|
||||
< editbin >
|
||||
················································································
|
||||
An alias for `editx $\(which <x>\)`. Saves on typing.
|
||||
················································································
|
||||
|
||||
< editpeco >
|
||||
················································································
|
||||
This function uses peco+tree like `cdp`, but opens your editor on the selected
|
||||
file(s). After you exit your editor(s), you are returned to peco where you left
|
||||
off.
|
||||
················································································
|
||||
|
||||
< ched >
|
||||
················································································
|
||||
Like chsh but for your editor (EDITOR env). A list from which you can choose an
|
||||
installed editor (CLI or GUI) is shown. This list is by no means complete. The
|
||||
editor for LACKADAISICAL and the global editor are separate. If the EDITOR
|
||||
variable is already defined, only LD_EDITOR will be changed. LD_EDITOR is the
|
||||
editor used by LACKADAISICAL utilities. To override the global EDITOR variable,
|
||||
pass "-g". To restore the normal behavior of checking for an earlier definition
|
||||
of EDITOR after passing "-g", run `ched` without arguments.
|
||||
················································································
|
||||
|
||||
< cdf >
|
||||
················································································
|
||||
Use fzf to find a file and then cd to its location.
|
||||
················································································
|
||||
|
||||
< cdp >
|
||||
················································································
|
||||
Similar to `cdf` but uses tree+peco for the query.
|
||||
················································································
|
||||
|
||||
< clip >
|
||||
················································································
|
||||
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,
|
||||
simply run clip without any arguments. The variable is stored locally in the
|
||||
shell as "LD_CLIP".
|
||||
················································································
|
||||
|
||||
< ldrc >
|
||||
················································································
|
||||
Edits daisy.source and re-sources it, similarly to shrc. Append "-e" to edit
|
||||
"extra.src", to add custom functions in the lackadaisical namespace.
|
||||
················································································
|
||||
|
||||
< daisy reload >
|
||||
················································································
|
||||
Re-sources daisy.source. Essentially `ldrc` without editing.
|
||||
················································································
|
||||
|
||||
< grab >
|
||||
················································································
|
||||
Alias for `awk '{print $x}'`, where x is a number. E.g. `echo 'a b c' | grab 2`
|
||||
returns 'b'.
|
||||
················································································
|
||||
|
||||
< daisy cbin >
|
||||
················································································
|
||||
Contains the name of the current LACKADAISICAL binary being run.
|
||||
················································································
|
||||
|
||||
< daisy enc >
|
||||
················································································
|
||||
Converts a file/stdin to a base64 block that can be 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`. Does not support symlinks yet, and will instead
|
||||
treat it as a full input file (reads the data of the linked file). When using
|
||||
stdin, please provide a filename as argument.
|
||||
················································································
|
||||
|
||||
< daisy enc multi >
|
||||
················································································
|
||||
A version of `daisy_enc` that encodes multiple files and outputs
|
||||
`daisy_base64_data` blocks to a file or stdout. These outputs can be
|
||||
concatenated as well.
|
||||
················································································
|
||||
|
||||
< daisy enc folder >
|
||||
················································································
|
||||
A version of `daisy_enc` that encodes a whole folder into a series of
|
||||
`daisy_base64_data` blocks. Requires the `tree` utility.
|
||||
················································································
|
||||
|
||||
< daisy dec >
|
||||
················································································
|
||||
Converts `daisy_base64_data` blocks back to the form it was in originally.
|
||||
················································································
|
||||
|
||||
< daisy dec multi >
|
||||
················································································
|
||||
A version of daisy_dec that runs on multiple input blocks that are either
|
||||
stored in a file or stdin.
|
||||
················································································
|
||||
|
||||
< daisy alias >
|
||||
················································································
|
||||
This utility sets persistent user aliases stored in
|
||||
"~/.config/lackadaisical/aliases.src". They will remain persistent until
|
||||
unaliased with daisy_unalias. 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 >
|
||||
················································································
|
||||
List all available commands, utilities and tools - without description.
|
||||
················································································
|
||||
|
||||
< daisy clear >
|
||||
················································································
|
||||
Removes all configuration, including aliases. A backup is made and can be
|
||||
restored using "daisy_restore". Triggers a reload.
|
||||
················································································
|
||||
|
||||
< daisy backup >
|
||||
················································································
|
||||
Backs up all config files. These can be restored using "daisy_restore".
|
||||
················································································
|
||||
|
||||
< daisy restore >
|
||||
················································································
|
||||
Undoes "daisy_clear" by restoring config files. Triggers a reload.
|
||||
················································································
|
||||
|
||||
< daisy_* /ld_* >
|
||||
················································································
|
||||
All functions prefixed by "daisy" are also available as alias with the prefixes
|
||||
"daisy_" and "ld_".
|
||||
················································································
|
||||
|
||||
< daisy help >
|
||||
················································································
|
||||
Shows this exact interface for information about different utilities and
|
||||
functions provided by `lackadaisical`.
|
||||
- help <command|utility|tool>: Shows a help entry for a particular command,
|
||||
including allternative function names.
|
||||
- help Shows fully formatted help entries for every
|
||||
function listed by "daisy list" (recommended
|
||||
for first-time users).
|
||||
················································································
|
||||
|
||||
< daisy welcome >
|
||||
················································································
|
||||
Showws some basic post-installation information about LACKADAISICAL and how to
|
||||
use it.
|
||||
················································································
|
||||
<!-- --- END OF DAISY HELP --- -->
|
||||
```
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue