22# Install Node (via nvm + Node.js 24 when Node is missing), enable Corepack,
33# install GitHub CLI when missing, and install @patternfly/patternfly-cli globally.
44
5+ # Ensure this script runs in bash, even if invoked with zsh
6+ if [ -z " ${BASH_VERSION:- } " ]; then
7+ exec bash " $0 " " $@ "
8+ fi
9+
510set -euo pipefail
611
712if [ -z " ${HOME:- } " ]; then
@@ -48,6 +53,40 @@ ensure_nvm_loaded() {
4853 return 1
4954}
5055
56+ setup_nvm_for_zsh () {
57+ # Add nvm to .zshrc only if zsh is the user's default shell
58+ if [ -z " ${SHELL:- } " ]; then
59+ return 0
60+ fi
61+
62+ case " $SHELL " in
63+ * /zsh)
64+ ;;
65+ * )
66+ return 0
67+ ;;
68+ esac
69+
70+ local zshrc=" ${HOME} /.zshrc"
71+ if [ ! -f " $zshrc " ]; then
72+ touch " $zshrc "
73+ fi
74+
75+ if grep -q ' NVM_DIR' " $zshrc " 2> /dev/null; then
76+ info " nvm is already configured in ${zshrc} "
77+ return 0
78+ fi
79+
80+ info " Adding nvm to ${zshrc} for zsh compatibility."
81+ cat >> " $zshrc " << 'EOF '
82+
83+ # Load nvm (Node Version Manager)
84+ export NVM_DIR="$HOME/.nvm"
85+ [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
86+ [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
87+ EOF
88+ }
89+
5190install_node_via_nvm () {
5291 info " Node.js not found. Installing nvm (${NVM_VERSION} ) and Node.js 24."
5392 if ! require_cmd curl && ! require_cmd wget; then
@@ -71,6 +110,8 @@ install_node_via_nvm() {
71110 nvm use 24 || error " nvm failed to activate Node.js 24."
72111 nvm alias default 24 2> /dev/null || true
73112
113+ setup_nvm_for_zsh
114+
74115 info " Node.js $( node --version) and npm $( npm --version) are ready (npm ships with this Node release)."
75116}
76117
@@ -245,16 +286,21 @@ main() {
245286 ensure_gh
246287 install_patternfly_cli
247288
289+ printf ' \n'
290+ printf ' SUCCESS: PatternFly CLI is installed.\n'
291+ printf ' \n'
248292 printf ' To see available commands, run the CLI with:\n'
249293 printf ' patternfly-cli --help\n'
250294 printf ' \n'
251295 printf ' Alternatively, you can use the alias "pfcli" instead of "patternfly-cli"\n'
252296 printf ' \n'
253297 printf ' pfcli --help\n'
254298 printf ' \n'
255- printf ' SUCCESS: PatternFly CLI is installed.\n'
299+ printf ' NOTE: If the command is not found, restart your terminal or run:\n'
300+ printf ' source ~/.zshrc # for zsh users\n'
301+ printf ' source ~/.bashrc # for bash users\n'
256302 printf ' \n'
257-
303+
258304}
259305
260306main " $@ "
0 commit comments