Upgrades to editx integrating the editbin alias.
Changes to new install detection.
This commit is contained in:
parent
3c1a6e7374
commit
056ab01ed4
3 changed files with 60 additions and 32 deletions
19
README.md
19
README.md
|
|
@ -56,6 +56,8 @@ take the same folder argument:
|
|||
< editx >
|
||||
················································································
|
||||
Uses your standard CLI editor to create/modify a file and make it executable.
|
||||
If the executable already exists in path, it will edit that instead.
|
||||
Should you not want this behavior, call the utility with the -n switch.
|
||||
················································································
|
||||
|
||||
< filewait >
|
||||
|
|
@ -139,11 +141,6 @@ A simple alias for `ls -lah --sort=time --reverse`.
|
|||
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
|
||||
|
|
@ -184,6 +181,7 @@ shell as "LD_CLIP".
|
|||
················································································
|
||||
Edits daisy.source and re-sources it, similarly to shrc. Append "-e" to edit
|
||||
"extra.src", to add custom functions in the lackadaisical namespace.
|
||||
Append "-d" to edit "daisy.command.source".
|
||||
················································································
|
||||
|
||||
< daisy reload >
|
||||
|
|
@ -197,11 +195,6 @@ 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
|
||||
|
|
@ -293,11 +286,5 @@ functions provided by `lackadaisical`.
|
|||
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 --- -->
|
||||
```
|
||||
|
|
|
|||
22
daisy.source
22
daisy.source
|
|
@ -64,13 +64,13 @@ export LD_AVAILABLE=0
|
|||
|
||||
# Config folder setup
|
||||
export LD_CONFIG_FOLDER="$HOME/.config/lackadaisical"
|
||||
export LD_NEW_INSTALL=
|
||||
export LD_NEW_INSTALL=0
|
||||
|
||||
if [[ ! -d "$LD_CONFIG_FOLDER" ]];
|
||||
then
|
||||
# Create the folder with its basics
|
||||
mkdir -p "$LD_CONFIG_FOLDER"
|
||||
new_install=1
|
||||
export LD_NEW_INSTALL=1
|
||||
fi
|
||||
|
||||
# Multiple default source files
|
||||
|
|
@ -215,12 +215,6 @@ function editpeco
|
|||
tree --noreport -fia . | peco --prompt "Press CTRL+C to quit - query:" --exec "xargs -o -I{} $EDITOR {}"
|
||||
}
|
||||
|
||||
# for convenience purposes
|
||||
function editbin
|
||||
{
|
||||
editx $(which $1)
|
||||
}
|
||||
|
||||
# sets a new editor based on commony available ones, and some visual ones
|
||||
function ched
|
||||
{
|
||||
|
|
@ -346,15 +340,23 @@ _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 [[ $new_install -eq 1 ]];
|
||||
if [[ LD_NEW_INSTALL -eq 1 ]];
|
||||
then
|
||||
daisy check
|
||||
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
|
||||
|
||||
###############################################################################
|
||||
|
|
|
|||
51
editx
51
editx
|
|
@ -13,15 +13,54 @@ fi
|
|||
|
||||
if [[ -z "${EDITOR}" ]];
|
||||
then
|
||||
# ched is defined in daisy.source
|
||||
ched "EDITOR env variable not set! You will have to set it yourself in the next screen."
|
||||
fi
|
||||
|
||||
[[ -e "$1" ]] && existed=1 || existed=0
|
||||
file=$1
|
||||
file_exist=0
|
||||
file_in_path=$(whereis $1 | awk '{print $2}')
|
||||
path_exist=0
|
||||
|
||||
touch "$1"
|
||||
chmod +x "$1"
|
||||
daisy editor "$1"
|
||||
[[ -e "$file" ]] && file_exist=1
|
||||
[[ -n "$file_in_path" ]] && path_exist=1
|
||||
|
||||
if [[ ! -s "$1" && $existed -eq 0 ]]; then
|
||||
rm -f "$1"
|
||||
if [[ $path_exist == 1 && $file_exist == 0 ]]; then
|
||||
file=$file_in_path
|
||||
elif [[ $path_exist == 1 && $file_exist == 1 ]]; then
|
||||
# Check if they are actually the same file
|
||||
if [[ $(realpath "$file") != $(realpath "$file_in_path") ]]; then
|
||||
echo "Multiple instances of \"$1\" were located, please make a selection:"
|
||||
echo "1. Local file: \"$file\""
|
||||
echo "2. File found in PATH: \"$file_in_path\""
|
||||
read -p "Please select a choice, the default choice (with no entry) is 2 [1..2]: " choice
|
||||
|
||||
case "$choice" in
|
||||
1)
|
||||
file=$file
|
||||
;;
|
||||
2|"")
|
||||
file="$file_in_path"
|
||||
;;
|
||||
*)
|
||||
file="$file_in_path"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
|
||||
# Determine if the file already exists before we touch it
|
||||
if [[ -e "$file" ]]; then
|
||||
existed=1
|
||||
else
|
||||
existed=0
|
||||
fi
|
||||
|
||||
touch "$file"
|
||||
chmod +x "$file"
|
||||
daisy editor "$file"
|
||||
|
||||
# Only remove if it's empty AND we created it in this session
|
||||
if [[ ! -s "$file" && $existed -eq 0 ]]; then
|
||||
rm -f "$file"
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue