Skip to content

Instantly share code, notes, and snippets.

@zba
Last active April 21, 2025 10:28
Show Gist options
  • Save zba/1c524ced6d01b209643d066ec9b0e70f to your computer and use it in GitHub Desktop.
Save zba/1c524ced6d01b209643d066ec9b0e70f to your computer and use it in GitHub Desktop.
run zellij session in current dir, with own autoupdated HISTFILE, good for run in vscode with ctrl+a unlocks
#!/bin/bash
#name as ~/bin/runZellijSession.sh
session_name=$(echo $PWD|sed "s/\\//_/g")_
hist_path="$HOME/.config/zellij/bash_histories"
mkdir -p $hist_path
old_hist_file="$HOME/.bash_history"
export HISTFILE="$hist_path/$session_name"
if [ ! -f "$HISTFILE" ]; then
cp "$old_hist_file" "$HISTFILE"
fi
export HISTSIZE=100000
export HISTFILESIZE=100000
export HISTCONTROL=ignoredups
# Save history after each command
export PROMPT_COMMAND="history -a;history -r;$PROMPT_COMMAND"
zellij a -c $session_name||sleep 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment