Skip to content

Commit ec2cd2b

Browse files
committed
Add zsh support. Initial changes - 2
1 parent 17f9527 commit ec2cd2b

File tree

8 files changed

+72
-30
lines changed

8 files changed

+72
-30
lines changed

bin/apps/bash/hhs-app/hhs.bash

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ usage: ${APP_NAME} {function | plugin {task} <command>} [args...] [options]
6767
EOF
6868

6969
# Directory containing all HHS plug-ins.
70-
PLUGINS_DIR="$(dirname "${0//${HHS_DIR}/$HHS_HOME}")/apps/${HHS_MY_SHELL}/hhs-app/plugins"
70+
PLUGINS_DIR="$(dirname "${0//${HHS_DIR}/$HHS_HOME}")/apps/${HHS_MY_SHELL//zsh/bash}/hhs-app/plugins"
7171

7272
# Directory containing all local HHS functions.
73-
FUNCTIONS_DIR="$(dirname "${0//${HHS_DIR}/$HHS_HOME}")/apps/${HHS_MY_SHELL}/hhs-app/functions"
73+
FUNCTIONS_DIR="$(dirname "${0//${HHS_DIR}/$HHS_HOME}")/apps/${HHS_MY_SHELL//zsh/bash}/hhs-app/functions"
7474

7575
# List of local hhs functions that can be executed.
7676
HHS_APP_FUNCTIONS=()
@@ -111,6 +111,7 @@ function has_function() {
111111
# @param $1 [Req] : The plugin name.
112112
function has_plugin() {
113113

114+
echo "${PLUGINS[*]}"
114115
if [[ -n "${1}" ]] && list_contains "${PLUGINS[*]}" "${1}"; then
115116
return 0
116117
fi

dotfiles/bash/bash_aliases.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ else
258258
alias __hhs_uuid='python3 -c "import uuid as ul; print(ul.uuid4())"'
259259

260260
# @alias: Reload HomeSetup
261-
alias __hhs_reload='__hhs_clear; source "${HOME}/.bashrc"'
261+
alias __hhs_reload='__hhs_clear; source "${HOME}/.${HHS_MY_SHELL}rc"'
262262
# @alias: Clear and reset all cursor attributes and IFS
263263
alias __hhs_clear='reset-cursor-attrs; echo -en "\033[2J\033[H${NC}"; export IFS="${OLDIFS}"'
264264
# @alias: Clear the screen and reset the terminal

dotfiles/bash/bash_functions.bash

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ else
3030
done
3131

3232
# Load all dev tools files.
33+
all=()
3334
while IFS= read -r line; do all+=("$line"); done < <(find "${HHS_HOME}/bin/dev-tools/bash" -type f -name "*.bash" | sort | uniq)
3435
__hhs_log "DEBUG" "Loading (${#all[@]}) dev-tools files"
3536
for file in "${all[@]}"; do

dotfiles/bash/bash_prompt.bash

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ else
223223
[[ -f "${colorls_dir}/files.yaml" ]] || \cp "${hhs_colorls_dir}/files.yaml" "${colorls_dir}"
224224
[[ -f "${colorls_dir}/folder_aliases.yaml" ]] || \cp "${hhs_colorls_dir}/folder_aliases.yaml" "${colorls_dir}"
225225
[[ -f "${colorls_dir}/folders.yaml" ]] || \cp "${hhs_colorls_dir}/folders.yaml" "${colorls_dir}"
226+
__hhs_source "$(dirname "$(gem which colorls)")"/tab_complete.sh
226227
fi
227228

228229
fi

dotfiles/bash/hhsrc.bash

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ function command_not_found_handle() {
401401
}
402402

403403
# Print HomeSetup MOTDs.
404+
echo -en "\033[H\033[J"
404405
if [[ -d "${HHS_MOTD_DIR}" ]]; then
405406
all=$(find "${HHS_MOTD_DIR}" -type f | sort | uniq)
406407
for motd in ${all}; do

dotfiles/zsh/zsh_functions.zsh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env zsh
2+
# shellcheck disable=SC1090
3+
4+
# Script: zsh_functions.bash
5+
# Purpose: This file is used to define some shell tools
6+
# Created: Nov 21, 2025
7+
# Author: <B>H</B>ugo <B>S</B>aporetti <B>J</B>unior
8+
# Mailto: taius.hhs@gmail.com
9+
# Site: https://github.com/yorevs/homesetup
10+
# License: Please refer to <https://opensource.org/licenses/MIT>
11+
#
12+
# Copyright (c) 2025, HomeSetup team
13+
14+
# !NOTICE: Do not change this file. To customize your functions edit the file ~/.functions
15+
16+
# Do not source this file multiple times.
17+
if list_contains "${HHS_ACTIVE_DOTFILES}" "zsh_functions"; then
18+
__hhs_log "DEBUG" "$0 was already loaded!"
19+
else
20+
21+
export HHS_ACTIVE_DOTFILES="${HHS_ACTIVE_DOTFILES} bash_functions"
22+
23+
# Load all dev tools files.
24+
while IFS= read -r line; do all+=("$line"); done < <(find "${HHS_HOME}/bin/dev-tools/bash" -type f -name "*.bash" | sort | uniq)
25+
__hhs_log "DEBUG" "Loading (${#all[@]}) dev-tools files"
26+
for file in "${all[@]}"; do
27+
__hhs_log "DEBUG" "Loading ${file}"
28+
__hhs_source "${file}" || __hhs_log "ERROR" "Unable to source file: ${file}"
29+
done
30+
31+
# Unalias any hhs found because we need this name to use for HomeSetup
32+
unalias hhs &> /dev/null
33+
__hhs_has 'hhs' && __hhs_log "ERROR" "'hhs' is already defined: $(command -v 'hhs')"
34+
35+
# @function: Wrapper to either invoke the hhs application or change to HHS_HOME or HHS_DIR.
36+
# @param $* [Opt] : All parameters are passed to hhs.bash.
37+
function __hhs() {
38+
39+
if [[ -z "${1}" || "${1}" == 'home' ]]; then
40+
\cd "${HHS_HOME}" || return 1
41+
elif [[ "${1}" == 'dir' ]]; then
42+
\cd "${HHS_DIR}" || return 1
43+
else
44+
hhs.bash "${@}" || return 1
45+
fi
46+
47+
return 0
48+
}
49+
50+
fi

dotfiles/zsh/zsh_prompt.zsh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,5 @@ if gem which colorls &>/dev/null; then
6161
[[ -f "${colorls_dir}/files.yaml" ]] || \cp "${hhs_colorls_dir}/files.yaml" "${colorls_dir}"
6262
[[ -f "${colorls_dir}/folder_aliases.yaml" ]] || \cp "${hhs_colorls_dir}/folder_aliases.yaml" "${colorls_dir}"
6363
[[ -f "${colorls_dir}/folders.yaml" ]] || \cp "${hhs_colorls_dir}/folders.yaml" "${colorls_dir}"
64+
source "$(dirname "$(gem which colorls)")"/tab_complete.sh
6465
fi

dotfiles/zsh/zshrc.zsh

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# If not running interactively or as a CI build, skip it.
1616
[[ -z "${JOB_NAME}" && -z "${GITHUB_ACTIONS}" && -z "${PS1}" && -z "${PS2}" ]] && return
1717

18+
echo -e "\033[1;34m[${SHELL##*\/}] HomeSetup is starting...\033[m"
19+
1820
export HHS_ACTIVE_DOTFILES="${HHS_ACTIVE_DOTFILES} zshrc"
1921

2022
# Unset other used variables
@@ -142,9 +144,10 @@ if [[ -f "${HHS_DIR}/.path" ]]; then
142144
done
143145
fi
144146

145-
# HomeSetup paths
147+
# ZSH missing paths
146148
brew_path="/opt/homebrew/bin"
147-
PATH="${brew_path:h}:${PATH}"
149+
ruby_path="$(ruby -e 'puts Gem.bindir')"
150+
PATH="${brew_path:h}:${ruby_path}:${PATH}"
148151
# Remove PATH duplicates.
149152
PATH=$(awk -F: '{for (i=1;i<=NF;i++) { if ( !x[$i]++ ) printf("%s:",$i); }}' <<<"${PATH}")
150153
export PATH
@@ -158,6 +161,7 @@ setopt share_history
158161
setopt hist_expire_dups_first
159162
setopt hist_ignore_dups
160163
setopt hist_verify
164+
setopt auto_cd
161165

162166
# Alias definitions
163167
if ! [[ -s "${HHS_ALIASDEF}" ]]; then
@@ -259,39 +263,22 @@ fi
259263
# Workaround to fix missing __hhs_functions
260264

261265
# Print HomeSetup MOTDs.
262-
MOTD="${ORANGE}[${HHS_MY_OS}-${HHS_MY_OS_RELEASE}/${HHS_MY_SHELL}] ${WHITE}${HAND_PEACE_ICN}
263-
${GREEN}Welcome ${USER:-user} to HomeSetup ${BLUE}v${HHS_VERSION}
264-
${NC}"
265-
266-
echo -e "${MOTD}"
267-
268-
# Unalias any hhs found because we need this name to use for HomeSetup
269-
unalias hhs &> /dev/null
270-
command -v &>/dev/null 'hhs' && __hhs_log "ERROR" "'hhs' is already defined: $(command -v 'hhs')"
271-
272-
# @function: Wrapper to either invoke the hhs application or change to HHS_HOME or HHS_DIR.
273-
# @param $* [Opt] : All parameters are passed to hhs.bash.
274-
function __hhs() {
275-
276-
if [[ -z "${1}" || "${1}" == 'home' ]]; then
277-
\cd "${HHS_HOME}" || return 1
278-
elif [[ "${1}" == 'dir' ]]; then
279-
\cd "${HHS_DIR}" || return 1
280-
else
281-
hhs.bash "${@}" || return 1
282-
fi
283-
284-
return 0
285-
}
266+
echo -e "\033[H\033[J"
267+
echo -en "${ORANGE}[${HHS_MY_OS}-${HHS_MY_OS_RELEASE}/${HHS_MY_SHELL}] ${WHITE}${HAND_PEACE_ICN} "
268+
echo -e "${GREEN}Welcome ${USER:-user} to HomeSetup ${BLUE}v${HHS_VERSION}${NC}\n"
286269

287270
alias cd='\cd'
288-
alias ..=..
271+
alias ..='cd ..'
272+
alias ...='cd ../../'
273+
alias ....='cd ../../../'
274+
alias .....='cd ../../../../'
289275
alias \?='\pwd'
290276
alias dirs='\dirs'
291277
alias du='\du'
292278
alias open='\open'
293279
alias shopt='\shopt'
294280
alias hhs='__hhs'
281+
alias gta='git add'
295282

296283
# -----------------------------------------------------------------------------------
297284
# Finalization

0 commit comments

Comments
 (0)