forked from EvergreenCrypto/docker-finance
client: add dfi alias
- `dfi` is now primary unified command (saves fingers) * `docker-finance` is still available, as this is only an addition - Also fixes missing line continuation during install (#104)
This commit is contained in:
@@ -33,6 +33,7 @@ export PATH="$PATH:${HOME}/.local/bin:${DOCKER_FINANCE_CONTAINER_REPO}:${DOCKER_
|
||||
# Base command alias
|
||||
alias docker-finance='$DOCKER_FINANCE_CONTAINER_CMD'
|
||||
alias finance='$DOCKER_FINANCE_CONTAINER_CMD'
|
||||
alias dfi='$DOCKER_FINANCE_CONTAINER_CMD'
|
||||
|
||||
# Traditional aliases
|
||||
alias c='clear' # or ctrl+l
|
||||
|
||||
@@ -23,18 +23,18 @@ aliases=~/.bash_aliases
|
||||
function docker-finance::install()
|
||||
{
|
||||
# Environment expectations
|
||||
local -r _alias="alias docker-finance="
|
||||
local -r _alias=("docker-finance" "dfi")
|
||||
local _path # full path to docker-finance repository
|
||||
_path="$(dirname "$(realpath -s $0)" | rev | cut -d'/' -f2- | rev)"
|
||||
|
||||
# Remove previous alias
|
||||
if grep "^${_alias}" "$aliases" &>/dev/null; then
|
||||
sed -i "/^${_alias}/d" "$aliases"
|
||||
unalias docker-finance
|
||||
fi
|
||||
|
||||
# Set new alias
|
||||
echo "${_alias}'${_path}/client/docker.bash'" >>"$aliases"
|
||||
# Install (or re-install) aliases
|
||||
# NOTE: caller must `source` (as `unalias` and `alias` are in subshell)
|
||||
for _a in "${_alias[@]}"; do
|
||||
if grep "^alias ${_a}=" "$aliases" &>/dev/null; then
|
||||
sed -i "/^alias ${_a}=/d" "$aliases"
|
||||
fi
|
||||
echo "alias ${_a}='${_path}/client/docker.bash'" >>"$aliases"
|
||||
done
|
||||
|
||||
# Set bash completion
|
||||
_completion="${_path}/client/src/docker/completion.bash"
|
||||
@@ -57,7 +57,7 @@ else
|
||||
fi
|
||||
fi
|
||||
docker-finance::install \
|
||||
&& echo "SUCCESS: installation complete"
|
||||
&& echo "SUCCESS: installation complete" \
|
||||
|| echo "FATAL: could not complete installation"
|
||||
else
|
||||
echo "FATAL: unsupported bash environment" >&2
|
||||
|
||||
@@ -97,3 +97,6 @@ function docker-finance::completion()
|
||||
|
||||
complete -F docker-finance::completion docker.bash
|
||||
complete -F docker-finance::completion docker-finance
|
||||
complete -F docker-finance::completion dfi
|
||||
|
||||
# vim: sw=2 sts=2 si ai et
|
||||
|
||||
@@ -95,57 +95,59 @@ function main()
|
||||
\e[37;2m# Finance platform\e[0m
|
||||
\e[37;2m#\e[0m
|
||||
|
||||
\e[37;2m# For the sake of simplicity, recreate the docker-finance alias using <platform${global_arg_delim_1}user:tag>\e[0m
|
||||
$ unalias docker-finance 2>/dev/null \\
|
||||
; alias docker-finance=\"$0 archlinux${global_arg_delim_1}${USER}:default\"
|
||||
|
||||
\e[37;2m# Generate environment and build default image\e[0m
|
||||
$ docker-finance gen && docker-finance build type${global_arg_delim_2}default
|
||||
\e[37;2m# Generate default environment and build default image\e[0m
|
||||
$ dfi archlinux${global_arg_delim_1}${USER}:default gen \\
|
||||
&& dfi archlinux${global_arg_delim_1}${USER}:default build type${global_arg_delim_2}default
|
||||
|
||||
\e[37;2m# Bring up container, open shell (type 'exit' to leave)\e[0m
|
||||
$ docker-finance up
|
||||
$ dfi archlinux${global_arg_delim_1}${USER}:default up
|
||||
|
||||
\e[37;2m# In another shell (or after you exit), open a container root shell\e[0m
|
||||
$ docker-finance shell user${global_arg_delim_2}root
|
||||
$ dfi archlinux${global_arg_delim_1}${USER}:default shell user${global_arg_delim_2}root
|
||||
|
||||
\e[37;2m# In another shell (or after you exit), edit client/container variables\e[0m
|
||||
$ docker-finance edit type${global_arg_delim_2}env
|
||||
$ dfi archlinux${global_arg_delim_1}${USER}:default edit type${global_arg_delim_2}env
|
||||
|
||||
\e[37;2m# Spawn a container with given command (removed after command finishes)\e[0m
|
||||
\e[37;2m# NOTE: incredibly useful when used with your host's crontab\e[0m
|
||||
$ docker-finance run 'finance family/alice fetch all${global_arg_delim_2}price'
|
||||
$ dfi archlinux${global_arg_delim_1}${USER}:default run 'dfi family/alice fetch all${global_arg_delim_2}price'
|
||||
|
||||
\e[37;2m# Bring down running container (stop and remove container & network)\e[0m
|
||||
$ docker-finance down
|
||||
$ dfi archlinux${global_arg_delim_1}${USER}:default down
|
||||
|
||||
\e[37;2m# Backup image, delete old image, build new image\e[0m
|
||||
$ docker-finance backup && docker-finance rm && docker-finance build
|
||||
$ dfi archlinux${global_arg_delim_1}${USER}:default backup \\
|
||||
&& dfi archlinux${global_arg_delim_1}${USER}:default rm \\
|
||||
&& dfi archlinux${global_arg_delim_1}${USER}:default build
|
||||
|
||||
\e[37;2m# Print current version of 'docker-finance' and client/container ('finance') dependencies\e[0m
|
||||
$ docker-finance version type${global_arg_delim_2}all
|
||||
$ dfi archlinux${global_arg_delim_1}${USER}:default version type${global_arg_delim_2}all
|
||||
|
||||
\e[37;2m#\e[0m
|
||||
\e[37;2m# Dev-tools platform\e[0m
|
||||
\e[37;2m#\e[0m
|
||||
|
||||
\e[37;2m# For the sake of simplicity, recreate the dev-tools alias using <platform${global_arg_delim_1}user:tag>\e[0m
|
||||
$ unalias dev-tools 2>/dev/null \\
|
||||
; alias dev-tools=\"$0 dev-tools${global_arg_delim_1}${USER}:default\"
|
||||
|
||||
\e[37;2m# Generate environment and build default image\e[0m
|
||||
$ dev-tools gen && dev-tools build type${global_arg_delim_2}default
|
||||
\e[37;2m# Generate default environment and build default image\e[0m
|
||||
$ dfi dev-tools${global_arg_delim_1}${USER}:default gen \\
|
||||
&& dfi archlinux${global_arg_delim_1}${USER}:default build type${global_arg_delim_2}default
|
||||
|
||||
\e[37;2m# Spawn a container with given command (removed after command finishes)\e[0m
|
||||
$ dev-tools run 'shellcheck --version'
|
||||
$ dfi dev-tools${global_arg_delim_1}${USER}:default run 'shellcheck --version'
|
||||
|
||||
\e[37;2m# Lint entire docker-finance source\e[0m
|
||||
$ dev-tools linter type${global_arg_delim_2}bash${global_arg_delim_3}php${global_arg_delim_3}c++
|
||||
$ dfi dev-tools${global_arg_delim_1}${USER}:default linter type${global_arg_delim_2}bash${global_arg_delim_3}php${global_arg_delim_3}c++
|
||||
|
||||
\e[37;2m# Generate Doxygen for docker-finance source\e[0m
|
||||
$ dev-tools doxygen gen
|
||||
$ dfi dev-tools${global_arg_delim_1}${USER}:default doxygen gen
|
||||
|
||||
\e[37;2m# Print current version of 'docker-finance' and client/container ('dev-tools') dependencies\e[0m
|
||||
$ dev-tools version type${global_arg_delim_2}all
|
||||
$ dfi dev-tools${global_arg_delim_1}${USER}:default version type${global_arg_delim_2}all
|
||||
|
||||
\e[32mTips:\e[0m
|
||||
|
||||
- Save your fingers! Use tab completion for all images and commands (see README)
|
||||
- Setup aliases for frequently used images (useful for single-user systems)
|
||||
* Depending on your alias design, tab completion may not be available
|
||||
"
|
||||
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user