Compare commits

...

23 Commits
dev ... main

Author SHA1 Message Date
Thomas Forgione 27753a09a8 Update alacritty config 2024-10-28 21:22:16 +01:00
Thomas Forgione f3ef0eb885 Clean theme 2024-10-19 02:51:02 +02:00
Thomas Forgione 025c1b5101 Clean 2024-10-19 02:47:04 +02:00
Thomas Forgione 110164b71e Adds postscan 2024-09-27 15:32:59 +02:00
Thomas Forgione 9de770c4bc Support j 2024-09-07 21:06:30 +02:00
Thomas Forgione f7b4e36cc3 Flask default port 2024-08-23 09:14:20 +02:00
Thomas Forgione 8800125c06 Opacity 2024-08-12 12:32:34 +02:00
Thomas Forgione 8af310d0a2 Fix bug on cd "" 2024-07-31 10:01:49 +02:00
Thomas Forgione 6ba78c412b No crash on space 2024-07-24 11:32:23 +02:00
Thomas Forgione c3a3d16b9f quote 2024-07-12 09:58:27 +02:00
Thomas Forgione bd0cb3c6c2 Remove echo 2024-07-03 16:47:51 +02:00
Thomas Forgione 1facb0079a Prevent bug when PARENT_TERMINAL is empty 2024-06-24 14:09:50 +02:00
Thomas Forgione feebba4e12 Working 2024-06-23 16:31:17 +02:00
Thomas Forgione 9241ff0c0d Opacity 2024-06-22 17:43:45 +02:00
Thomas Forgione a02648109d Adds typescript 2024-06-22 13:24:50 +02:00
Thomas Forgione 9e8c7bed3d Numbat alias 2024-06-22 00:28:02 +02:00
Thomas Forgione 8ba58d1475 No need for notify send 2024-06-21 22:23:53 +02:00
Thomas Forgione 6e63a19f04 Fix bugs 2024-06-21 18:40:01 +02:00
Thomas Forgione 90b5a8ad61 IT FUCKING WORKS 2024-06-21 18:16:54 +02:00
Thomas Forgione 62212e6b83 Better 2024-06-21 18:06:29 +02:00
Thomas Forgione b45049ac27 Clean 2024-06-21 17:52:13 +02:00
Thomas Forgione 3ff0c82b3f Fix bug 2024-06-21 17:32:39 +02:00
Thomas Forgione e2559a9f85 Preserve ssh 2024-06-21 17:28:36 +02:00
13 changed files with 127 additions and 106 deletions

View File

@ -1,3 +1,4 @@
[general]
live_config_reload = true
[bell]
@ -60,7 +61,7 @@ x = 0
y = 0
[[keyboard.bindings]]
action = "SpawnNewInstance"
command = "clone-terminal"
key = "E"
mods = "Control|Shift"
@ -637,7 +638,7 @@ semantic_escape_chars = ",│`|:\"' ()[]{}<>"
[window]
decorations = "none"
dynamic_title = false
opacity = 0.8
opacity = 0.6
[window.dimensions]
columns = 0

11
bin/clone-terminal Executable file
View File

@ -0,0 +1,11 @@
#!/usr/bin/env bash
# Extract parent window uuid
WINDOW_ID=$(xdotool getactivewindow)
WM_NAME=$(xprop -id $WINDOW_ID WM_NAME | cut -d '"' -f 2)
# Generate new uuid for new terminal
uuid=$(uuidgen)
alacritty --title $uuid -e sh -c "TERMINAL_UUID=$uuid PARENT_TERMINAL=$WM_NAME exec $SHELL"

4
bin/new-terminal Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env bash
UUID=$(uuidgen)
alacritty --title $UUID -e sh -c "TERMINAL_UUID=$UUID exec $SHELL"

9
bin/post-scan Executable file
View File

@ -0,0 +1,9 @@
#!/usr/bin/env bash
# auto fix issues with my scanner
input="$3"
color=$(magick "$input" -format "%[hex:u.p{100,-1}]" info:)
tmp=$(mktemp --suffix=.png)
magick "$input" -page +0-100 -background \#$color -flatten -auto-level $tmp
magick $tmp -quality 100 "${input%.*}.pdf"
rm -rf $tmp "$input"

3
bin/quote Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env bash
xclip -sel clip -o | sed -e 's/^/> /' | xclip -sel clip

View File

@ -17,6 +17,11 @@
"python": {
"command": "pylsp",
"filetypes": ["python"]
},
"typscript": {
"command": "typescript-language-server",
"args": ["--stdio"],
"filetypes": ["typescript"]
}
}
}

View File

@ -72,6 +72,9 @@ cdw() {
fi
}
# Numbat shortcut
alias nb=numbat
# Initialize thefuck
command -v thefuck > /dev/null 2>&1

View File

@ -32,5 +32,8 @@ if [ -d $HOME/.venv ]; then
export VIRTUAL_ENV=$HOME/.venv
fi
# Use port 8000 by default for flask, cause why would we use anything different?
export FLASK_RUN_PORT=8000
export TERM=xterm-256color
export REPORTTIME=5

View File

@ -1,103 +0,0 @@
# ZSH Theme - Preview: http://dl.dropbox.com/u/4109351/pics/gnzh-zsh-theme.png
# Based on bira theme
# load some modules
autoload -U colors zsh/terminfo # Used in the colour alias below
colors
setopt prompt_subst
# make some aliases for the colours: (coud use normal escap.seq's too)
for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do
eval PR_$color='%{$fg[${(L)color}]%}'
done
eval PR_NO_COLOR="%{$terminfo[sgr0]%}"
eval PR_BOLD="%{$terminfo[bold]%}"
# Check the UID
if [[ $UID -ge 1000 ]]; then # normal user
# If ssh
if [[ -n "$SSH_CLIENT" || -n "$SSH2_CLIENT" ]]; then
eval PR_USER='${PR_GREEN}%n${PR_NO_COLOR}'
eval PR_USER_OP='${PR_GREEN}%#${PR_NO_COLOR}'
local PR_ARROW_UP='${PR_GREEN}┌── ${PR_NO_COLOR}'
local PR_ARROW_DOWN='${PR_GREEN}└${PR_NO_COLOR}'
local PR_PROMPT='$PR_GREEN▷$PR_NO_COLOR'
else
eval PR_USER='${PR_MAGENTA}%n${PR_NO_COLOR}'
eval PR_USER_OP='${PR_BLUE}%#${PR_NO_COLOR}'
local PR_PROMPT='$PR_MAGENTA▷$PR_NO_COLOR'
local PR_ARROW_UP='$PR_MAGENTA┌── ${PR_NO_COLOR}'
local PR_ARROW_DOWN='$PR_MAGENTA└${PR_NO_COLOR}'
fi
elif [[ $UID -eq 0 ]]; then # root
eval PR_USER='${PR_RED}%n${PR_NO_COLOR}'
eval PR_USER_OP='${PR_RED}%#${PR_NO_COLOR}'
local PR_ARROW_UP='${PR_RED}┌── ${PR_NO_COLOR}'
local PR_ARROW_DOWN='${PR_RED}└${PR_NO_COLOR}'
local PR_PROMPT='$PR_RED▷$PR_NO_COLOR'
fi
# Check if we are on SSH or not
if [[ -n "$SSH_CLIENT" || -n "$SSH2_CLIENT" ]]; then
eval PR_HOST='${PR_GREEN}%M${PR_NO_COLOR}' #SSH
else
eval PR_HOST='${PR_BLUE}%M${PR_NO_COLOR}' # no SSH
fi
# local return_code="%(?..%{$PR_RED%}%? ↵%{$PR_NO_COLOR%})"
truncated_pwd() {
local max_allowed_size=$(( `tput cols` - 30 ))
local path_name=$(print -rD $PWD)
local new_path_name=""
local truncated=0
while [ ${#path_name} -gt $max_allowed_size ]; do
truncated=1
new_path_name=`echo $path_name | cut -d '/' -f 2-`
if [[ "$new_path_name" == "$path_name" ]]; then
break
fi
path_name=$new_path_name
done
if [ $truncated -eq 1 ]; then
echo "~/.../"$path_name
else
echo $path_name
fi
}
local user_host='$PR_BOLD${PR_USER}$PR_BOLD'
local current_dir='$PR_BOLD%{$PR_BLUE%}$(truncated_pwd)$PR_NO_COLOR%}'
local rvm_ruby=''
if which rvm-prompt &> /dev/null; then
rvm_ruby='%{$PR_RED%}$(rvm-prompt i v g s)%{$PR_NO_COLOR%}'
else
if which rbenv &> /dev/null; then
rvm_ruby='%{$PR_RED%}$(rbenv version | sed -e "s/ (set.*$//")%{$PR_NO_COLOR%}'
fi
fi
local return_code=""
local git_branch='$(git_prompt_info)'
local PR_DATE='${PR_BOLD}${PR_MAGENTA}[%D{%H:%M}]${PR_NO_COLOR}'
#PROMPT="${user_host} ${current_dir} ${rvm_ruby}${git_branch}$PR_PROMPT "
separator='${PR_YELLOW}::${PR_NO_COLOR}'
tty | read tty_value
if [[ $tty_value == *pts* ]]; then # if in a tty
PROMPT="$PR_ARROW_UP${PR_DATE} ${user_host}${separator}${PR_NO_COLOR}${current_dir} ${rvm_ruby}${git_branch}
$PR_ARROW_DOWN$PR_PROMPT ${PR_NO_COLOR}"
return_code="%(?.%{$PR_GREEN%}%? ↵%{$PR_NO_COLOR%}.%{$PR_RED%}%? ↵%{$PR_NO_COLOR%})"
else
eval PR_NO_COLOR="$PR_WHITE"
PROMPT="${user_host} ${current_dir} ${rvm_ruby} ${git_branch}> ${PR_NO_COLOR}"
return_code="%(?.%{$PR_GREEN%}%? <%{$PR_NO_COLOR%}.%{$PR_RED%}%? <%{$PR_NO_COLOR%})"
fi
RPS1=" ${return_code}"
ZSH_THEME_GIT_PROMPT_PREFIX="%{$PR_YELLOW%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$PR_NO_COLOR%}"
TMOUT=30
TRAPALRM() {
zle reset-prompt
}

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

@ -0,0 +1,84 @@
if [ "$PRESERVE_SSH_CWD" = "true" ]; then
# Ensure the directory where we store terminal cwds and ssh exists
mkdir -p $HOME/.config/terminalscwd/
# Alias for cd: when we change directory, we write the new cwd in the file corresponding to the terminal uuid
cd() {
if [ -z "$1" ]; then
directory=$HOME
elif [[ "$1" == "-P" ]] && [ -z $2 ]; then
directory="$HOME"
option="$1"
elif [[ "$1" == "-P" ]]; then
directory="$2"
option="$1"
else
directory="$1"
fi
if [ -z "$option" ]; then
builtin cd "$directory"
else
builtin cd "$option" "$directory"
fi
pwd > $HOME/.config/terminalscwd/$TERMINAL_UUID.cwd
}
# Alias for ssh: when we ssh somewhere, we write it so that we know we should ssh when cloning terminal
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.cwd
}
# If terminal uuid does not exit
if [ -z $TERMINAL_UUID ]; then
# Generate one
export TERMINAL_UUID=$(uuidgen)
fi
# Copy state for new terminal
if [ ! -z $PARENT_TERMINAL ]; then
if [ -f $HOME/.config/terminalscwd/$PARENT_TERMINAL.cwd ]; then
cp $HOME/.config/terminalscwd/$PARENT_TERMINAL.cwd $HOME/.config/terminalscwd/$TERMINAL_UUID.cwd
fi
if [ -f $HOME/.config/terminalscwd/$PARENT_TERMINAL.ssh ]; then
cp $HOME/.config/terminalscwd/$PARENT_TERMINAL.ssh $HOME/.config/terminalscwd/$TERMINAL_UUID.ssh
fi
fi
# When we're done, delete the uuid files
preserve_ssh_cleanup() {
rm -rf $HOME/.config/terminalscwd/$TERMINAL_UUID.cwd
rm -rf $HOME/.config/terminalscwd/$TERMINAL_UUID.ssh
}
trap preserve_ssh_cleanup EXIT
# If there already is a file corresponding to the current uuid
if [ -f $HOME/.config/terminalscwd/$TERMINAL_UUID.cwd ]; then
# Go the the right directory
cd "$(cat $HOME/.config/terminalscwd/$TERMINAL_UUID.cwd)"
else
# Use our custom alias to go to home, and set the file cwd
cd
fi
# If we're running in an ssh session
if [ -f $HOME/.config/terminalscwd/$TERMINAL_UUID.ssh ]; then
# Run the ssh command, and exec shell in the end so the terminal doesn't exit at end of ssh
ssh $(cat $HOME/.config/terminalscwd/$TERMINAL_UUID.ssh)
fi
fi

3
zshrc
View File

@ -21,7 +21,7 @@ DISABLE_AUTO_UPDATE="true"
ZSH=$HOME/.config/ohmyzsh
ZSH_CUSTOM=$HOME/.config/dotfiles/zsh/ohmyzsh
ZSH_THEME="laptop"
ZSH_THEME="tforgione"
if [ -f $DOTFILES/zsh/env.zsh ]; then
source $DOTFILES/zsh/env.zsh
@ -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