Skip to content

Commit

Permalink
zellij!
Browse files Browse the repository at this point in the history
  • Loading branch information
rentziass committed Dec 3, 2024
1 parent 5b6bc4c commit f5ade8b
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 20 deletions.
17 changes: 1 addition & 16 deletions bin/.local/bin/dotfiles
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,4 @@ if [[ $CODESPACES == "true" ]]; then
folder=/workspaces/.codespaces/.persistedshare/dotfiles
fi

session_name=dotfiles
tmux_running=$(pgrep tmux)
if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then
tmux new-session -s $session_name -c $folder
exit 0
fi

if ! tmux has-session -t $session_name 2> /dev/null; then
tmux new-session -ds $session_name -c $folder
fi

if [[ -z $TMUX ]]; then
tmux attach-session -t $session_name
else
tmux switch-client -t $session_name
fi
source $HOME/.local/bin/zellij-sessionizer $folder
38 changes: 38 additions & 0 deletions bin/.local/bin/zellij-sessionizer
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash

if [[ $# -eq 1 ]]; then
selected=$1
else
selected=$(find ~/dev -mindepth 1 -maxdepth 1 -type d | fzf)
fi

if [[ -z $selected ]]; then
exit 0
fi

selected_name=$(basename "$selected" | tr . _)

sessions=$(zellij list-sessions -s)
if ! echo "$sessions" | grep -q "$selected_name"; then
# create a tmp file containing the layout
tmpfile=$(mktemp)

cat > $tmpfile <<- EOF
layout {
cwd "$selected"
pane focus=true
pane size=1 borderless=true {
plugin location="zellij:tab-bar"
}
pane size=1 borderless=true {
plugin location="zellij:status-bar"
}
}
EOF


zellij -s "$selected_name" --new-session-with-layout $tmpfile
cd $selected
else
zellij attach "$selected_name"
fi
2 changes: 1 addition & 1 deletion install
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if [ -f "/etc/debian_version" ]; then
ripgrep \
kitty-terminfo

brew install jj
brew install jj zellij

curl -LO https://github.com/neovim/neovim/releases/latest/download/nvim.appimage
chmod u+x nvim.appimage
Expand Down
4 changes: 2 additions & 2 deletions zellij/.config/zellij/config.kdl
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ default_mode "normal"
// - true (default, enabled)
// - false
//
// pane_frames false
pane_frames false

// When attaching to an existing session with other users,
// should the session be mirrored (true)
Expand Down Expand Up @@ -355,7 +355,7 @@ default_mode "normal"
// copy_command "wl-copy" // wayland
// copy_command "pbcopy" // osx
//
// copy_command "pbcopy"
copy_command "rdm copy"

// Choose the destination for copied text
// Allows using the primary selection buffer (on x11/wayland) instead of the system clipboard.
Expand Down
9 changes: 9 additions & 0 deletions zellij/.config/zellij/layouts/default.kpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
layout {
pane
pane size=1 borderless=true {
plugin location="tab-bar"
}
pane size=1 borderless=true {
plugin location="status-bar"
}
}
2 changes: 1 addition & 1 deletion zsh/.zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ for function in $HOME/functions/*; do
source $function
done

bindkey -s "^F" "tmux-sessionizer\n"
bindkey -s "^F" "zellij-sessionizer\n"
bindkey -s "^T" "dotfiles\n"

# GOLANG
Expand Down

0 comments on commit f5ade8b

Please sign in to comment.