Skip to content
This repository has been archived by the owner on May 19, 2022. It is now read-only.

Per tmux session history data

Kevin Brubeck Unhammer edited this page Jan 18, 2019 · 1 revision

Some People like compartmentalizing their life into different tmux sessions, and don't want files accessed in one session to appear as suggestions in a different session.

The following in your ~/.bashrc will give you one fasd history per tmux session, if you like to work that way:

export TMUX_SESSION=
if [[ -n ${TMUX+set} ]]; then
    TMUX_SESSION=$(tmux display-message -p "#S")
    if [[ -n ${TMUX_SESSION+set} ]]; then
        [[ -d ~/.fasd.d ]] || mkdir ~/.fasd.d
        export _FASD_DATA="$HOME/.fasd.d/${TMUX_SESSION%% *}" # pick the first word of the session name
        [[ -f $_FASD_DATA && -n $_FASD_DATA ]] || cp "$HOME"/.fasd "$_FASD_DATA"
    fi
fi

If the per-session fasd history doesn't exist, it copies the default ~/.fasd file.