I was having major delays and even tried moving my system dataset but still found it may ssh’ing into the shell horrid. I have hacked together a quick startup script to load the daemon when I ssh into the box. It check if the daemon is running first. It seems to be working so far. I just include the Atuin stuff in a script that gets sourced from the .zshrc.
setopt interactive_comments
source $HOME/.atuin/bin/env
atsearch() {
atuin search "$1" --format "{host}\t{command}"
}
is_atuin_daemon_running() {
if pgrep -f "atuin daemon" > /dev/null; then
return 0 # true
else
return 1 # false
fi
}
# Not used but included.
stop_all_atuin_daemons() {
# Find all process IDs of "atuin daemon"
local pids
pids=$(pgrep -f "atuin daemon")
if [[ -n "$pids" ]]; then
# Loop through each PID and kill it
for pid in $pids; do
kill "$pid" && echo "Atuin daemon with PID $pid stopped."
done
else
echo "No running instances of atuin daemon found."
fi
}
# if running on truenas, then launch the daemon because of the sqllite bug on zfs
if uname -a | grep -q "truenas"; then
SOCKET="$HOME/.local/share/atuin/atuin.sock"
# Check if the socket file exists and is active
if [ -S "$SOCKET" ] && nc -zU "$SOCKET" 2>/dev/null; then
echo "Atuin daemon is runing."
else
echo "Starting atuin daemon"
if [ -S $SOCKET ]; then
rm $SOCKET
fi
nohup atuin daemon >/dev/null 2>&1 &
fi
fi
eval "$(atuin init zsh --disable-up-arrow)"
#lsof -c "atuin" | grep sock
alias h="atsearch"```
Thanks for posting this.
I finally got my box updated from Core to Scale and immediately started getting hit by the sqlite / ZFS bug. Your RC script nicely gets the daemon running.
I did have one change where instead of checking for “truenas”, I’m checking the type of the filesystem the database is on. This keeps my RC file a bit more generic for use on other systems. So my if statement is instead:
if [[ "$(stat -f -c %T $HOME/.local/share/atuin)" == 'zfs' ]]; then
That is a good idea! I did not think that far ahead. I am going to see if I can edit my post with your change
Rob
cat check_autin_daemon.sh
setopt interactive_comments
source $HOME/.atuin/bin/env
atsearch() {
atuin search "$1" --format "{host}\t{command}"
}
is_atuin_daemon_running() {
if pgrep -f "atuin daemon" > /dev/null; then
return 0 # true
else
return 1 # false
fi
}
# Not used but included.
stop_all_atuin_daemons() {
# Find all process IDs of "atuin daemon"
local pids
pids=$(pgrep -f "atuin daemon")
if [[ -n "$pids" ]]; then
# Loop through each PID and kill it
for pid in $pids; do
kill "$pid" && echo "Atuin daemon with PID $pid stopped."
done
else
echo "No running instances of atuin daemon found."
fi
}
# if running on truenas, then launch the daemon because of the sqllite bug on zfs
#if uname -a | grep -q "truenas"; then
# if the database is running on zfs, then launch the daemon because of the sqllite bug on zfs, suggested by fracai Arno
if [[ "$(stat -f -c %T $HOME/.local/share/atuin)" == 'zfs' ]]; then
SOCKET="$HOME/.local/share/atuin/atuin.sock"
# Check if the socket file exists and is active
if [ -S "$SOCKET" ] && nc -zU "$SOCKET" 2>/dev/null; then
echo "Atuin daemon is runing."
else
echo "Starting atuin daemon"
if [ -S $SOCKET ]; then
rm $SOCKET
fi
nohup atuin daemon >/dev/null 2>&1 &
fi
fi
eval "$(atuin init zsh --disable-up-arrow)"
#lsof -c "atuin" | grep sock
alias h="atsearch"```