dotfiles

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README

commit 719390f226e5b802c80d73d5779d9f83eb1d5f60
parent 94b274aa844cf69bcec54c63349fdc2d314d72c1
Author: Pablo Cárdenas <pablo.cardenas@imca.edu.pe>
Date:   Tue, 18 Jun 2024 21:31:27 -0500

shell: fix print_goodbye and git

Diffstat:
M.config/shell/functions.sh | 33+++++++++++++++++++++------------
1 file changed, 21 insertions(+), 12 deletions(-)

diff --git a/.config/shell/functions.sh b/.config/shell/functions.sh @@ -6,7 +6,7 @@ pwd() { echo "Use dirs [-v]"; } man() { case $1 in - -* | [1-9]* | n) + -* | [0-9]* | n) command man "$@" ;; *) @@ -24,6 +24,10 @@ git() { _work_tree="$2" shift 2 fi + if [ "$1" = "-C" ]; then + _c="$2" + shift 2 + fi if [ "$1" = "checkout" ]; then echo "Use" @@ -51,31 +55,36 @@ git() { if [ -n "${_work_tree}" ]; then set -- --work-tree "${_work_tree}" "$@" fi - unset _git_dir _work_tree + if [ -n "${_c}" ]; then + set -- -C "${_c}" "$@" + fi + unset _git_dir _work_tree _c command git "$@" return $? fi return 1 } -print_goodbye() { +status() { set -- \ --modified \ --others \ --exclude-standard \ --directory \ --no-empty-directory - # shellcheck disable=SC2016 - if [ -z "${TMUX}" ] && { - [ -n "$(dotfiles ls-files "$@" || true)" ] || - ! dotfiles submodule foreach '[ -z "$(git ls-files '"$*"')" ]' \ - >/dev/null 2>/dev/null; - }; then + if [ -n "$(dotfiles ls-files "$@" || true)" ] || + ! dotfiles submodule foreach \ + "[ -z \"\$(git ls-files ""$*"")\" ]" \ + >/dev/null 2>/dev/null; then echo "In dotfiles:" dotfiles status -s dotfiles submodule foreach 'git status -s' - read -r var - echo "${var}" - unset var + return 1 + fi +} + +print_goodbye() { + if [ -z "${TMUX}" ]; then + status || read -r _ fi }