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: 3 additions & 3 deletions hooks/bash.bash
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ preexec_invoke_cmd() {
return
fi

shelltime track -s=bash -id=$SESSION_ID -cmd="$CMD" -p=pre &> /dev/null
shelltime track -s=bash -id=$SESSION_ID -cmd="$CMD" -p=pre --ppid=$PPID &> /dev/null
}

# Function to be executed after each command (before prompt)
Expand All @@ -57,13 +57,13 @@ precmd_invoke_cmd() {
if [[ "$CMD" =~ ^shelltime ]]; then
return
fi

# Ensure CMD is not empty or the precmd_invoke_cmd itself
if [ -z "$CMD" ] || [ "$CMD" == "precmd_invoke_cmd" ]; then
return
fi

shelltime track -s=bash -id=$SESSION_ID -cmd="$CMD" -p=post -r=$LAST_RESULT &> /dev/null
shelltime track -s=bash -id=$SESSION_ID -cmd="$CMD" -p=post -r=$LAST_RESULT --ppid=$PPID &> /dev/null
}

# Set the functions for bash-preexec
Expand Down
7 changes: 5 additions & 2 deletions hooks/fish.fish
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ end
# Create a timestamp for the session when the shell starts
set -g SESSION_ID (date +%Y%m%d%H%M%S)

# Capture parent process ID at shell startup (fish doesn't have native $PPID)
set -g FISH_PPID (ps -o ppid= -p %self | string trim)

# Define the preexec function
function fish_preexec --on-event fish_preexec
if string match -q 'exit*' -- $argv; or string match -q 'logout*' -- $argv; or string match -q 'reboot*' -- $argv
return
end

shelltime track -s=fish -id=$SESSION_ID -cmd="$argv" -p=pre > /dev/null
shelltime track -s=fish -id=$SESSION_ID -cmd="$argv" -p=pre --ppid=$FISH_PPID > /dev/null
end

# Define the postexec function
Expand All @@ -26,5 +29,5 @@ function fish_postexec --on-event fish_postexec
return
end
# This event is triggered before each prompt, which is after each command
shelltime track -s=fish -id=$SESSION_ID -cmd="$argv" -p=post -r=$LAST_RESULT > /dev/null
shelltime track -s=fish -id=$SESSION_ID -cmd="$argv" -p=post -r=$LAST_RESULT --ppid=$FISH_PPID > /dev/null
end
4 changes: 2 additions & 2 deletions hooks/zsh.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ preexec() {
return
fi

shelltime track -s=zsh -id=$SESSION_ID -cmd=$CMD -p=pre &> /dev/null
shelltime track -s=zsh -id=$SESSION_ID -cmd="$CMD" -p=pre --ppid=$PPID &> /dev/null
}

# Define the postexec function (in zsh, it's called precmd)
Expand All @@ -30,5 +30,5 @@ precmd() {
if [[ $CMD =~ ^(exit|logout|reboot) ]]; then
return
fi
shelltime track -s=zsh -id=$SESSION_ID -cmd=$CMD -p=post -r=$LAST_RESULT &> /dev/null
shelltime track -s=zsh -id=$SESSION_ID -cmd="$CMD" -p=post -r=$LAST_RESULT --ppid=$PPID &> /dev/null
}
Loading