addet correct tmux and neovim configuration

This commit is contained in:
pika 2025-03-08 19:51:28 +01:00
parent 748f91e772
commit 4645dcf0a1

View file

@ -219,25 +219,50 @@ _alias() {
alias ll="ls --color=always -lph" alias ll="ls --color=always -lph"
fi fi
# ─< t stands for tmux >──────────────────────────────────────────────────────────────────── # Function to determine which Neovim command to use
choose_nvim() {
if [ -n "$DISPLAY" ] || [ -n "$WAYLAND_DISPLAY" ]; then
# If in a graphical environment, use Neovide
if command_exists neovide; then
echo "neovide --fork"
return
fi
elif [ -n "$TMUX" ]; then
# If inside an active tmux session, use nvim
echo "command nvim"
return
fi
# Default to nvim
echo "command nvim"
}
# Set up Neovim aliases based on environment
if command_exists nvim; then
alias cnvim="command nvim"
alias nvim="$(choose_nvim)"
if [ -d "$HOME/.config/nvchad" ]; then
alias nvchad='NVIM_APPNAME="nvchad" command nvim'
alias neochad='NVIM_APPNAME="nvchad" neovide --fork'
fi
fi
# Tmux session manager
if command_exists tmux; then if command_exists tmux; then
local tmux_y="$(echo '-- tmux-session active! | connecting to active session --')"
local tmux_n="$(echo '-- no tmux-session found! | creating one --')"
ta() { ta() {
command tmux list-sessions >/dev/null 2>&1 if tmux list-sessions >/dev/null 2>&1; then
if [ $? -eq 0 ]; then echo "-- tmux session active! | Connecting to active session --"
echo "${tmux_y}"
sleep 0.3 sleep 0.3
tmux attach tmux attach
else else
echo "${tmux_n}" echo "-- No tmux session found! | Creating one --"
sleep 0.3 sleep 0.3
tmux tmux
fi fi
} }
alias ts="tmux source $HOME/.tmux.conf" alias ts="tmux source $HOME/.tmux.conf"
fi fi
# ─< t stands for trash(-cli) >─────────────────────────────────────────────────────────────── # ─< t stands for trash(-cli) >───────────────────────────────────────────────────────────────
if command_exists trash; then if command_exists trash; then
alias rm="trash" alias rm="trash"
@ -412,19 +437,6 @@ _coding_() {
export EDITOR="codium" export EDITOR="codium"
fi fi
# ─< neovide, the best frontend for any neovim-config >───────────────────────────────────
if command_exists nvim; then
alias cnvim="command nvim"
if command_exists neovide; then
alias nvim="neovide --fork"
fi
if [ -d "$HOME/.config/nvchad" ]; then
alias nvchad='NVIM_APPNAME="nvchad" command nvim'
alias neochad='NVIM_APPNAME="nvchad" neovide --fork'
fi
fi
# Function to get the IP address # Function to get the IP address
get_ip() { get_ip() {
ip a | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | cut -d/ -f1 | head -n 1 ip a | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | cut -d/ -f1 | head -n 1