feat manage script

This commit is contained in:
2025-02-24 09:51:41 +00:00
commit 1a3a374f3b
45 changed files with 2149 additions and 0 deletions

40
config/shared/alacritty Normal file
View File

@@ -0,0 +1,40 @@
live_config_reload = true
[env]
TERM = "xterm-256color"
[font]
normal = { family = "SF Mono", style = "Regular" }
size = 12
offset = { x = 0, y = 0 }
[window]
decorations_theme_variant = "Dark"
padding = { x = 4, y = 0 }
dynamic_padding = false
resize_increments = true
[keyboard]
bindings = [
# Create new window
{ action = "SpawnNewInstance", key = "N", mods = "Command" },
# Jump back one word
{ key = "Left", mods = "Alt", chars = "\u001bb" },
# Jump forward one word
{ key = "Right", mods = "Alt", chars = "\u001bf" },
# Move to start of line
{ key = "Left", mods = "Command", chars = "\u0001" },
# Move to end of line
{ key = "Right", mods = "Command", chars = "\u0005" },
# Delete backwards
{ key = "Back", mods = "Alt", chars = "\u001B\u007F" }, # word
{ key = "Back", mods = "Command", chars = "\u0015" }, # line
# Delete forwards
{ key = "Delete", mods = "Alt", chars = "\u001Bd" }, # word
{ key = "Delete", mods = "Command", chars = "\u000B" } # line
]
[scrolling]
multiplier = 1

97
config/shared/bin/colortest Executable file
View File

@@ -0,0 +1,97 @@
#!/usr/bin/env bash
# Test black and white
echo "=== Black and White ==="
printf "Normal text\n"
printf "\e[1mBold text\e[0m\n"
printf "\e[7mReverse text\e[0m\n\n"
# Test 4-bit ANSI (16 colors)
echo "=== 4-bit ANSI Colors (16 colors) ==="
echo "Foreground colors:"
for i in {30..37}; do
printf "\e[${i}m\\e[${i}m\e[0m "
done
echo -e "\n"
echo "Background colors:"
for i in {40..47}; do
printf "\e[${i}m\\e[${i}m\e[0m "
done
echo -e "\n"
echo "Bright foreground colors:"
for i in {90..97}; do
printf "\e[${i}m\\e[${i}m\e[0m "
done
echo -e "\n"
echo "Bright background colors:"
for i in {100..107}; do
printf "\e[${i}m\\e[${i}m\e[0m "
done
echo -e "\n\n"
# Test 8-bit ANSI (256 colors)
echo "=== 8-bit ANSI Colors (256 colors) ==="
echo "16 System Colors:"
for i in {0..15}; do
printf "\e[48;5;${i}m \e[0m"
if [ $((($i + 1) % 8)) == 0 ]; then
echo
fi
done
echo
echo "216 RGB Colors:"
for i in {16..231}; do
printf "\e[48;5;${i}m \e[0m"
if [ $((($i - 15) % 36)) == 0 ]; then
echo
fi
done
echo
echo "24 Grayscale Colors:"
for i in {232..255}; do
printf "\e[48;5;${i}m \e[0m"
if [ $((($i - 231) % 12)) == 0 ]; then
echo
fi
done
echo -e "\n"
# Test 24-bit true color
echo "=== 24-bit True Color (16.7 million colors) ==="
echo "RGB Color Gradient:"
awk 'BEGIN{
s="/\\";
for (colnum = 0; colnum<77; colnum++) {
r = 255-(colnum*255/76);
g = (colnum*510/76);
b = (colnum*255/76);
if (g>255) g = 510-g;
printf "\033[48;2;%d;%d;%dm", r,g,b;
printf "\033[38;2;%d;%d;%dm", 255-r,255-g,255-b;
printf "%s\033[0m", substr(s,colnum%2+1,1);
}
printf "\n";
}'
echo "RGB Color Bars:"
for r in 0 127 255; do
for g in 0 127 255; do
for b in 0 127 255; do
printf "\e[48;2;${r};${g};${b}m \e[0m"
done
printf " "
done
echo
done
echo
# Print terminal information
echo "=== Terminal Information ==="
echo "TERM: $TERM"
echo "COLORTERM: $COLORTERM"
echo "Reported colors (tput colors): $(tput colors)"

18
config/shared/bin/detect_keys Executable file
View File

@@ -0,0 +1,18 @@
#!/bin/zsh
echo "Press any key combination. Press Ctrl+C to exit."
while true; do
result=""
escape_sequence=""
read -sk 1 key
if [[ $key == $'\x1b' ]]; then
escape_sequence+="^["
while read -sk 1 -t 0.01 next_key; do
escape_sequence+="$next_key"
done
result="$escape_sequence"
else
result="$key"
fi
echo -E "Key: $result"
done

41
config/shared/bin/dev Executable file
View File

@@ -0,0 +1,41 @@
# --rm: automatically remove the container when it exits
# Check if a container name was provided
if [ $# -eq 0 ]; then
echo "Usage: $0 <container_name>"
exit 1
fi
IMAGE="web-stack"
NAME="${IMAGE}-$1"
# Function to exec into the container
exec_into_container() {
docker exec --detach-keys "ctrl-q,ctrl-p" -it $NAME /bin/zsh
}
# Check if the container exists
if [ "$(docker ps -a -q -f name=$NAME)" ]; then
# Container exists, start it if it's not running
if [ ! "$(docker ps -q -f name=$NAME)" ]; then
echo "Container $NAME exists but is not running. Starting it..."
docker start $NAME
else
echo "Container $NAME is already running."
fi
else
echo "Container $NAME does not exist. Creating and running it in detached mode..."
docker run -d \
--detach-keys "ctrl-q,ctrl-p" \
--network host \
-v $HOME/.ssh:/home/dev/.ssh \
-v $PWD:/workspace \
--name $NAME \
--init \
$IMAGE \
tail -f /dev/null
fi
# Exec into the container
echo "Executing into container $NAME..."
exec_into_container

29
config/shared/bin/ssh-forward Executable file
View File

@@ -0,0 +1,29 @@
#!/bin/bash
# Function to display usage information
usage() {
echo "Usage: $0 <user@host> <port1> [port2] [port3] ..."
exit 1
}
# Ensure at least two arguments are provided: host and one port
if [ "$#" -lt 2 ]; then
usage
fi
# Extract the host from the first argument
HOST="$1"
shift # Shift the arguments so that $@ contains the remaining ports
# Initialize the PORTS variable
PORTS=""
# Iterate over the remaining arguments, which are the ports
for port in "$@"; do
PORTS="$PORTS -L ${port}:localhost:${port}"
done
# Construct and run the SSH command
SSH_CMD="ssh -N -T -o ExitOnForwardFailure=yes $HOST $PORTS"
echo "Running: $SSH_CMD"
$SSH_CMD

View File

@@ -0,0 +1,48 @@
# Terminal
term = "xterm-256color"
# Fonts
font-family = "SF Mono"
font-family = "SF Mono"
font-size = 12
font-thicken = true
# Cell width (affects letter spacing)
adjust-cell-width = -1
adjust-cell-height = -1
adjust-font-baseline = -1
# Cursor
cursor-style-blink = false
cursor-style = block
shell-integration-features = no-cursor
# Icon
# macos-icon = custom-style
# macos-icon-frame = plastic
# macos-icon-ghost-color = cba6f7
# macos-icon-screen-color = 181825
# Window
#background = #181818
background = #000000
window-theme = dark
window-width = 100
window-height = 26
window-padding-x = 4
window-padding-y = 2
window-colorspace = display-p3
window-decoration = true
macos-titlebar-style = native
# Resize by row
#window-step-resize = true
#window-padding-balance = true
# Background
background-opacity = 1
background-blur-radius = 0

7
config/shared/git Normal file
View File

@@ -0,0 +1,7 @@
[init]
defaultBranch = main
[user]
name = Tomas Mirchev
email = contact@tomastm.com
[pull]
rebase = true

63
config/shared/htop/htoprc Normal file
View File

@@ -0,0 +1,63 @@
# Beware! This file is rewritten by htop when settings are changed in the interface.
# The parser is also very primitive, and not human-friendly.
htop_version=3.2.2
config_reader_min_version=3
fields=0 48 17 18 38 39 40 2 46 47 49 1
hide_kernel_threads=1
hide_userland_threads=1
hide_running_in_container=0
shadow_other_users=0
show_thread_names=0
show_program_path=1
highlight_base_name=0
highlight_deleted_exe=1
shadow_distribution_path_prefix=0
highlight_megabytes=1
highlight_threads=1
highlight_changes=0
highlight_changes_delay_secs=5
find_comm_in_cmdline=1
strip_exe_from_cmdline=1
show_merged_command=0
header_margin=1
screen_tabs=1
detailed_cpu_time=0
cpu_count_from_one=0
show_cpu_usage=1
show_cpu_frequency=0
show_cpu_temperature=0
degree_fahrenheit=0
update_process_names=0
account_guest_in_cpu_meter=0
color_scheme=0
enable_mouse=1
delay=15
hide_function_bar=0
header_layout=two_50_50
column_meters_0=AllCPUs Memory Swap
column_meter_modes_0=1 1 1
column_meters_1=Tasks LoadAverage Uptime
column_meter_modes_1=2 2 2
tree_view=0
sort_key=47
tree_sort_key=0
sort_direction=-1
tree_sort_direction=1
tree_view_always_by_pid=0
all_branches_collapsed=0
screen:Main=PID USER PRIORITY NICE M_VIRT M_RESIDENT M_SHARE STATE PERCENT_CPU PERCENT_MEM TIME Command
.sort_key=PERCENT_MEM
.tree_sort_key=PID
.tree_view=0
.tree_view_always_by_pid=0
.sort_direction=-1
.tree_sort_direction=1
.all_branches_collapsed=0
screen:I/O=PID USER IO_PRIORITY IO_RATE IO_READ_RATE IO_WRITE_RATE PERCENT_SWAP_DELAY PERCENT_IO_DELAY Command
.sort_key=IO_RATE
.tree_sort_key=PID
.tree_view=0
.tree_view_always_by_pid=0
.sort_direction=-1
.tree_sort_direction=1
.all_branches_collapsed=0

121
config/shared/nvim Normal file
View File

@@ -0,0 +1,121 @@
-- [[ Basic Keymaps ]]
-- See `:help vim.keymap.set()`
-- Map 'jk' to escape in insert mode
vim.keymap.set('i', 'jk', '<Esc>', { desc = 'Exit insert mode with jk' })
-- Clear highlights on search when pressing <Esc> in normal mode
-- See `:help hlsearch`
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
-- Diagnostic keymaps
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier
-- for people to discover. Otherwise, you normally need to press <C-\><C-n>, which
-- is not what someone will guess without a bit more experience.
vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' })
-- Keybinds to make split navigation easier.
-- Use CTRL+<hjkl> to switch between windows
--
-- See `:help wincmd` for a list of all window commands
vim.keymap.set('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus to the left window' })
vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' })
vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' })
vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })
-- [[ Basic Autocommands ]]
-- See `:help lua-guide-autocommands`
-- Highlight when yanking (copying) text
-- Try it with `yap` in normal mode
-- See `:help vim.highlight.on_yank()`
vim.api.nvim_create_autocmd('TextYankPost', {
desc = 'Highlight when yanking (copying) text',
group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
callback = function()
vim.highlight.on_yank()
end,
})
-- ---------------------------------------------------
-- ---------------------------------------------------
-- Set <space> as the leader key
-- See `:help mapleader`
-- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used)
vim.g.mapleader = " "
vim.g.maplocalleader = " "
-- [[ Setting options ]]
-- See `:help vim.opt`
-- NOTE: You can change these options as you wish!
-- For more options, you can see `:help option-list`
-- Disable Neovim background
vim.api.nvim_set_hl(0, "Normal", { bg = "none" })
vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" })
-- Scroll lines/columns
vim.opt.mousescroll = "hor:1,ver:1"
-- Set indentation preferences
vim.opt.expandtab = true -- Convert tabs to spaces
vim.opt.shiftwidth = 2 -- Number of spaces for auto-indent
vim.opt.tabstop = 2 -- Number of spaces a tab counts for
vim.opt.softtabstop = 2 -- Number of spaces a tab counts for when editing
vim.opt.autoindent = true -- Copy indent from current line when starting new line
vim.opt.smartindent = true -- Do smart autoindenting when starting a new line
-- Disable line wrapping
vim.opt.wrap = false
-- Make line numbers default
vim.opt.number = true
vim.opt.relativenumber = true
-- Enable mouse mode, can be useful for resizing splits for example!
vim.opt.mouse = "a"
-- Don't show the mode, since it's already in the status line
vim.opt.showmode = true
vim.opt.statusline = "%F%m%r%h%w%=%l,%c %P"
-- Sync clipboard between OS and Neovim.
-- Schedule the setting after `UiEnter` because it can increase startup-time.
-- Remove this option if you want your OS clipboard to remain independent.
-- See `:help 'clipboard'`
vim.schedule(function()
vim.opt.clipboard = "unnamedplus"
end)
-- Enable break indent
vim.opt.breakindent = true
-- Save undo history
vim.opt.undofile = true
-- Case-insensitive searching UNLESS \C or one or more capital letters in the search term
vim.opt.ignorecase = true
vim.opt.smartcase = true
-- Decrease update time
vim.opt.updatetime = 250
-- Decrease mapped sequence wait time
-- Displays which-key popup sooner
vim.opt.timeoutlen = 300
-- Configure how new splits should be opened
vim.opt.splitright = true
vim.opt.splitbelow = true
-- Preview substitutions live, as you type!
vim.opt.inccommand = "split"
-- Show which line your cursor is on
vim.opt.cursorline = true
-- Minimal number of screen lines to keep above and below the cursor.
vim.opt.scrolloff = 10

62
config/shared/tmux Normal file
View File

@@ -0,0 +1,62 @@
# Change the prefix from 'C-b' to 'C-Space'
unbind C-b
set-option -g prefix C-Space
bind-key C-Space send-prefix
#set -g default-terminal "tmux-256color"
#set -as terminal-features ",*:RGB"
set-option -sg escape-time 10
set-option -g focus-events on
# Set the base index for windows and panes to 1 instead of 0
set -g base-index 1
setw -g pane-base-index 1
# Increase scrollback buffer size
set -g history-limit 10000
# Customize the status bar
set -g status-style bg=default,fg=white
set -g status-left '#[fg=cyan,bold][#S] '
set -g status-left-length 50
set -g status-right ''
# Window status format
setw -g window-status-format '#[fg=white,dim]#I#[fg=grey]:#[fg=white]#W#[fg=grey]#F'
setw -g window-status-current-format '#[fg=cyan,bold]#I#[fg=blue]:#[fg=cyan]#W#[fg=grey]#F'
# Pane border
set -g pane-border-style fg=colour240
set -g pane-active-border-style fg=cyan
# Message text
set -g message-style bg=default,fg=cyan
# Enable mouse support
setw -g mouse on
# Fix scroll. Use N3 instead of N1 to make it quicker
bind-key -T copy-mode-vi WheelUpPane send -N1 -X scroll-up
bind-key -T copy-mode-vi WheelDownPane send -N1 -X scroll-down
# Update terminal titles
set-option -g set-titles on
# Use vim keybindings in copy mode
setw -g mode-keys vi
# Setup 'v' to begin selection as in Vim
bind -T copy-mode-vi v send-keys -X begin-selection
# Pane navigation using vim-like keys
bind -r k select-pane -U
bind -r j select-pane -D
bind -r h select-pane -L
bind -r l select-pane -R
# Automatically renumber windows when one is closed
set -g renumber-windows on
# Reload tmux config
bind r source-file ~/.tmux.conf \; display "Reloaded!"

26
config/shared/vim Normal file
View File

@@ -0,0 +1,26 @@
set nocompatible
set nobackup
set encoding=utf-8
set clipboard=unnamed
filetype plugin indent on
let mapleader=" "
inoremap jk <esc>
set number
set relativenumber
set ruler
set cursorline
set scrolloff=10
set nowrap
set showcmd
set wildmenu
set title
set mouse=a
set shiftwidth=2
set tabstop=2
set expandtab
set autoindent
set smartindent
syntax on

70
config/shared/wezterm Normal file
View File

@@ -0,0 +1,70 @@
local wezterm = require('wezterm')
local config = wezterm.config_builder()
config.term="xterm-256color"
config.color_scheme = "Catppuccin Frappe"
config.font = wezterm.font('FiraCode Nerd Font')
-- config.window_decorations = "INTEGRATED_BUTTONS | RESIZE"
config.font_size = 14.0
config.use_resize_increments = true
config.window_padding = {
left = 4,
right = 4,
top = 4,
bottom = 0,
}
config.mouse_bindings = {
{
event = { Drag = { streak = 1, button = 'Left' } },
mods = 'CMD',
action = wezterm.action.StartWindowDrag,
},
{
event = { Drag = { streak = 1, button = 'Left' } },
mods = 'CTRL|SHIFT',
action = wezterm.action.StartWindowDrag,
},
}
local act = wezterm.action
config.keys = {
{
key = 'w',
mods = 'CMD',
action = wezterm.action.CloseCurrentTab { confirm = false }
},
{
key = 'LeftArrow',
mods = 'CMD',
action = wezterm.action { SendString = '\x1b0H' }
},
{
key = 'RightArrow',
mods = 'CMD',
action = wezterm.action { SendString = '\x1b0F' }
},
{
key = 'LeftArrow',
mods = 'OPT',
action = act.SendKey { key = 'b', mods = 'ALT' }
},
{
key = 'RightArrow',
mods = 'OPT',
action = act.SendKey { key = 'f', mods = 'ALT' }
}
---- Make Option-Left equivalent to Alt-b which many line editors interpret as backward-word
--{
-- key="LeftArrow",
-- mods="OPT",
-- action=wezterm.action{SendString="\x1bb"}
--},
---- Make Option-Right equivalent to Alt-f; forward-word
--{
-- key="RightArrow",
-- mods="OPT",
-- action=wezterm.action{SendString="\x1bf"}
--}
}
return config

71
config/shared/zsh Normal file
View File

@@ -0,0 +1,71 @@
# Add /bin to path
export PATH="$PATH:$HOME/bin"
# Set locales
export LANGUAGE="en_US:en"
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
autoload -Uz compinit && compinit # Autocomplete
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' # Case Insensitive
setopt autocd # cd without it
setopt share_history
# Git prompt function
git_prompt_info() {
if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
local branch=$(git symbolic-ref --short HEAD 2>/dev/null || git rev-parse --short HEAD)
echo " %F{green}($branch)%f"
fi
}
# Set up the prompt
setopt PROMPT_SUBST # Dyna
PROMPT='%n@%m%f %F{blue}%~%f$(git_prompt_info) $ '
# Disable the log builtin, so we don't conflict with /usr/bin/log
disable log
# Save command history
HISTFILE=${ZDOTDIR:-$HOME}/.zsh_history
HISTSIZE=2000
SAVEHIST=1000
setopt HIST_IGNORE_ALL_DUPS
# Load functions
autoload -U up-line-or-beginning-search
autoload -U down-line-or-beginning-search
zle -N up-line-or-beginning-search
zle -N down-line-or-beginning-search
# Bind both common escape sequences
bindkey '^[[A' up-line-or-beginning-search # normal mode
bindkey '^[OA' up-line-or-beginning-search # application mode
bindkey '^[[B' down-line-or-beginning-search # normal mode
bindkey '^[OB' down-line-or-beginning-search # application mode
# Aliases for ls
alias ls='ls --color=auto'
alias ll='ls -lF'
alias lla='ll -a'
alias ld='ls -ld */' # List only directories
# Aliases for git
alias g='git'
alias ga='git add'
alias gaa='git add --all'
alias gb='git branch'
alias gcm='git commit -m'
alias gam='git commit -am'
alias gco='git checkout'
alias gd='git diff'
alias gf='git fetch'
alias gl='git pull'
alias gp='git push'
alias gst='git status'
alias glg='git log --graph --oneline --decorate --all'
alias gm='git merge'
alias grb='git rebase'
alias grs='git reset'
alias grv='git remote -v'