Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,9 @@ jobs:
fi
[ -f ~/.shelltime/hooks/bash-preexec.sh ] || (echo "bash-preexec.sh not found in ~/.shelltime/hooks!" && exit 1)
ls ~/.shelltime
ls ~/.shelltime/bin
if command -v brew >/dev/null 2>&1 && brew list shelltime >/dev/null 2>&1; then
which shelltime || (echo "shelltime not in PATH via Homebrew!" && exit 1)
else
ls ~/.shelltime/bin
fi
ls ~/.shelltime/hooks
33 changes: 25 additions & 8 deletions install.bash
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,28 @@ command_exists() {
command -v "$1" >/dev/null 2>&1
}

# Flag to track whether Homebrew installation was used
BREW_INSTALLED=false

# Check for required commands
if ! command_exists curl; then
echo "Error: curl is not installed."
exit 1
fi

# On macOS, prefer Homebrew installation if brew is available
if [[ "$OS" == "Darwin" ]] && command_exists brew; then
echo "Homebrew detected on macOS. Attempting to install via brew..."
if brew install shelltime/tap/shelltime; then
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The brew install command returns a non-zero exit code if the package is already installed. This triggers the fallback logic and attempts a manual installation, which can lead to duplicate installations (one via Homebrew and one in ~/.shelltime/bin) and user confusion. Checking if the package is already installed prevents this unnecessary fallback.

Suggested change
if brew install shelltime/tap/shelltime; then
if brew list shelltime &>/dev/null || brew install shelltime/tap/shelltime; then

BREW_INSTALLED=true
echo "Successfully installed shelltime via Homebrew."
else
echo "Homebrew installation failed. Falling back to manual installation..."
fi
fi

if [ "$BREW_INSTALLED" = false ]; then
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The manual installation block (lines 34-194) is now nested within an if statement but lacks indentation. This makes the script significantly harder to read and maintain. Please indent the entire block to reflect the new logical structure.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep shell config bootstrap outside manual install gate

Wrapping the entire binary-install section in if [ "$BREW_INSTALLED" = false ] means macOS+Homebrew installs skip the fish config bootstrap that used to create ~/.config/fish/config.fish (and related PATH setup). On fresh machines where that file does not already exist, the later hook wiring only runs add_source_to_config when the file exists, so fish users end up with no hook source line after a successful Homebrew install.

Useful? React with 👍 / 👎.


CLI_FILE_NAME="https://github.com/malamtime/cli/releases/latest/download/cli_"
DAEMON_FILE_NAME="${CLI_FILE_NAME}daemon_"

Expand Down Expand Up @@ -127,14 +143,6 @@ if [[ "$OS" == "Darwin" ]] || [[ "$OS" == "Linux" ]]; then
# mv shelltime /c/Windows/System32/
fi

# Check if $HOME/.shelltime/daemon exists, create if not
if [ ! -d "$HOME/.shelltime/daemon" ]; then
mkdir -p "$HOME/.shelltime/daemon"
if [ $? -ne 0 ]; then
echo "Warning: Failed to create $HOME/.shelltime/daemon directory. Daemon functionality may be unavailable."
fi
fi

# Add $HOME/.shelltime/bin to user path
if [[ "$OS" == "Darwin" ]] || [[ "$OS" == "Linux" ]]; then
# For Zsh
Expand Down Expand Up @@ -185,6 +193,15 @@ if [[ "$OS" == "MINGW64_NT" ]] || [[ "$OS" == "MSYS_NT" ]] || [[ "$OS" == "CYGWI
echo "If you know where binaries should be installed on Windows, please open an issue: https://github.com/shelltime/cli"
fi

fi # end of manual installation block
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For manual installations, the binary is moved to ~/.shelltime/bin, but this directory is not added to the current process's PATH. Consequently, the shelltime daemon reinstall call at the end of the script (line 284) will fail during the first installation because the shelltime command won't be found in the current environment. Consider adding export PATH="$HOME/.shelltime/bin:$PATH" within the manual installation block to ensure the binary is available for subsequent setup steps.


# Check if $HOME/.shelltime/daemon exists, create if not
if [ ! -d "$HOME/.shelltime/daemon" ]; then
mkdir -p "$HOME/.shelltime/daemon"
if [ $? -ne 0 ]; then
echo "Warning: Failed to create $HOME/.shelltime/daemon directory. Daemon functionality may be unavailable."
fi
fi

# STEP 2
# insert a preexec and postexec script to user configuration, including `zsh` and `fish`
Expand Down
Loading