# created 2024095(+/-3)
# author: @jakimfett
# inspiration: functions.sh
#echo "got here"
# @todo pull in nano settings from functions.sh
#. ~/run/mixins.src
DEBUG=1
function logThis {
# echo "got here to logThis"
if [[ "${DEBUG}" -eq 1 ]]; then
# echo "got past logThis{DEBUG}..."
if [[ ! -z "${@}" ]]; then
echo -e "${@}" # | tee -a <logfile>?
else
echo
fi
fi
}
function lt {
# echo "got here to lt"
logThis "${@}"
}
lt "@function:logThis/lt testing..." &&\
lt "@function:logThis/lt success" && lt "---"
#@todo exit if lt fails
versionControlSystem='pijul'
function v {
if [[ ! -z "${@}" ]]; then
eval "${versionControlSystem} ${@}"
else
eval "${versionControlSystem}"
fi
}
lt "@function:v loaded"
function vc {
v diff
}
lt "@function:vc loaded"
function vcs {
v record
}
lt "@function:vcs loaded"
function mkrepo {
if [[ ! -z "${@}" ]]; then
# case statement?
lt "got from user:\n\t'${@}'"
lt
local trimmedInput="${@:1}"
local cmd="mkdir '${@:2}.repo' && v init '${@:2}.repo'"
# @todo check for improper format
# hardcoding dry run with a magic value?
# that's a choice.
# destructive by default refactoring should be hard.
# echo "${@:1:1}"
if [[ "${@:1:1}" == '--init' ]]; then
echo -e "This command should:"
else
echo "!! THIS IS A DRY RUN !!"
echo "Using '--init' option would:"
fi
echo -e "\t- create directory '${@:2}.repo' in $(pwd)"
echo -e "\t- initialize a '${versionControlSystem}' repository at '$(pwd)/${@:2}.repo'"
echo
if [[ "${@:1:1}" == '--init' ]]; then
echo -n "EVAL: "
eval "${cmd}"
echo
fi
echo "Result:"
if [ -d "${@:2}.repo/.${versionControlSystem}" ]; then
echo "Successfully created ${versionControlSystem} repository at '$(pwd)/${@:2}.repo'"
else
echo "NOT FOUND: ${versionControlSystem} repo at '$(pwd)/${@:2}.repo'"
fi
fi
# @todo exit trapping
}
lt "@function:mkrepo loaded"
function selfTest {
# todo shellcheck
lt "\tdiscreet testing function not yet implemented,\n\tsee above for inline tests"
}
lt "@function:selfTest loaded"
lt
lt "running self-test function 'selfTest':"
selfTest
#@todo port over function registration
lt "\n> loading complete, see above for available functions"
# originally, the functions were all aliases.
#
# then, delusions of creating terminal-based object-orientedness struck.
# #
# generally, this entire stack of functionality has gone through refinement of:
# oneliner-->alias
# alias-->function
# function-->class
#
# where "class" can mean sourcefile (.src) or scriptfile (.sh)
#
# #
#
# some of this is just QoL stuff that hasn't become it's own thing
#
# #
#
# make nano more usable
alias nano="nano --nowrap --backup --positionlog --autoindent --linenumbers --softwrap --tabsize 3"
# easy ssh key stuffs
alias ssh-makey='ssh-keygen -a 256 -t ed25519'
alias ssh-mykey='cat ~/.ssh/id_ed25519.pub'
alias ssh-showkey='cat ~/.ssh/id_ed25519.pub && echo -e "^-- personal pubkey\n\nserver key(s) --v"; ssh-keygen -lf <(ssh-keyscan localhost 2>/dev/null)'
# temporal anchoring
alias when='date +%Y.%j.%H%M%S'