Preserve ssh

This commit is contained in:
Thomas Forgione 2024-06-21 17:28:36 +02:00
parent 74152e04fc
commit e2559a9f85
5 changed files with 38 additions and 3 deletions

View File

@ -60,7 +60,7 @@ x = 0
y = 0
[[keyboard.bindings]]
action = "SpawnNewInstance"
command = "clone-terminal"
key = "E"
mods = "Control|Shift"
@ -636,8 +636,8 @@ semantic_escape_chars = ",│`|:\"' ()[]{}<>"
[window]
decorations = "none"
dynamic_title = false
opacity = 0.8
dynamic_title = true
opacity = 0.85
[window.dimensions]
columns = 0

9
bin/clone-terminal Executable file
View File

@ -0,0 +1,9 @@
#!/usr/bin/env bash
WINDOW_ID=$(xdotool getactivewindow)
WM_NAME=$(xprop -id $WINDOW_ID WM_NAME | cut -d '"' -f 2)
if [ -f $HOME/.config/terminalscwd/$WM_NAME.ssh ]; then
echo $(cat $HOME/.config/terminalscwd/$WM_NAME.ssh) > ~/toto.txt
alacritty -e sh -c "TERMINAL_UUID=$WM_NAME ssh $(cat $HOME/.config/terminalscwd/$WM_NAME.ssh)"
fi

View File

@ -14,6 +14,11 @@
# Uncomment following line if you want to disable autosetting terminal title.
DISABLE_AUTO_TITLE="true"
if [ -z $TERMINAL_UUID ]; then
export TERMINAL_UUID=$(uuidgen)
fi
echo -en "\e]2;$TERMINAL_UUID\a"
# Uncomment following line if you want red dots to be displayed while waiting for completion
# COMPLETION_WAITING_DOTS="true"

20
zsh/preserve-cwd-ssh.zsh Normal file
View File

@ -0,0 +1,20 @@
if [ "$PRESERVE_SSH_CWD" = "true" ]; then
mkdir -p $HOME/.config/terminalscwd/
cd() {
builtin cd $1
pwd > $HOME/.config/terminalscwd/$TERMINAL_UUID.pwd
}
if [ -f $HOME/.config/terminalscwd/$TERMINAL_UUID.pwd ]; then
cd $(cat $HOME/.config/terminalscwd/$TERMINAL_UUID.pwd)
else
cd
fi
ssh() {
echo $1 > $HOME/.config/terminalscwd/$TERMINAL_UUID.ssh
/usr/bin/ssh $@
rm $HOME/.config/terminalscwd/$TERMINAL_UUID.ssh
pwd > $HOME/.config/terminalscwd/$TERMINAL_UUID.pwd
}
fi

1
zshrc
View File

@ -31,6 +31,7 @@ source $DOTFILES/zsh/config.zsh
source $DOTFILES/zsh/path.zsh
source $DOTFILES/zsh/exports.zsh
source $DOTFILES/zsh/aliases.zsh
source $DOTFILES/zsh/preserve-cwd-ssh.zsh
if [ -f $DOTFILES/zsh/extraconfig.zsh ]; then
source $DOTFILES/zsh/extraconfig.zsh