Add tmux config and replace zellij with tmux in zshrc.

Zhrc also has some light refactoring, and has added a zsh local file
which gets sourced if it exists, useful for adding local environment
variables
This commit is contained in:
Martin Larsson 2024-06-29 14:01:03 +02:00
parent 6ebb641656
commit d094fce66d
6 changed files with 186 additions and 6 deletions

View file

@ -17,12 +17,19 @@ set_custom_keybindings() {
init() {
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
[ -f ~/.zshrc_local ] && source ~/.zshrc_local
eval "$(fzf --zsh)"
eval "$(zoxide init --cmd cd zsh)"
set_custom_keybindings
}
add_to_path() {
if [[ -d $1 ]] && [[ ! $PATH =~ $1 ]]; then
export PATH=$1:$PATH
fi
}
# Workaround to make sure that the custom keybindings
# are persistent when switching modes in zsh-vi-mode ...
# It still breaks sometimes when exiting insert mode, but its better than not having it at all
@ -36,9 +43,8 @@ if [[ "$(uname)" == "Darwin" ]]; then
fi
# Paths
if [[ -d $HOME/.local/nvim ]]; then
export PATH=$HOME/.local/nvim/bin:$PATH # Nightly neovim
fi
add_to_path $HOME/.local/bin
add_to_path $HOME/.local/nvim/bin
# Set the directory we want to store zinit and plugins
ZINIT_HOME="${XDG_DATA_HOME:-$HOME/.local/share}/zinit/zinit.git"
@ -132,9 +138,14 @@ bwp() {
bw get password "$1" | wlc
}
# Make sure that zellij isn't recursively started on shell startup
if [[ -z $ZELLIJ ]]; then
zellij --layout ~/.config/zellij/top-bar.kdl
# Check if tmux is already running or if the session is interactive
if [[ -z "$TMUX" ]] && [[ $- == *i* ]]; then
# Create a new tmux session, if one doesnt exist, give it the main name, never attach to a session
if tmux ls &> /dev/null; then
tmux attach
else
tmux new-session -s main
fi
fi
fastfetch