From cb42a8429d1528344f48e25c523485503901c392 Mon Sep 17 00:00:00 2001 From: odas0r Date: Wed, 16 Apr 2025 23:48:33 +0100 Subject: [PATCH 1/7] darwin version is just weird --- alacritty/alacritty.toml | 106 ------------- alacritty/setup | 13 -- bash/agent.sh | 29 ---- bash/aliases.sh | 21 +-- bash/bash | 2 +- bash/editor.sh | 2 +- bash/fzf.sh | 2 +- bash/kitty.sh | 5 - bash/nvimr.sh | 16 -- bash/path.sh | 102 ++----------- bashrc | 19 +-- gh/config.yml | 2 +- git/gitconfig | 12 +- git/gitconfig.wsl | 26 ---- git/setup | 29 ++-- install/aws-cli | 11 -- install/bat-cat | 13 -- install/bats | 13 -- install/clang | 29 +--- install/cloudflared | 11 -- install/cmake | 18 +-- install/deno | 5 - install/docker | 23 --- install/fd | 7 - install/firebase-cli | 10 -- install/fzf | 13 -- install/gcc | 6 - install/gh | 14 -- install/golang-language-server | 3 - install/kitty | 4 +- install/lazydocker | 11 -- install/lazygit | 14 -- install/litestream | 13 -- install/lua | 31 ---- install/lua-language-server | 15 -- install/marksman | 13 -- install/opencv | 23 --- install/parallel | 18 --- install/pg-formatter | 5 - install/ruby | 10 -- install/sqlite | 51 ------- install/stripe | 23 --- install/stylua | 11 -- install/tmux | 20 --- install/ueberzugpp | 28 ---- kitty/kitty.conf | 126 ++++++--------- kitty/setup | 5 +- kitty/tab_bar.py | 170 --------------------- lazygit/config.yml | 2 +- lazygit/setup | 2 + nvim/lua/odas0r/options.lua | 14 +- nvim/lua/odas0r/plugins/nvim-lspconfig.lua | 15 -- nvim/spell/en.utf-8.add | 2 +- scripts/bat | 5 - scripts/bluetooth-reboot | 5 - scripts/branches | 32 ---- scripts/clipboard | 2 +- scripts/clone | 5 - scripts/cmd | 8 - scripts/commit | 3 - scripts/commits | 26 ---- scripts/dot | 13 +- scripts/emoji | 9 -- scripts/emulator-start | 17 --- scripts/epub2pdf | 58 ------- scripts/explain | 5 - scripts/figma-fonts | 10 -- scripts/figma-fonts-reload | 7 - scripts/figma-open | 7 - scripts/fix-audio | 5 - scripts/fix-docker | 5 - scripts/fix-key | 25 --- scripts/flutter-hot-reload | 28 ---- scripts/{fmt-js => formatjs} | 0 scripts/gcal | 2 - scripts/gdocs | 3 - scripts/git-md | 58 ------- scripts/habit | 1 - scripts/install-fonts | 41 ----- scripts/installers | 4 +- scripts/lazy | 5 - scripts/lintcommits | 19 --- scripts/logitech-light-ui | 5 - scripts/mark | 4 - scripts/markpath | 3 - scripts/marks | 3 - scripts/md | 61 -------- scripts/minecraft | 10 -- scripts/n | 5 - scripts/newcli | 28 ---- scripts/newi | 4 +- scripts/newx | 4 +- scripts/nextday | 27 ---- scripts/{nvimr-test => nvim-test} | 0 scripts/nvimr | 11 -- scripts/nvimr-reset | 10 -- scripts/popup | 17 --- scripts/prevday | 29 ---- scripts/pull | 3 - scripts/push | 3 - scripts/py | 5 - scripts/schema | 2 +- scripts/scripts | 2 +- scripts/ssh-edit | 2 +- scripts/tempf | 2 +- scripts/tmuxin | 73 --------- scripts/today | 22 --- scripts/tunnel | 41 ----- scripts/tunnel-config | 5 - scripts/tunnel-ls | 5 - scripts/tunnel-random | 20 --- scripts/unmark | 5 - scripts/update | 3 - scripts/x | 1 - scripts/xdg-open | 5 - scripts/zip-cp | 26 ---- scripts/zl | 2 +- scripts/zn | 2 +- setup | 28 +--- tmux/setup | 7 - tmux/tmux.conf | 99 ------------ 121 files changed, 119 insertions(+), 2061 deletions(-) delete mode 100644 alacritty/alacritty.toml delete mode 100755 alacritty/setup delete mode 100644 bash/agent.sh delete mode 100644 bash/kitty.sh delete mode 100644 bash/nvimr.sh delete mode 100644 git/gitconfig.wsl delete mode 100755 install/aws-cli delete mode 100755 install/bat-cat delete mode 100755 install/bats delete mode 100755 install/cloudflared delete mode 100755 install/deno delete mode 100755 install/docker delete mode 100755 install/fd delete mode 100755 install/firebase-cli delete mode 100755 install/fzf delete mode 100755 install/gcc delete mode 100755 install/gh delete mode 100755 install/golang-language-server delete mode 100755 install/lazydocker delete mode 100755 install/lazygit delete mode 100755 install/litestream delete mode 100755 install/lua delete mode 100755 install/lua-language-server delete mode 100755 install/marksman delete mode 100755 install/opencv delete mode 100755 install/parallel delete mode 100755 install/pg-formatter delete mode 100755 install/ruby delete mode 100755 install/sqlite delete mode 100755 install/stripe delete mode 100755 install/stylua delete mode 100755 install/tmux delete mode 100755 install/ueberzugpp delete mode 100644 kitty/tab_bar.py delete mode 100755 scripts/bat delete mode 100755 scripts/bluetooth-reboot delete mode 100755 scripts/branches delete mode 100755 scripts/clone delete mode 100755 scripts/cmd delete mode 100755 scripts/commit delete mode 100755 scripts/commits delete mode 100755 scripts/emoji delete mode 100755 scripts/emulator-start delete mode 100755 scripts/epub2pdf delete mode 100755 scripts/explain delete mode 100755 scripts/figma-fonts delete mode 100755 scripts/figma-fonts-reload delete mode 100755 scripts/figma-open delete mode 100755 scripts/fix-audio delete mode 100755 scripts/fix-docker delete mode 100755 scripts/fix-key delete mode 100755 scripts/flutter-hot-reload rename scripts/{fmt-js => formatjs} (100%) delete mode 100755 scripts/gcal delete mode 100755 scripts/gdocs delete mode 100644 scripts/git-md delete mode 120000 scripts/habit delete mode 100755 scripts/install-fonts delete mode 100755 scripts/lazy delete mode 100755 scripts/lintcommits delete mode 100755 scripts/logitech-light-ui delete mode 100755 scripts/mark delete mode 100755 scripts/markpath delete mode 100755 scripts/marks delete mode 100755 scripts/md delete mode 100755 scripts/minecraft delete mode 100755 scripts/n delete mode 100755 scripts/newcli delete mode 100755 scripts/nextday rename scripts/{nvimr-test => nvim-test} (100%) delete mode 100755 scripts/nvimr delete mode 100755 scripts/nvimr-reset delete mode 100755 scripts/popup delete mode 100755 scripts/prevday delete mode 100755 scripts/pull delete mode 100755 scripts/push delete mode 100755 scripts/py delete mode 100755 scripts/tmuxin delete mode 100755 scripts/today delete mode 100755 scripts/tunnel delete mode 100755 scripts/tunnel-config delete mode 100755 scripts/tunnel-ls delete mode 100755 scripts/tunnel-random delete mode 100755 scripts/unmark delete mode 100755 scripts/update delete mode 120000 scripts/x delete mode 100755 scripts/xdg-open delete mode 100755 scripts/zip-cp delete mode 100755 tmux/setup delete mode 100644 tmux/tmux.conf diff --git a/alacritty/alacritty.toml b/alacritty/alacritty.toml deleted file mode 100644 index bff5e58..0000000 --- a/alacritty/alacritty.toml +++ /dev/null @@ -1,106 +0,0 @@ -# Environment Variables -[env] -TERM = "alacritty" -# WINIT_X11_SCALE_FACTOR="1.0" - -[shell] -args = ["--cd ~"] -program = "wsl.exe" - -# Window Configuration -[window] -opacity = 1 -dynamic_padding = false -decorations = "Full" -padding = { x = 8, y = 8 } - - -# Font Configuration -[font] -size = 12.0 -normal = { family = "JetBrains Mono", style = "Medium" } -bold = { family = "JetBrains Mono", style = "Bold" } -italic = { family = "JetBrains Mono", style = "Medium Italic" } -bold_italic = { family = "JetBrains Mono", style = "Bold Italic" } -offset = { x = 0, y = 1 } -glyph_offset = { x = 0, y = 0 } - -# Scrolling -[scrolling] -history = 10000 -multiplier = 3 - -[terminal] -# osc52 = "CopyPaste" - -# Colors (Gruvbox dark) - -# Primary Colors -[colors.primary] -background = "#282828" -foreground = "#ebdbb2" -bright_foreground = "#fbf1c7" -dim_foreground = "#a89984" - -# Cursor Colors -[colors.cursor] -text = "CellBackground" -cursor = "CellForeground" - -# Vi Mode Cursor Colors -[colors.vi_mode_cursor] -text = "CellBackground" -cursor = "CellForeground" - -# Selection Colors -[colors.selection] -text = "CellBackground" -background = "CellForeground" - -# Bright Colors -[colors.bright] -black = "#928374" -red = "#fb4934" -green = "#b8bb26" -yellow = "#fabd2f" - -blue = "#83a598" -magenta = "#d3869b" -cyan = "#8ec07c" -white = "#ebdbb2" - -# Normal Colors -[colors.normal] -black = "#282828" # Gruvbox dark background -red = "#cc241d" -green = "#98971a" -yellow = "#d79921" -blue = "#458588" -magenta = "#b16286" -cyan = "#689d6a" -white = "#a89984" - -# Dim Colors -[colors.dim] -black = "#32302f" -red = "#9d0006" -green = "#79740e" -yellow = "#b57614" -blue = "#076678" -magenta = "#8f3f71" -cyan = "#427b58" -white = "#928374" - - -# Keybindings -[keyboard] -bindings = [ - { key = "T", mods = "Control", command = { program = "alacritty" } }, - { key = "C", mods = "Control", chars = "\u0003"}, - { key = "C", mods = "Control|Shift", action = "Copy" }, - { key = "V", mods = "Control|Shift", action = "Paste"}, - { key = "PageUp", mods = "Shift", action = "ScrollPageUp", mode = "~Alt" }, - { key = "PageDown", mods = "Shift", action = "ScrollPageDown", mode = "~Alt" }, - { key = "Home", mods = "Shift", action = "ScrollToTop", mode = "~Alt" }, - { key = "End", mods = "Shift", action = "ScrollToBottom", mode = "~Alt" }, -] diff --git a/alacritty/setup b/alacritty/setup deleted file mode 100755 index 25258d7..0000000 --- a/alacritty/setup +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -if [[ -n "$WSL_DISTRO_NAME" ]]; then - mkdir -p "/mnt/c/Users/Guilherme Rosado/AppData/Roaming/alacritty" - rm "/mnt/c/Users/Guilherme Rosado/AppData/Roaming/alacritty/alacritty.toml" - cp "$DOT/alacritty/alacritty.toml" "/mnt/c/Users/Guilherme Rosado/AppData/Roaming/alacritty/alacritty.toml" -fi - -ln -sf "$DOT/alacritty/alacritty.toml" "$HOME/.alacritty.toml" - -printf "Alacritty setup done! 🌟\n" diff --git a/bash/agent.sh b/bash/agent.sh deleted file mode 100644 index 9a9aac5..0000000 --- a/bash/agent.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash - -# Code extracted from https://stuartleeks.com/posts/wsl-ssh-key-forward-to-windows/ -if [[ ! -d $HOME/.1password ]]; then - mkdir -p $HOME/.1password -fi - -# Configure ssh forwarding -export SSH_AUTH_SOCK=$HOME/.1password/agent.sock - -if [[ -n "${WSL_DISTRO_NAME}" ]]; then - # need `ps -ww` to get non-truncated command for matching - # use square brackets to generate a regex match for the process we want but that doesn't match the grep command running it! - ALREADY_RUNNING=$( - ps -auxww | grep -q "[n]piperelay.exe -ei -s //./pipe/openssh-ssh-agent" - echo $? - ) - if [[ $ALREADY_RUNNING != "0" ]]; then - if [[ -S $SSH_AUTH_SOCK ]]; then - # not expecting the socket to exist as the forwarding command isn't running (http://www.tldp.org/LDP/abs/html/fto.html) - echo "removing previous socket..." - rm $SSH_AUTH_SOCK - fi - echo "Starting SSH-Agent relay..." - # setsid to force new session to keep running - # set socat to listen on $SSH_AUTH_SOCK and forward to npiperelay which then forwards to openssh-ssh-agent on windows - (setsid socat UNIX-LISTEN:$SSH_AUTH_SOCK,fork EXEC:"npiperelay.exe -ei -s //./pipe/openssh-ssh-agent",nofork &) >/dev/null 2>&1 - fi -fi diff --git a/bash/aliases.sh b/bash/aliases.sh index 9c896c9..473a533 100644 --- a/bash/aliases.sh +++ b/bash/aliases.sh @@ -1,17 +1,12 @@ -#!/bin/bash +#!/usr/bin/env bash -# Utils alias ..="cd .." -alias ls="ls --format=single-column --classify --color --group-directories-first" -alias la="ls -la" +alias ls="gls --format=single-column --classify --color --group-directories-first" +alias la="gls --format=single-column --classify --color --group-directories-first -la" alias sb="source ~/.bashrc" -alias hosts="sudoedit /etc/hosts" -alias luamake="/home/odas0r/tools/lua-language-server/3rd/luamake/luamake" -alias android-studio="/home/odas0r/tools/android-studio/bin/studio.sh" - -# alias ssh="ssh.exe" -# alias ssh-add="ssh-add.exe" +alias luamake="$HOME/tools/lua-language-server/3rd/luamake/luamake" +alias android-studio="$HOME/tools/android-studio/bin/studio.sh" repos() { local paths=( @@ -23,13 +18,13 @@ repos() { for path in "${paths[@]}"; do if [[ -d "$path" ]]; then if [[ -z "$all_repos" ]]; then - all_repos=$(find "$path" -mindepth 2 -maxdepth 2 -type d) + all_repos=$(gfind "$path" -mindepth 2 -maxdepth 2 -type d) else - all_repos="$all_repos"$'\n'"$(find "$path" -mindepth 2 -maxdepth 2 -type d)" + all_repos="$all_repos"$'\n'"$(gfind "$path" -mindepth 2 -maxdepth 2 -type d)" fi fi done - repo=$(echo "$all_repos" | fzf-tmux -p 40% --multi --prompt="Your repositories > ") + repo=$(echo "$all_repos" | fzf --multi --prompt="Your repositories > ") [ -n "$repo" ] && cd "$repo" || return } diff --git a/bash/bash b/bash/bash index 24f17cc..d87a82d 120000 --- a/bash/bash +++ b/bash/bash @@ -1 +1 @@ -/home/odas0r/github.com/odas0r/dot/bash \ No newline at end of file +/Users/odas0r/github.com/odas0r/dot/bash \ No newline at end of file diff --git a/bash/editor.sh b/bash/editor.sh index d1f7681..b2dcfa4 100644 --- a/bash/editor.sh +++ b/bash/editor.sh @@ -22,5 +22,5 @@ fi export HRULEWIDTH=73 # Define the editor -export VISUAL="nvimr" +export VISUAL="nvim" export EDITOR="$VISUAL" diff --git a/bash/fzf.sh b/bash/fzf.sh index 2298c33..873876d 100644 --- a/bash/fzf.sh +++ b/bash/fzf.sh @@ -2,7 +2,7 @@ # source "/usr/share/doc/fzf/examples/key-bindings.bash" # source "/usr/share/doc/fzf/examples/completion.bash" -[ -f ~/.fzf.bash ] && source ~/.fzf.bash +[[ -f ~/.fzf.bash ]] && source ~/.fzf.bash FD_OPTIONS="--follow --exclude .git --exclude node_modules" FZF_BINDS="--bind 'f2:toggle-preview,ctrl-d:half-page-down,ctrl-u:half-page-up,ctrl-/:toggle-all'" diff --git a/bash/kitty.sh b/bash/kitty.sh deleted file mode 100644 index 5dea458..0000000 --- a/bash/kitty.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -if test -n "$KITTY_INSTALLATION_DIR" -a -e "$KITTY_INSTALLATION_DIR/shell-integration/bash/kitty.bash"; then - source "$KITTY_INSTALLATION_DIR/shell-integration/bash/kitty.bash" -fi diff --git a/bash/nvimr.sh b/bash/nvimr.sh deleted file mode 100644 index 1582c36..0000000 --- a/bash/nvimr.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -if [[ "$TERM" == "xterm-kitty" ]]; then - panel_pid=$(kitty @ ls | jq '.[] | .tabs[] | .windows[] | select(.is_self == true) | .pid') - panel_title=$(kitty @ ls | jq '.[] | .tabs[] | .windows[] | select(.is_self == true) | .title') - - # trim all the newlines, since the output of kitty @ ls is multiline - panel_pid=$(echo "$panel_pid" | tr -d '\n' | tr -d ' ') - panel_title=$(echo "$panel_title" | tr -d '"' | tr -d ' ') - - export NVIM_SOCKET="$HOME/.cache/nvim/nvim_socket.${panel_pid}.${panel_title}.pipe" -elif [[ -n "$TMUX" ]]; then - export NVIM_SOCKET="$HOME/.cache/nvim/nvim_socket.pane_${TMUX_PANE}.pipe" -else - export NVIM_SOCKET="$HOME/.cache/nvim/nvim_socket.pipe" -fi diff --git a/bash/path.sh b/bash/path.sh index 738c0af..31a2220 100644 --- a/bash/path.sh +++ b/bash/path.sh @@ -1,50 +1,17 @@ #!/usr/bin/env bash -# shellcheck disable=SC2155 - -if [[ -n "${WSL_DISTRO_NAME}" ]]; then - # execute this to symlink the chrome program - # ln -sf "/mnt/c/Program Files/Google/Chrome/Application/chrome.exe" ~/.local/bin/chrome - export BROWSER="$HOME/.local/bin/chrome" - export CHROME_EXECUTABLE="$HOME/.local/bin/chrome" -fi - -# export XDG_CONFIG_HOME="$HOME/.config" -export DOT_FILES="$HOME/github.com/odas0r/dot" -export SPDLOG_LEVEL=debug - -# Followed this to install openssl 1.1.1, which is needed on some applications. -# If some problem related to openssl happens this might be the cause, since I -# replaced the v3.X.X with openssl.old -# -# https://askubuntu.com/questions/1126893/how-to-install-openssl-1-1-1-and-libssl-package#1127228 -export LD_LIBRARY_PATH="/opt/openssl/lib:${LD_LIBRARY_PATH}" +export DOT="$HOME/github.com/odas0r/dot" -# Utils -export MARKPATH="$HOME/.marks" -export SNIPPETS="$HOME/snippets" +export SSH_AUTH_SOCK="$HOME/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock" export LOCAL_BIN="$HOME/.local/bin" -export LOCAL_BIN_SCRIPTS="$HOME/.local/bin/scripts" # $HOME/.local/bin is the PATH for global scripts - -export TOOLS="$HOME/tools" - -# Dot Path -export DOT="$HOME/github.com/odas0r/dot" - -# Deno -export DENO_INSTALL="/home/odas0r/.deno" +# the PATH for global scripts +export LOCAL_BIN_SCRIPTS="$HOME/.local/bin/scripts" # pnpm package manager -export PNPM_HOME="/home/odas0r/.local/share/pnpm" - +export PNPM_HOME="$HOME/.local/share/pnpm" export VOLTA_HOME="$HOME/.volta" -# Java -# export JAVA_HOME=$(/usr/libexec/java_home -v 17) -# export JUNIT_HOME="$HOME/java" -# export CLASSPATH="$CLASSPATH:$JUNIT_HOME/junit-4.13.2.jar:$JUNIT_HOME/hamcrest-core-1.3.jar" - # zet path export ZET="$HOME/github.com/odas0r/zet" @@ -52,63 +19,12 @@ export ZET="$HOME/github.com/odas0r/zet" export GOROOT="/usr/local/go" export GOPATH="$HOME/go" -# Ruby -export GEM_HOME="$HOME/.gem" - -# CBUILD -# export CPATH="$HOME/llvm-project/build/lib/clang/19/include:$CPATH" -# export C_INCLUDE_PATH="$HOME/llvm-project/build/lib/clang/19/include:$C_INCLUDE_PATH" -# export CPLUS_INCLUDE_PATH="$HOME/llvm-project/build/lib/clang/19/include:$CPLUS_INCLUDE_PATH" - -# Cargo -export CARGOPATH="/home/odas0r/.cargo" - -# Tools -export LUA_LANGUAGE_SERVER="$TOOLS/lua-language-server/bin" - -# Perl -export PERLPATH="/hom/odas0r/perl5" -export PERL5LIB="/home/odas0r/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}" -export PERL_LOCAL_LIB_ROOT="/home/odas0r/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}" -export PERL_MB_OPT='--install_base "/home/odas0r/perl5"' -export PERL_MM_OPT="INSTALL_BASE=/home/odas0r/perl5" - -# Android Studio -export ANDROID_HOME="$HOME/Android/Sdk" -export ANDROID_STUDIO_HOME="/home/odas0r/tools/android-studio" -export ANDROID_SDK_BUILD_TOOLS="$HOME/Android/Sdk/build-tools/33.0.0" -export ANDROID_SDK_PLATFORM_TOOLS="$HOME/Android/Sdk/platform-tools" -export ANDROID_SDK_EMULATOR="$HOME/Android/Sdk/emulator" - -# JetBrains - -export JETBRAINS_APPS="$HOME/.local/share/JetBrains/Toolbox/apps" -export JETBRAINS_DATAGRIP="$JETBRAINS_APPS/datagrip" - -export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 - -export FLUTTER_BIN="$HOME/flutter/bin" - # Global Path -PATH="$PATH:/bin:/usr/local/bin:" -PATH+="$GOROOT/bin:$GOPATH/bin:" -PATH+="$CARGOPATH/bin:" -PATH+="$PERLPATH/bin:" -PATH+="$DENO_INSTALL/bin:" +PATH="$PATH:/usr/local/bin:/usr/bin:/bin:/sbin:/usr/sbin:" + PATH+="$LOCAL_BIN:$LOCAL_BIN_SCRIPTS:" -PATH+="$LUA_LANGUAGE_SERVER:" -PATH+="$GNU_UTILS:" -PATH+="$LD_LIBRARY_PATH:" -PATH+="$JAVA_HOME/bin:" -PATH+="$FLUTTER_BIN:" -PATH+="$ANDROID_HOME:" -PATH+="$ANDROID_STUDIO_HOME/bin:" -PATH+="$ANDROID_SDK_BUILD_TOOLS:" -PATH+="$ANDROID_SDK_PLATFORM_TOOLS:" -PATH+="$ANDROID_SDK_EMULATOR:" -PATH+="$JETBRAINS_DATAGRIP/bin:" +PATH+="$GOROOT/bin:$GOPATH/bin:" PATH+="$PNPM_HOME:" -PATH+="$VOLTA_HOME/bin:" -PATH+="$GEM_HOME/bin" +PATH+="$VOLTA_HOME/bin" export PATH diff --git a/bashrc b/bashrc index 238a3d6..4dd74ef 100644 --- a/bashrc +++ b/bashrc @@ -1,24 +1,13 @@ #!/usr/bin/env bash +eval "$(/opt/homebrew/bin/brew shellenv)" + # source all files for file in $HOME/.bash/*.sh; do - . $file + . $file done -# source all completion files +# # source all completion files for file in $HOME/.bash/autocomplete/*.sh; do . $file done - -# *BECAREFUL:* -# -# Tmux does not modify the PATH env var. It does cache the PATH from the first -# client to create a session, so all the PATH modifications should be done -# before starting tmux. -# -if [[ -n "$WSL_DISTRO_NAME" ]]; then - if [[ "$TERM" != "xterm-kitty" ]] && [[ -z "$TMUX" ]]; then - echo "Starting tmux session..." - tmux attach -t wsl || tmux new -s wsl - fi -fi diff --git a/gh/config.yml b/gh/config.yml index 03312f2..5e9f412 100644 --- a/gh/config.yml +++ b/gh/config.yml @@ -1,5 +1,5 @@ git_protocol: ssh -editor: nvimr +editor: nvim prompt: enabled pager: less aliases: diff --git a/git/gitconfig b/git/gitconfig index c90daa3..f2f058d 100644 --- a/git/gitconfig +++ b/git/gitconfig @@ -7,20 +7,10 @@ followTags = true default = current [core] - editor = nvimr + editor = nvim autocrlf = false sshCommand = ssh [init] defaultBranch = main -[diff] - tool = nvimr -[difftool "nvimr"] - cmd = nvimr -d $LOCAL $REMOTE -[merge] - tool = nvimr -[mergetool "nvimr"] - cmd = nvimr -d $LOCAL $BASE $REMOTE $MERGED -c 'wincmd J | wincmd =' - prompt = false - keepBackup = false [pull] rebase = false diff --git a/git/gitconfig.wsl b/git/gitconfig.wsl deleted file mode 100644 index d1b2b13..0000000 --- a/git/gitconfig.wsl +++ /dev/null @@ -1,26 +0,0 @@ -[include] - path = ~/.gitconfig.key -[user] - name = odas0r - email = guilherme.odas0r@gmail.com -[push] - followTags = true - default = current -[core] - editor = nvimr - autocrlf = false - sshCommand = ssh.exe -[init] - defaultBranch = main -[diff] - tool = nvimr -[difftool "nvimr"] - cmd = nvimr -d $LOCAL $REMOTE -[merge] - tool = nvimr -[mergetool "nvimr"] - cmd = nvimr -d $LOCAL $BASE $REMOTE $MERGED -c 'wincmd J | wincmd =' - prompt = false - keepBackup = false -[pull] - rebase = false diff --git a/git/setup b/git/setup index fade2bc..8c0b0e7 100755 --- a/git/setup +++ b/git/setup @@ -2,22 +2,17 @@ set -e -SIGNKEY="$DOT/git/gitconfig.key" -if [[ ! -f "$SIGNKEY" ]]; then - echo "Add GPG key. Please generate one and add it to $SIGNKEY" - cat </dev/null - -sudo apt-get update - -sudo groupadd docker -sudo usermod -aG docker $USER -newgrp docker diff --git a/install/fd b/install/fd deleted file mode 100755 index b7ff4a7..0000000 --- a/install/fd +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -sudo apt install fd-find - -ln -s "$(which fdfind)" ~/.local/bin/fd diff --git a/install/firebase-cli b/install/firebase-cli deleted file mode 100755 index ec02546..0000000 --- a/install/firebase-cli +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -if [[ ! -x "$(command -v firebase)" ]]; then - curl -sL https://firebase.tools | bash -else - curl -sL https://firebase.tools | upgrade=true bash -fi - diff --git a/install/fzf b/install/fzf deleted file mode 100755 index d828dd9..0000000 --- a/install/fzf +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -cd /tmp - -if [[ ! -d "$HOME/.fzf" ]]; then - git clone --depth 1 https://github.com/junegunn/fzf.git "$HOME/.fzf" -else - cd "$HOME/.fzf" && git pull -fi - -"$HOME/.fzf/install" diff --git a/install/gcc b/install/gcc deleted file mode 100755 index 290e14c..0000000 --- a/install/gcc +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -sudo apt-get install gcc-12 -sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 100 diff --git a/install/gh b/install/gh deleted file mode 100755 index 22c88c9..0000000 --- a/install/gh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -# if [[ ! -x "$(command -v gh)" ]]; then -# curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg -# echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list >/dev/null -# fi - -# Upgrade -sudo apt install gh - -# Extensions -gh extension install github/gh-copilot diff --git a/install/golang-language-server b/install/golang-language-server deleted file mode 100755 index feeea17..0000000 --- a/install/golang-language-server +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -go install golang.org/x/tools/gopls@latest diff --git a/install/kitty b/install/kitty index f803037..fa0a29f 100755 --- a/install/kitty +++ b/install/kitty @@ -4,5 +4,5 @@ set -euo pipefail curl -L https://sw.kovidgoyal.net/kitty/installer.sh | sh /dev/stdin -ln -sf ~/.local/kitty.app/bin/kitty ~/.local/bin/kitty -ln -sf ~/.local/kitty.app/bin/kitten ~/.local/bin/kitten +# ln -sf ~/.local/kitty.app/bin/kitty ~/.local/bin/kitty +# ln -sf ~/.local/kitty.app/bin/kitten ~/.local/bin/kitten diff --git a/install/lazydocker b/install/lazydocker deleted file mode 100755 index 62a4ab0..0000000 --- a/install/lazydocker +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -# https://github.com/jesseduffield/lazydocker?tab=readme-ov-file#binary-release-linuxosxwindows - -tmpdir=$(mktemp -d) - -cd "$tmpdir" - -curl https://raw.githubusercontent.com/jesseduffield/lazydocker/master/scripts/install_update_linux.sh | bash diff --git a/install/lazygit b/install/lazygit deleted file mode 100755 index 1a36b2e..0000000 --- a/install/lazygit +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -# https://github.com/jesseduffield/lazygit?tab=readme-ov-file#ubuntu - -tmpdir=$(mktemp -d) - -cd "$tmpdir" - -LAZYGIT_VERSION=$(curl -s "https://api.github.com/repos/jesseduffield/lazygit/releases/latest" | grep -Po '"tag_name": "v\K[^"]*') -curl -Lo lazygit.tar.gz "https://github.com/jesseduffield/lazygit/releases/latest/download/lazygit_${LAZYGIT_VERSION}_Linux_x86_64.tar.gz" -tar xf lazygit.tar.gz lazygit -sudo install lazygit /usr/local/bin diff --git a/install/litestream b/install/litestream deleted file mode 100755 index 3b70025..0000000 --- a/install/litestream +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -cd /tmp && mkdir -p litestream - -cd litestream - - -wget https://github.com/benbjohnson/litestream/releases/download/v0.3.13/litestream-v0.3.13-linux-amd64.deb -sudo dpkg -i litestream-v0.3.13-linux-amd64.deb -rm litestream-v0.3.13-linux-amd64.deb - diff --git a/install/lua b/install/lua deleted file mode 100755 index f953840..0000000 --- a/install/lua +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -sudo apt install build-essential libreadline-dev unzip - -cd /tmp/ - -# Check versions here https://www.lua.org/ftp -# -LUA_VERSION=5.1.5 -if [[ -d "lua-$LUA_VERSION" ]]; then - rm -rf "lua-$LUA_VERSION" -fi - -curl -O "https://www.lua.org/ftp/lua-${LUA_VERSION}.tar.gz" -tar zxf "lua-$LUA_VERSION.tar.gz" -cd "lua-$LUA_VERSION" -make linux test -sudo make install - -LUA_ROCKS_VERSION=3.11.0 -if [[ -d "luarocks-$LUA_ROCKS_VERSION" ]]; then - rm -rf "luarocks-$LUA_ROCKS_VERSION" -fi -curl -O "https://luarocks.github.io/luarocks/releases/luarocks-$LUA_ROCKS_VERSION.tar.gz" -tar zxf "luarocks-$LUA_ROCKS_VERSION.tar.gz" -cd "luarocks-$LUA_ROCKS_VERSION" -./configure --with-lua-include=/usr/local/include -make -sudo make install diff --git a/install/lua-language-server b/install/lua-language-server deleted file mode 100755 index 7780798..0000000 --- a/install/lua-language-server +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash - -set -e - -# Docs: https://luals.github.io/wiki/build/ - -if [[ -d "$HOME/tools/lua-language-server" ]]; then - rm -rf "$HOME/tools/lua-language-server" -fi - -mkdir -p $HOME/tools/ -cd $HOME/tools -git clone https://github.com/LuaLS/lua-language-server -cd lua-language-server -./make.sh diff --git a/install/marksman b/install/marksman deleted file mode 100755 index 9c7262e..0000000 --- a/install/marksman +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -cd /tmp/ - -VERSION="2023-12-09" - -curl -L "https://github.com/artempyanykh/marksman/releases/download/${VERSION}/marksman-linux-x64" -o marksman - -chmod +x marksman - -mv marksman $HOME/.local/bin/ diff --git a/install/opencv b/install/opencv deleted file mode 100755 index f50084e..0000000 --- a/install/opencv +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -# https://docs.opencv.org/4.x/d7/d9f/tutorial_linux_install.html - -cd /tmp/ - -# Install minimal prerequisites (Ubuntu 18.04 as reference) -sudo apt update && sudo apt install -y cmake g++ wget unzip - -# Download and unpack sources -wget -O opencv.zip https://github.com/opencv/opencv/archive/4.9.0.zip -unzip opencv.zip - -# Create build directory -mkdir -p build && cd build - -# Configure -cmake ../opencv-4.9.0 - -# Build -cmake --build . diff --git a/install/parallel b/install/parallel deleted file mode 100755 index fc37a31..0000000 --- a/install/parallel +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -# download source -curl -s -L -o /tmp/parallel.tar.bz2 https://ftpmirror.gnu.org/parallel/parallel-latest.tar.bz2 -# extract source -tar -C /tmp -xjf /tmp/parallel.tar.bz2 -# navigate into extracted source -cd /tmp/parallel-* -# build and install -./configure && make && make install -# return to previous directory -cd - -# verify version of parallel installed -parallel --version | head -1 -# get past annoying parallel citation prompt -echo 'will cite' | parallel --citation &>/dev/null || true diff --git a/install/pg-formatter b/install/pg-formatter deleted file mode 100755 index 0eb543b..0000000 --- a/install/pg-formatter +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -set -e - -sudo apt install pgformatter diff --git a/install/ruby b/install/ruby deleted file mode 100755 index fee6f16..0000000 --- a/install/ruby +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -sudo apt install ruby-dev - -mkdir "$HOME/.ruby" - -echo 'export GEM_HOME="$HOME/.ruby"' -echo 'export PATH="$GEM_HOME/bin:$PATH"' diff --git a/install/sqlite b/install/sqlite deleted file mode 100755 index 2d7ed26..0000000 --- a/install/sqlite +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -# Get the latest SQLite version number -CURRENT_YEAR=$(date +'%Y') -SQLITE_VERSION=$(curl -s https://www.sqlite.org/download.html | grep -oP '(?<=sqlite-autoconf-)[0-9]+' | head -1) -if [[ -z "$SQLITE_VERSION" ]]; then - echo "Failed to get SQLite version number" - exit 1 -fi - -echo "===========================================" -echo "Installing SQLite version ${SQLITE_VERSION}" -echo -e "===========================================\n" - -cd /tmp - -rm -rf sqlite-autoconf-* - -curl "https://www.sqlite.org/${CURRENT_YEAR}/sqlite-autoconf-${SQLITE_VERSION}.tar.gz" -o sqlite.tar.gz - -# Extract the source code -tar -xzf sqlite.tar.gz - -# Go into the extracted source code directory -cd "sqlite-autoconf-${SQLITE_VERSION}" - -# Configure the build -# CFLAGS="-DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_COLUMN_METADATA" ./configure -CFLAGS="-DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_COLUMN_METADATA" \ - ./configure --enable-readline=yes - -# Compile the code -make - -# remove the old binary -if [[ -f /usr/local/bin/sqlite3 ]]; then - sudo rm /usr/local/bin/sqlite3 -fi - -# Install SQLite (requires root) -sudo make install - -# Clean up -cd .. -rm -r "sqlite-autoconf-${SQLITE_VERSION}/" -rm sqlite.tar.gz - -# Print SQLite version -sqlite --version diff --git a/install/stripe b/install/stripe deleted file mode 100755 index 3c48f7c..0000000 --- a/install/stripe +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash - -set -e - -# get the latest version of stripe cli (tag_name) -owner="stripe" -repo="stripe-cli" - -version="$(curl --silent "https://api.github.com/repos/${owner}/${repo}/releases/latest" | jq -r '.tag_name')" -package="stripe_${version//v/}_linux_x86_64.tar.gz" - -mkdir -p /tmp/stripe-install -cd /tmp/stripe-install - -# download the latest release -wget "https://github.com/stripe/stripe-cli/releases/download/${version}/${package}" - -# tar the file -tar -xvf "$package" -chmod u+x ./stripe - -# Put the new stripe cli on the /usr/bin to be globally available -sudo mv ./stripe /usr/bin diff --git a/install/stylua b/install/stylua deleted file mode 100755 index a91cc54..0000000 --- a/install/stylua +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -# create installer dir -mkdir -p /tmp/stylua-installer -cd /tmp/stylua-installer - -# download and install binary -VERSION=v0.20.0 -wget "https://github.com/JohnnyMorganz/StyLua/releases/download/$VERSION/stylua-linux.zip" -unzip stylua-linux.zip -sudo install stylua /usr/local/bin diff --git a/install/tmux b/install/tmux deleted file mode 100755 index 5825e03..0000000 --- a/install/tmux +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash - -sudo apt install libevent-dev ncurses-dev build-essential bison pkg-config - -rm -rf /tmp/tmux - -git clone https://github.com/tmux/tmux.git /tmp/tmux - -cd /tmp/tmux || exit 1 - -git checkout 3.3a - -sh autogen.sh - -./configure && make -sudo make install - -cd - || exit 1 - -rm -fr /tmp/tmux diff --git a/install/ueberzugpp b/install/ueberzugpp deleted file mode 100755 index 0c21ad0..0000000 --- a/install/ueberzugpp +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash - -# https://software.opensuse.org/download.html?project=home%3Ajustkidding&package=ueberzugpp - -# Install dependencies -# accept the installation of the packages -sudo apt-get install libssl-dev libvips-dev libsixel-dev libchafa-dev libtbb-dev - -# sudo apt install libx11-dev libxinerama-dev libxft-dev libx11-xcb-dev libxcb-res0-dev -# sudo apt install libxcb*-dev -# sudo apt install libopencv-dev - -cd $HOME - -if [[ -d "ueberzugpp" ]]; then - git -C ueberzugpp pull -else - git clone https://github.com/jstkdng/ueberzugpp.git -fi - - -cd ueberzugpp -git checkout master -mkdir -p build && cd build -cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_WAYLAND=ON .. -cmake --build . -install ueberzug $HOME/.local/bin -install ueberzugpp $HOME/.local/bin diff --git a/kitty/kitty.conf b/kitty/kitty.conf index 70ad835..9caebf0 100644 --- a/kitty/kitty.conf +++ b/kitty/kitty.conf @@ -1,14 +1,16 @@ # vim:ft=config +shell /usr/local/bin/bash + include ./themes/gruvbox.conf # include ./themes/gruvbox_light.conf # include ./themes/tokyonight.conf -term xterm-kitty +term xterm-256color -font_family JetBrains Mono Light +font_family JetBrains Mono Normal bold_font JetBrains Mono SemiBold -italic_font JetBrains Mono Light Italic +italic_font JetBrains Mono Italic bold_italic_font JetBrains Mono SemiBold Italic modify_font underline_position 150% @@ -18,13 +20,10 @@ modify_font cell_height 120% adjust_line_height 120% adjust_column_width 100% -# Best font sizes (pick one) -# font_size 15.5 -# font_size 13 -font_size 11.5 +font_size 14 # OS Specific -macos_thicken_font 0 +macos_thicken_font 0.0 # # Misc @@ -44,51 +43,14 @@ enable_audio_bell no cursor_shape block shell_integration disabled -#: The set of URL prefixes to look for when detecting a URL under the -#: mouse cursor. - +# The set of URL prefixes to look for when detecting a URL under the +# mouse cursor. detect_urls yes -# To minimize latency - -input_delay 0 -repaint_delay 2 -sync_to_monitor no -wayland_enable_ime no - -# This is to make kitty a remote terminal where you can do things with the @ -# operator -allow_remote_control yes -listen_on unix:@mykitty - -######################################### -# Tab -######################################### -# -# REF: https://github.com/kovidgoyal/kitty/discussions/4447 - -tab_bar_style custom - -tab_bar_edge bottom -tab_bar_align left -tab_bar_style custom -tab_bar_min_tabs 1 -tab_activity_symbol none -bell_on_tab no -tab_separator "" -tab_bar_margin_width 0.0 -tab_bar_margin_height 5.0 0.0 -tab_title_template "{f'{title[:30]}…' if title.rindex(title[-1]) + 1 > 30 else (title.center(6) if (title.rindex(title[-1]) + 1) % 2 == 0 else title.center(5))}" -active_tab_font_style bold - ######################################### # Keybindings ######################################### - -map ctrl+c copy_and_clear_or_interrupt -map ctrl+v paste_from_clipboard - map ctrl+- change_font_size all -0.25 map ctrl++ change_font_size all +0.25 @@ -108,49 +70,49 @@ map ctrl+. kitten unicode_input enabled_layouts splits # layout creation -map ctrl+0x61>- launch --location=hsplit --cwd=current -map ctrl+0x61>\ launch --location=vsplit --cwd=current +map cmd+a>- launch --location=hsplit --cwd=current +map cmd+a>\ launch --location=vsplit --cwd=current # layout management like tmux -map ctrl+0x61>h neighboring_window left -map ctrl+0x61>l neighboring_window right -map ctrl+0x61>k neighboring_window up -map ctrl+0x61>j neighboring_window down +map cmd+a>h neighboring_window left +map cmd+a>l neighboring_window right +map cmd+a>k neighboring_window up +map cmd+a>j neighboring_window down -map ctrl+0x61>left resize_window narrower -map ctrl+0x61>right resize_window wider -map ctrl+0x61>up resize_window taller -map ctrl+0x61>down resize_window shorter 3 -map ctrl+0x61>0 resize_window reset +map cmd+a>left resize_window narrower +map cmd+a>right resize_window wider +map cmd+a>up resize_window taller +map cmd+a>down resize_window shorter 3 +map cmd+a>0 resize_window reset # Scrollback search buffer -map ctrl+0x61>f show_scrollback -map ctrl+0x61>g launch --type overlay --title='Lazygit' --cwd=current --copy-env lzg -map ctrl+0x61>d launch --type overlay --title='Lazydocker' --cwd=current --copy-env lzd -# map ctrl+0x61>l launch --type overlay --title='Logs' nvim ~/github.com/odas0r/zet/log.md +map cmd+a>f show_scrollback +map cmd+a>g launch --type overlay --title='Lazygit' --cwd=current --copy-env lzg +map cmd+a>d launch --type overlay --title='Lazydocker' --cwd=current --copy-env lzd +# map cmd+a>l launch --type overlay --title='Logs' nvim ~/github.com/odas0r/zet/log.md # tab navigation -map ctrl+0x61>c launch --cwd=current --type=tab -map ctrl+0x61>n next_tab -map ctrl+0x61>p previous_tab -map ctrl+0x61>r load_config_file -map ctrl+, set_tab_title -map ctrl+0x61>w close_window -map ctrl+0x61>z toggle_layout stack # this does not work? :( -map ctrl+0x61>: kitty_shell window -map ctrl+0x61>Q close_window +map cmd+a>c launch --cwd=current --type=tab +map cmd+a>n next_tab +map cmd+a>p previous_tab +map cmd+a>r load_config_file +map cmd+, set_tab_title +map cmd+a>w close_window +map cmd+a>z toggle_layout stack # this does not work? :( +map cmd+a>: kitty_shell window +map cmd+a>Q close_window # tab management to 1, 2, 3, 4, 5, 6, 7, 8, 9 -map ctrl+0x61>1 goto_tab 1 -map ctrl+0x61>2 goto_tab 2 -map ctrl+0x61>3 goto_tab 3 -map ctrl+0x61>4 goto_tab 4 -map ctrl+0x61>5 goto_tab 5 -map ctrl+0x61>6 goto_tab 6 -map ctrl+0x61>7 goto_tab 7 -map ctrl+0x61>8 goto_tab 8 -map ctrl+0x61>9 goto_tab 9 +map cmd+a>1 goto_tab 1 +map cmd+a>2 goto_tab 2 +map cmd+a>3 goto_tab 3 +map cmd+a>4 goto_tab 4 +map cmd+a>5 goto_tab 5 +map cmd+a>6 goto_tab 6 +map cmd+a>7 goto_tab 7 +map cmd+a>8 goto_tab 8 +map cmd+a>9 goto_tab 9 # move tab to the left -map ctrl+0x61>, move_tab_backward -map ctrl+0x61>. move_tab_forward +map cmd+a>, move_tab_backward +map cmd+a>. move_tab_forward diff --git a/kitty/setup b/kitty/setup index cf09508..a66b331 100755 --- a/kitty/setup +++ b/kitty/setup @@ -7,8 +7,7 @@ KITTY="$HOME/.config/kitty" mkdir -p "$KITTY" # create symlinks for the config & theme files -ln -sf "$DOT/kitty/kitty.conf" "$KITTY/kitty.conf" -ln -sf "$DOT/kitty/themes" "$KITTY/themes" -ln -sf "$DOT/kitty/tab_bar.py" "$KITTY/tab_bar.py" +ln -sf "$HOME/github.com/odas0r/dot/kitty/kitty.conf" "$KITTY/kitty.conf" +ln -sf "$HOME/github.com/odas0r/dot/kitty/themes" "$KITTY/themes" echo "Kitty setup done! ⭐" diff --git a/kitty/tab_bar.py b/kitty/tab_bar.py deleted file mode 100644 index dd62c44..0000000 --- a/kitty/tab_bar.py +++ /dev/null @@ -1,170 +0,0 @@ -from datetime import datetime -from kitty.boss import get_boss -from kitty.fast_data_types import Screen, add_timer, get_options -from kitty.utils import color_as_int -from kitty.tab_bar import ( - DrawData, - ExtraData, - Formatter, - TabBarData, - as_rgb, - draw_attributed_string, - draw_title, -) - -import subprocess - -opts = get_options() -icon_fg = as_rgb(color_as_int(opts.color16)) -icon_bg = as_rgb(color_as_int(opts.color8)) -bat_text_color = as_rgb(color_as_int(opts.color15)) -clock_color = as_rgb(color_as_int(opts.color15)) -date_color = as_rgb(color_as_int(opts.color8)) -pomo_fg = as_rgb(color_as_int(opts.color11)) # Bright color for text -pomo_bg = as_rgb(color_as_int(opts.color1)) # Dark color for background -SEPARATOR_SYMBOL, SOFT_SEPARATOR_SYMBOL = ("", "") -RIGHT_MARGIN = 1 -REFRESH_TIME = 1 -ICON = "  " - - -def _draw_icon(screen: Screen, index: int) -> int: - if index != 1: - return 0 - fg, bg = screen.cursor.fg, screen.cursor.bg - screen.cursor.fg = icon_fg - screen.cursor.bg = icon_bg - screen.draw(ICON) - screen.cursor.fg, screen.cursor.bg = fg, bg - screen.cursor.x = len(ICON) - return screen.cursor.x - - -def _draw_left_status( - draw_data: DrawData, - screen: Screen, - tab: TabBarData, - before: int, - max_title_length: int, - index: int, - is_last: bool, - extra_data: ExtraData, -) -> int: - if screen.cursor.x >= screen.columns - right_status_length: - return screen.cursor.x - tab_bg = screen.cursor.bg - tab_fg = screen.cursor.fg - default_bg = as_rgb(int(draw_data.default_bg)) - if extra_data.next_tab: - next_tab_bg = as_rgb(draw_data.tab_bg(extra_data.next_tab)) - needs_soft_separator = next_tab_bg == tab_bg - else: - next_tab_bg = default_bg - needs_soft_separator = False - if screen.cursor.x <= len(ICON): - screen.cursor.x = len(ICON) - screen.draw(" ") - screen.cursor.bg = tab_bg - draw_title(draw_data, screen, tab, index) - if not needs_soft_separator: - screen.draw(" ") - screen.cursor.fg = tab_bg - screen.cursor.bg = next_tab_bg - screen.draw(SEPARATOR_SYMBOL) - else: - prev_fg = screen.cursor.fg - if tab_bg == tab_fg: - screen.cursor.fg = default_bg - elif tab_bg != default_bg: - c1 = draw_data.inactive_bg.contrast(draw_data.default_bg) - c2 = draw_data.inactive_bg.contrast(draw_data.inactive_fg) - if c1 < c2: - screen.cursor.fg = default_bg - screen.draw(" " + SOFT_SEPARATOR_SYMBOL) - screen.cursor.fg = prev_fg - end = screen.cursor.x - return end - - -def _draw_right_status(screen: Screen, is_last: bool, cells: list) -> int: - if not is_last: - return 0 - draw_attributed_string(Formatter.reset, screen) - screen.cursor.x = screen.columns - right_status_length - screen.cursor.fg = 0 - for color, status in cells: - screen.cursor.fg = color - screen.draw(status) - screen.cursor.bg = 0 - return screen.cursor.x - - -def _redraw_tab_bar(_): - tm = get_boss().active_tab_manager - if tm is not None: - tm.mark_tab_bar_dirty() - - -def get_pomodoro_status() -> str: - try: - output = subprocess.check_output(["pomo", "print"], text=True) - return output.strip() - except subprocess.CalledProcessError as e: - return "Error: " + str(e) - - -timer_id = None -right_status_length = -1 - - -def draw_tab( - draw_data: DrawData, - screen: Screen, - tab: TabBarData, - before: int, - max_title_length: int, - index: int, - is_last: bool, - extra_data: ExtraData, -) -> int: - global timer_id - global right_status_length - if timer_id is None: - timer_id = add_timer(_redraw_tab_bar, REFRESH_TIME, True) - clock = datetime.now().strftime(" %H:%M:%S") - date = datetime.now().strftime(" %d-%m-%Y") - cells = [(clock_color, clock), (date_color, date)] - right_status_length = RIGHT_MARGIN + sum(len(cell[1]) for cell in cells) - - left_end = _draw_icon(screen, index) - left_end = _draw_left_status( - draw_data, - screen, - tab, - before, - max_title_length, - index, - is_last, - extra_data, - ) - - if is_last: - # Calculate center space and position for pomodoro status - pomo_status = get_pomodoro_status() - center_space = screen.columns - left_end - right_status_length - pomo_status_len = len(pomo_status) - if center_space > pomo_status_len: - start_pos = left_end + (center_space - pomo_status_len) // 2 - screen.cursor.bold = True - screen.cursor.x = max(start_pos, left_end) - screen.cursor.fg = bat_text_color - screen.draw(pomo_status) - screen.cursor.bold = False - - _draw_right_status( - screen, - is_last, - cells, - ) - - return screen.cursor.x diff --git a/lazygit/config.yml b/lazygit/config.yml index a4eac40..bac9cf4 100644 --- a/lazygit/config.yml +++ b/lazygit/config.yml @@ -1,4 +1,4 @@ os: - edit: "nvimr {{filename}}" # see 'Configuring File Editing' section + edit: "nvim {{filename}}" # see 'Configuring File Editing' section open: "open {{filename}}" # copyToClipboardCmd: "win32yank.exe" diff --git a/lazygit/setup b/lazygit/setup index fe689bb..3229860 100755 --- a/lazygit/setup +++ b/lazygit/setup @@ -1,5 +1,7 @@ #!/usr/bin/env bash +mkdir -p "$HOME/.config/lazygit" + ln -sf "$DOT/lazygit/config.yml" "$HOME/.config/lazygit/config.yml" printf "Lazygit setup done! 🌟\n" diff --git a/nvim/lua/odas0r/options.lua b/nvim/lua/odas0r/options.lua index 6ba019e..bda81ae 100644 --- a/nvim/lua/odas0r/options.lua +++ b/nvim/lua/odas0r/options.lua @@ -2,17 +2,11 @@ -- Options ----------------------------------------- -local isWSL = os.getenv("WSL_DISTRO_NAME") == "Ubuntu" -if isWSL then - vim.ui.open = function(arg) - vim.fn.system("open " .. arg) - end -end - -- copy-paste from -- local opt = vim.opt +opt.shell = "/usr/local/bin/bash" opt.textwidth = 120 -- Maximum width of text -- opt.colorcolumn = "80" -- Line length marker opt.formatoptions = "jcroqlnt" -- tcqj @@ -83,9 +77,3 @@ opt.swapfile = false -- dictionary opt.spelllang = { "en", "pt_pt" } opt.encoding = "utf-8" - --- if vim.fn.has("nvim-0.9.0") == 1 then --- opt.splitkeep = "screen" --- opt.shortmess:append({ C = true }) --- end --- diff --git a/nvim/lua/odas0r/plugins/nvim-lspconfig.lua b/nvim/lua/odas0r/plugins/nvim-lspconfig.lua index ed9fbc3..8e0b87d 100644 --- a/nvim/lua/odas0r/plugins/nvim-lspconfig.lua +++ b/nvim/lua/odas0r/plugins/nvim-lspconfig.lua @@ -255,12 +255,6 @@ return { -- }, -- }) - require("lspconfig").marksman.setup({ - on_attach = on_attach, - capabilities = capabilities, - flags = flags, - }) - -- sudo apt-get install clangd-14 -- sudo update-alternatives --install /usr/bin/clangd clangd /usr/bin/clangd-14 100 require("lspconfig").clangd.setup({ @@ -338,15 +332,6 @@ return { -- }) -- - -- ========== Make sure you have: ============= - -- - -- sudo apt install lua5.1 - -- sudo apt install luajit - -- sudo apt install luarocks - -- luarocks install busted - - -- LSP for lua - -- https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#sumneko_lua local sumneko_binary_path = vim.fn.exepath("lua-language-server") local sumneko_root_path = vim.fn.fnamemodify(sumneko_binary_path, ":h:h:h") diff --git a/nvim/spell/en.utf-8.add b/nvim/spell/en.utf-8.add index 2964c39..a7f4fda 100644 --- a/nvim/spell/en.utf-8.add +++ b/nvim/spell/en.utf-8.add @@ -306,7 +306,7 @@ Canelhas Redbul Pracetamol LGTM -nvimr +nvim nvr searchbar afetar diff --git a/scripts/bat b/scripts/bat deleted file mode 100755 index eab8a82..0000000 --- a/scripts/bat +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -batcat "$@" diff --git a/scripts/bluetooth-reboot b/scripts/bluetooth-reboot deleted file mode 100755 index 1295576..0000000 --- a/scripts/bluetooth-reboot +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -sudo service bluetooth restart diff --git a/scripts/branches b/scripts/branches deleted file mode 100755 index 7de7099..0000000 --- a/scripts/branches +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env bash - -set -e - -is_in_git_repo() { - git rev-parse HEAD -- >/dev/null 2>&1 -} - -is_in_git_repo || (echo "You're not in a git repo" && exit 1) - -# select the wanted branch -branch=$( - git branch -a --color=always | grep -v '/HEAD\s' | sort | - fzf-tmux -p 95% --ansi --multi --tac \ - --header 'Ctrl+d: Delete a local branch' \ - --bind 'ctrl-d:execute(tmux confirm -p "Do you want to remove branch {1}? [y/Y]" "neww git branch -D {1}")+reload(git branch -a --color=always | grep -v "/HEAD\s" | sort)' \ - --preview 'git log --oneline --graph --date=short --color=always --pretty="format:%C(auto)%cd %h%d %s" $(sed s/^..// <<< {} | cut -d" " -f1)' | - sed 's/^..//' | cut -d' ' -f1 | - sed 's#^remotes/##' -) - -# exit if a branch wasn't selected -[[ -z $branch ]] && exit 1 - -# exit if you're already on the selected branch -[[ $branch == "$(git rev-parse --abbrev-ref HEAD)" ]] && exit 1 - -# checkout to selected branch -# 1. Update all the branches/tags from all remotes -# 2. Checkout to the selected branch -# 3. Pull all current changes from that branch -git checkout "$branch" diff --git a/scripts/clipboard b/scripts/clipboard index 21885d9..9ffb55c 100755 --- a/scripts/clipboard +++ b/scripts/clipboard @@ -2,4 +2,4 @@ set -euo pipefail -xclip -selection clipboard +pbcopy diff --git a/scripts/clone b/scripts/clone deleted file mode 100755 index ae38e21..0000000 --- a/scripts/clone +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -set -e - -git clone "$@" diff --git a/scripts/cmd b/scripts/cmd deleted file mode 100755 index de25e9d..0000000 --- a/scripts/cmd +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -set -e - -cmd="$(command -v "$1")" -if [ -n "$cmd" ]; then - popup nvimr "$cmd" -fi diff --git a/scripts/commit b/scripts/commit deleted file mode 100755 index a384561..0000000 --- a/scripts/commit +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -git commit "$@" diff --git a/scripts/commits b/scripts/commits deleted file mode 100755 index e9a72cc..0000000 --- a/scripts/commits +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash - -set -e - -is_in_git_repo() { - git rev-parse HEAD >/dev/null 2>&1 -} - -is_in_git_repo || (echo "You're not in a git repo" && exit 1) - -commit=$( - git log --date=short --format="%C(green)%C(bold)%cd %C(auto)%h%d %s (%an)" --graph --color=always \ - | fzf --ansi --no-sort --multi --bind 'ctrl-s:toggle-sort' \ - --header 'Press CTRL-S to toggle sort' \ - --preview 'grep -o "[a-f0-9]\{7,\}" <<< {} | xargs git show --color=always' \ - | grep -o "[a-f0-9]\{7,\}" -) - -# exit if a branch wasn't selected -[[ -z $commit ]] && exit 1 - -# exit if you're already on the selected commit -[[ $commit == "$(git rev-parse --short HEAD)" ]] && exit 1 - -# checkout to the commit-sha -git checkout "$commit" diff --git a/scripts/dot b/scripts/dot index d026e5c..1f59907 100755 --- a/scripts/dot +++ b/scripts/dot @@ -2,21 +2,16 @@ set -e -if [[ ! -x "$(command -v fzf-tmux)" ]]; then - echo "You need to install fzf-tmux" - exit 1 -fi - if [[ -n $1 ]]; then # find the files by regex & open them w/ nvim - find "$DOT" -type f -name "*$1*" -exec nvimr '{}' + + find "$DOT" -type f -name "*$1*" -exec nvim '{}' + exit 0 fi file=$( - fd . "$DOT" | fzf-tmux -p 95% --multi \ + fd . "$DOT" | fzf --multi \ --prompt="Search through your dotfiles > " \ - --preview 'batcat --theme=gruvbox-dark --style=numbers --color=always {}' + --preview 'bat --theme=gruvbox-dark --style=numbers --color=always {}' ) if [[ -f $file ]]; then @@ -24,6 +19,6 @@ if [[ -f $file ]]; then open "${file}" exit 0 else - nvimr "${file}" + nvim "${file}" fi fi diff --git a/scripts/emoji b/scripts/emoji deleted file mode 100755 index 4273d65..0000000 --- a/scripts/emoji +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -set -e - -emojis=$(curl -sSL 'https://git.io/JXXO7') - -selected_emoji=$(echo "$emojis" | fzf-tmux -p 95%) - -echo "${selected_emoji:0:1}" diff --git a/scripts/emulator-start b/scripts/emulator-start deleted file mode 100755 index 2e7153c..0000000 --- a/scripts/emulator-start +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -GUM="go run github.com/charmbracelet/gum@v0.14.1" - -emulator=$(emulator -list-avds | $GUM choose --header="Choose an emulator to start") - -if [[ -z "${emulator}" ]]; then - exit 0 -fi - -# restart the server -adb kill-server -adb start-server - -emulator -avd "${emulator}" -gpu host -no-boot-anim -no-audio diff --git a/scripts/epub2pdf b/scripts/epub2pdf deleted file mode 100755 index 0569ecd..0000000 --- a/scripts/epub2pdf +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -# Input EPUB file (you can modify this to loop through multiple files) -BOOK="$1" - -# Check if an input file is provided -if [[ -z "$BOOK" ]]; then - echo "Usage: $0 " - exit 1 -fi - -# Check if the EPUB file exists -if [[ ! -f "$BOOK" ]]; then - echo "Error: File '$BOOK' not found." - exit 1 -fi - -# Output PDF file (same name as EPUB, .pdf extension) -PDF_FILE="${BOOK%.*}.pdf" - -# Temporary directory for extracted images -TMP_DIR=$(mktemp -d) - -# Conversion command (using xelatex - often more robust than lualatex) -CONVERT_CMD="pandoc -s -t latex --toc --top-level-division=chapter --pdf-engine=xelatex --extract-media=$TMP_DIR --data-dir=$TMP_DIR \"$BOOK\" -o \"$PDF_FILE\"" - -# 1. Extract Images and Try Initial Conversion -echo "Attempting initial conversion..." -if ! eval "$CONVERT_CMD"; then - echo "Initial conversion failed. Attempting image conversion workaround..." - - if [ -d "$TMP_DIR/images" ]; then - cd "$TMP_DIR/images" || exit 1 - - for i in *.jpg; do - convert "$i" "${i%.jpg}.jpeg" - rm "$i" - mv "${i%.jpg}.jpeg" "$i" - done - - cd .. - - echo "Retrying conversion with converted images..." - if ! eval "$CONVERT_CMD"; then - echo "Error: Conversion failed after image conversion. Check LaTeX output." - rm -rf "$TMP_DIR" - exit 1 - fi - else - echo "Error: No images directory found in the extracted media. Skipping image conversion." - fi -fi - -echo "Conversion successful: $PDF_FILE" - -rm -rf "$TMP_DIR" # Clean up the temporary directory diff --git a/scripts/explain b/scripts/explain deleted file mode 100755 index 1b7dcee..0000000 --- a/scripts/explain +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -gh copilot explain "$@" diff --git a/scripts/figma-fonts b/scripts/figma-fonts deleted file mode 100755 index b4ac57c..0000000 --- a/scripts/figma-fonts +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -if [[ ! -d "$TOOLS/figma-linux-font-helper" ]]; then - echo "Install figma-linux-font-helper first..." - exit 1 -fi - -python3 "$TOOLS/figma-linux-font-helper/server.py" diff --git a/scripts/figma-fonts-reload b/scripts/figma-fonts-reload deleted file mode 100755 index 80a5db3..0000000 --- a/scripts/figma-fonts-reload +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -sudo systemctl restart figma-linux-font-helper.service - -systemctl status figma-linux-font-helper.service diff --git a/scripts/figma-open b/scripts/figma-open deleted file mode 100755 index a711927..0000000 --- a/scripts/figma-open +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -USER_AGENT="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.3" - -google-chrome --user-agent="${USER_AGENT}" https://www.figma.com/files/recent diff --git a/scripts/fix-audio b/scripts/fix-audio deleted file mode 100755 index c98860c..0000000 --- a/scripts/fix-audio +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -systemctl --user restart pipewire diff --git a/scripts/fix-docker b/scripts/fix-docker deleted file mode 100755 index e737e6f..0000000 --- a/scripts/fix-docker +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -set -e - -sudo systemctl restart docker.socket docker.service diff --git a/scripts/fix-key b/scripts/fix-key deleted file mode 100755 index b15aa79..0000000 --- a/scripts/fix-key +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env bash - -set -e - -repo="$1" -key="$2" - -if [[ -z "$repo" ]] || [[ -z "$key" ]]; then - echo "invalid args :(" - exit 1 -fi - -sudo apt-key export "$key" | sudo gpg --dearmour -o "/usr/share/keyrings/$repo.gpg" - -# edit file -# sudo echo -e "\n # Edit:[arch=amd64 signed-by=/usr/share/keyrings/$repo.gpg]" | sudo tee -a "/etc/apt/sources.list.d/$repo.list" -sudo nvim "/etc/apt/sources.list.d/$repo.list" - -# sudo apt update - - -# sudo gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/"$repo".gpg --keyserver keyserver.ubuntu.com --recv "$key" -# sudo chmod 644 /etc/apt/trusted.gpg.d/"$repo".gpg - -# sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys "$1" diff --git a/scripts/flutter-hot-reload b/scripts/flutter-hot-reload deleted file mode 100755 index 3b296e6..0000000 --- a/scripts/flutter-hot-reload +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -# get pid of the running flutter process -pids=$(ps aux | grep '[f]lutter.*run' | awk '{print $2}') - -# get the kitty window id of the running flutter process -kitty_ls_output=$(kitty @ --to=$KITTY_LISTEN_ON ls) - -# # we're navigating to .[].tabs[].windows[] to reflect the structure in your output -# kitty_id=$(echo "$kitty_ls_output" | jq -r ".[].tabs[].windows[] | select(.foreground_processes[].pid == $pid) | .id") -# -# # send 'r\n' to the flutter process -# kitty @ --to=$KITTY_LISTEN_ON send-text --match=id:$kitty_id 'r\n' - -# loop over each pid -while read -r pid; do - # navigate to .[].tabs[].windows[] to extract matching kitty_ids - kitty_ids=$(echo "$kitty_ls_output" | jq -r ".[].tabs[].windows[] | select(.foreground_processes[]?.pid == $pid) | .id") - - # loop over each kitty_id and send the 'r\n' text - while read -r kitty_id; do - if [[ -n "$kitty_id" ]]; then - kitty @ --to=$KITTY_LISTEN_ON send-text --match=id:$kitty_id 'r\n' - fi - done <<< "$kitty_ids" -done <<< "$pids" diff --git a/scripts/fmt-js b/scripts/formatjs similarity index 100% rename from scripts/fmt-js rename to scripts/formatjs diff --git a/scripts/gcal b/scripts/gcal deleted file mode 100755 index 29fe926..0000000 --- a/scripts/gcal +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -open 'https://calendar.google.com/calendar/u/1/r/' diff --git a/scripts/gdocs b/scripts/gdocs deleted file mode 100755 index f71fd5b..0000000 --- a/scripts/gdocs +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -exec open https://docs.google.com/document/u/0/ diff --git a/scripts/git-md b/scripts/git-md deleted file mode 100644 index 1285450..0000000 --- a/scripts/git-md +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -PREVIEW_DIR="/tmp/.md" -WATCH_FILE="$1" - -# Kill any existing preview server and inotifywait process -pkill -f "preview $PREVIEW_DIR" -pkill -f "inotifywait" - -cleanup() { - echo "Shutting down..." - # Kill browser-sync by finding its process ID (PID) - pkill -f "preview $PREVIEW_DIR" - # Optionally, repreviewor perform any other cleanup - rm -rf "$PREVIEW_DIR" - mkdir -p "$PREVIEW_DIR" -} - -# Trap signals INT and TERM, and call cleanup function -trap cleanup INT TERM - -generate_preview() { - HTMLFILE="/tmp/.md/index.html" - MARKDOWN_TMP="$(mktemp -u -p "$PREVIEW_DIR").md" - - TEMPLATE="$HOME/github.com/odas0r/dot/pandoc/github.html" - STYLES=$(cat "$HOME/github.com/odas0r/dot/pandoc/github-theme.css") - - cp "$WATCH_FILE" "$MARKDOWN_TMP" - - # transform with mermaid if ```mermaid is found - # if grep -q '```mermaid' "$WATCH_FILE"; then - # mmdc \ - # --backgroundColor "#0d1117" \ - # --theme dark \ - # -i "$MARKDOWN_TMP" -o "$MARKDOWN_TMP" - # fi - - pandoc \ - --from gfm \ - --to html \ - --highlight-style pygments \ - --css="$STYLES" \ - --template="$TEMPLATE" \ - --metadata title="Preview" \ - -o "$HTMLFILE" "$MARKDOWN_TMP" -} - -generate_preview # Initial preview generation -preview "$PREVIEW_DIR" & # start a preview server in the background - -# Start watching the file -inotifywait -m -e close_write "$WATCH_FILE" | while read -r directory events filename; do - echo "Detected change in '$WATCH_FILE', regenerating preview..." - generate_preview -done diff --git a/scripts/habit b/scripts/habit deleted file mode 120000 index b921ff8..0000000 --- a/scripts/habit +++ /dev/null @@ -1 +0,0 @@ -/Users/odas0r/github.com/habit-cmd/habit \ No newline at end of file diff --git a/scripts/install-fonts b/scripts/install-fonts deleted file mode 100755 index 04f40a7..0000000 --- a/scripts/install-fonts +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -FONT_DIR="$HOME/.local/share/fonts/" -echo "Looking for .otf and .ttf fonts..." - -# Find all .otf and .ttf files and store the list in an array -mapfile -t fonts < <(find . -type f \( -iname "*.ttf" -o -iname "*.otf" \)) - -# Check if any fonts were found -if [ ${#fonts[@]} -eq 0 ]; then - echo "No fonts found. Exiting." - exit 1 -fi - -# Show the list of fonts found -echo "The following fonts will be installed:" -printf "%s\n" "${fonts[@]}" - -# Ask for confirmation -read -rp "Proceed with installation? (y/N) " response -if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]; then - # Copy the fonts to the system directory - for font in "${fonts[@]}"; do - echo "Installing font: $font" - sudo cp "$font" "$FONT_DIR" - done - - # Update the font cache - echo "Updating font cache..." - sudo fc-cache -fv -else - echo "Font installation cancelled." - exit 1 -fi - -# if there's a service called figma-linux-font-helper.service, restart it -if systemctl is-active --quiet figma-linux-font-helper.service; then - sudo systemctl restart figma-linux-font-helper.service -fi diff --git a/scripts/installers b/scripts/installers index fbee22c..168d376 100755 --- a/scripts/installers +++ b/scripts/installers @@ -3,8 +3,8 @@ declare INSTALLS_PATH="$HOME/github.com/odas0r/dot/install" # Generate a list of installer scripts -installer_scripts=$(find "$INSTALLS_PATH" -mindepth 1 -maxdepth 1 -type f -printf "%p\n" | - fzf-tmux -p 40% --multi --prompt="Your installers > ") +installer_scripts=$(fd --type f --maxdepth 1 . "$INSTALLS_PATH" | + fzf --multi --prompt="Your installers > ") # Run the selected installer scripts for script in $installer_scripts; do diff --git a/scripts/lazy b/scripts/lazy deleted file mode 100755 index 4e5f267..0000000 --- a/scripts/lazy +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -lzg "$@" diff --git a/scripts/lintcommits b/scripts/lintcommits deleted file mode 100755 index 814f78e..0000000 --- a/scripts/lintcommits +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -set -e - -if [[ ! -x "$(command -v pip3)" ]]; then - echo "You need to install pip3" - echo "check $HOME/dot/install directory" - exit 1 -fi - -# get the default config under /dot -if [[ ! -f ".gitlint" ]]; then - cp "$HOME/dot/git/gitlint" .gitlint -fi - -# Install git hook -if [[ ! -f ".git/hooks/commit-msg" ]]; then - gitlint install-hook -fi diff --git a/scripts/logitech-light-ui b/scripts/logitech-light-ui deleted file mode 100755 index 2f61de5..0000000 --- a/scripts/logitech-light-ui +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -lcui diff --git a/scripts/mark b/scripts/mark deleted file mode 100755 index f33023d..0000000 --- a/scripts/mark +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -mkdir -p $MARKPATH -ln -s "$(pwd)" "$MARKPATH/$1" diff --git a/scripts/markpath b/scripts/markpath deleted file mode 100755 index 02de8f3..0000000 --- a/scripts/markpath +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -exec echo "$(readlink "${MARKPATH}/${1}")" diff --git a/scripts/marks b/scripts/marks deleted file mode 100755 index a0330cb..0000000 --- a/scripts/marks +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -ls -l "$MARKPATH" | sed 's/ / /g' | cut -d' ' -f9- | sed 's/ -/\-/g' && echo diff --git a/scripts/md b/scripts/md deleted file mode 100755 index ae1c38b..0000000 --- a/scripts/md +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -PREVIEW_DIR="/tmp/.md" -WATCH_FILE="$1" - -# remove old preview files -rm -rf "$PREVIEW_DIR" -mkdir -p "$PREVIEW_DIR" - -cleanup() { - echo "Shutting down..." - # Kill browser-sync by finding its process ID (PID) - pkill -f "preview $PREVIEW_DIR" - # Optionally, repreviewor perform any other cleanup - rm -rf "$PREVIEW_DIR" - exit 0 -} - -# Trap signals INT and TERM, and call cleanup function -trap cleanup INT TERM - -generate_preview() { - HTMLFILE="/tmp/.md/index.html" - MARKDOWN_TMP="$(mktemp -u -p "$PREVIEW_DIR").md" - - TEMPLATE="$HOME/github.com/odas0r/dot/pandoc/github.html" - STYLES=$(cat "$HOME/github.com/odas0r/dot/pandoc/github-theme.css") - - cp "$WATCH_FILE" "$MARKDOWN_TMP" - - # transform with mermaid if ```mermaid is found - # if grep -q '```mermaid' "$WATCH_FILE"; then - # mmdc \ - # --backgroundColor "#0d1117" \ - # --theme dark \ - # -i "$MARKDOWN_TMP" -o "$MARKDOWN_TMP" - # fi - - pandoc \ - --from gfm \ - --to html \ - --css="$STYLES" \ - --template="$TEMPLATE" \ - --metadata title="Preview" \ - -o "$HTMLFILE" "$MARKDOWN_TMP" -} - -# remove old preview files -rm -rf "$PREVIEW_DIR" -mkdir -p "$PREVIEW_DIR" - -generate_preview # Initial preview generation -preview "$PREVIEW_DIR" & # start a preview server in the background - -# Start watching the file -inotifywait -m -e close_write "$WATCH_FILE" | while read -r directory events filename; do - echo "Detected change in '$WATCH_FILE', regenerating preview..." - generate_preview -done diff --git a/scripts/minecraft b/scripts/minecraft deleted file mode 100755 index 7cb0f74..0000000 --- a/scripts/minecraft +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -LAUNCHER="$HOME/Minecraft/launcher.jar" - -[[ ! -f $LAUNCHER ]] && echo "Launcher not found..." && exit 1 - -java -jar "$LAUNCHER" - diff --git a/scripts/n b/scripts/n deleted file mode 100755 index b756545..0000000 --- a/scripts/n +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -set -e - -nvimr "$@" diff --git a/scripts/newcli b/scripts/newcli deleted file mode 100755 index 19b4eb7..0000000 --- a/scripts/newcli +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -REPOS_PATH="$HOME/github.com/odas0r" - -mkdir -p "$REPOS_PATH" - -cliName="$*" - -if [[ -z "$cliName" ]]; then - echo "Usage: newcli " - exit 1 -fi - -# read if the user wants to create a new repo -read -p "Creating new repo on odas0r/${cliName} [y/N]\n" -n 1 -r answer - -cd "$REPOS_PATH" - -if [[ $answer = "y" ]]; then - gh repo create "$cliName" \ - --public \ - --template odas0r/cmd \ - --clone -fi - -echo "Initialized on $REPOS_PATH/$cliName" diff --git a/scripts/newi b/scripts/newi index 4974312..fefdfcc 100755 --- a/scripts/newi +++ b/scripts/newi @@ -11,7 +11,7 @@ installerPath="$HOME/github.com/odas0r/dot/install/${installer}" if [[ -e $installerPath ]]; then read -r -p "${1} already exists. Edit?" yes case "$yes" in - y | yes | ok | okay) nvimr "$installerPath" ;; + y | yes | ok | okay) nvim "$installerPath" ;; esac exit 0 fi @@ -24,4 +24,4 @@ set -euo pipefail EOF chmod +x "$installerPath" -nvimr "$installerPath" +nvim "$installerPath" diff --git a/scripts/newx b/scripts/newx index d826045..87932cd 100755 --- a/scripts/newx +++ b/scripts/newx @@ -7,7 +7,7 @@ path="$HOME/.local/bin/scripts/${1}" if [[ -e $path ]]; then read -r -p "${1} already exists. Edit?" yes case "$yes" in - y | yes | ok | okay) nvimr "$path" ;; + y | yes | ok | okay) nvim "$path" ;; esac exit 0 fi @@ -20,4 +20,4 @@ set -euo pipefail EOF chmod +x "$path" -nvimr "$path" +nvim "$path" diff --git a/scripts/nextday b/scripts/nextday deleted file mode 100755 index e415cdd..0000000 --- a/scripts/nextday +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash - -set -e - -declare -r ZET="$HOME/github.com/zet" -declare -r JOURNAL="$ZET/journal" -declare -r DAILY_TEMPLATE="$ZET/.templates/daily.tmpl.md" - -declare nextdayDate - -if [[ $OSTYPE == "darwin"* ]]; then - nextdayDate=$(gdate --date="next day" "+%Y-%m-%d") -else - nextdayDate=$(date --date="next day" "+%Y-%m-%d") -fi - -file="$JOURNAL/${nextdayDate}.md" - -if [[ ! -f "$file" ]]; then - # Append the daily template on the file - export title="# Journal Entry, ${nextdayDate}" - tmpl "$DAILY_TEMPLATE" >"$file" - - popup nvimr "$file" -else - popup nvimr "$file" -fi diff --git a/scripts/nvimr-test b/scripts/nvim-test similarity index 100% rename from scripts/nvimr-test rename to scripts/nvim-test diff --git a/scripts/nvimr b/scripts/nvimr deleted file mode 100755 index c537d05..0000000 --- a/scripts/nvimr +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -set -e - -if [[ ! -S "$NVIM_SOCKET" ]]; then - nvim --listen "$NVIM_SOCKET" "$@" -else - # if we're on lazygit, we need to send the file to the correct buffer - filePath="$(realpath "$1")" - nvim --server "$NVIM_SOCKET" --remote-send ":wincmd p | e ${filePath}" -fi diff --git a/scripts/nvimr-reset b/scripts/nvimr-reset deleted file mode 100755 index 042004c..0000000 --- a/scripts/nvimr-reset +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -set -e - -if [[ -S "$NVIM_SOCKET" ]]; then - rm "$NVIM_SOCKET" - echo "Reseted session: $NVIM_SOCKET" -else - echo "There's no current session..." -fi diff --git a/scripts/popup b/scripts/popup deleted file mode 100755 index a09ab58..0000000 --- a/scripts/popup +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash - -set -e - -if [[ ! -x "$(command -v tmux)" ]]; then - echo "You need to install tmux" - exit 1 -fi - -# check if tmux is already running -if [[ -n "$TMUX" ]]; then - tmux popup -h90% -w95% -E "$@" -else - echo "Popup requires tmux to be running..." - "$@" -fi - diff --git a/scripts/prevday b/scripts/prevday deleted file mode 100755 index 73fce42..0000000 --- a/scripts/prevday +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env bash - -set -e - -declare -r ZET="${HOME}/github.com/odas0r/zet" -declare -r JOURNAL="$ZET/journal" -declare -r DAILY_TEMPLATE="$ZET/.templates/daily.tmpl.md" - -declare yesterdaysDate - -if [[ $OSTYPE == "darwin"* ]]; then - yesterdaysDate=$(gdate --date="yesterday" "+%Y-%m-%d") -else - yesterdaysDate=$(date --date="yesterday" "+%Y-%m-%d") -fi - -file="$JOURNAL/${yesterdaysDate}.md" - -if [[ ! -f $file ]]; then - - # create a new journal using the `tmpl` script - export title="Journal Entry, ${yesterdaysDate}" - tmpl "$DAILY_TEMPLATE" >"$file" - - # Open the daily file - nvimr "$file" -else - nvimr "$file" -fi diff --git a/scripts/pull b/scripts/pull deleted file mode 100755 index 28cbd14..0000000 --- a/scripts/pull +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -git pull "$@" diff --git a/scripts/push b/scripts/push deleted file mode 100755 index 9ecbaf5..0000000 --- a/scripts/push +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -git push "$@" diff --git a/scripts/py b/scripts/py deleted file mode 100755 index 4c21f43..0000000 --- a/scripts/py +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -python3 "$@" diff --git a/scripts/schema b/scripts/schema index 7b5d919..2a755d2 100755 --- a/scripts/schema +++ b/scripts/schema @@ -2,4 +2,4 @@ set -euo pipefail -sqlite-utils schema "$@" +sqlite3 "$@" .schema diff --git a/scripts/scripts b/scripts/scripts index dd8dd52..989c59f 120000 --- a/scripts/scripts +++ b/scripts/scripts @@ -1 +1 @@ -/home/odas0r/github.com/odas0r/dot/scripts \ No newline at end of file +/Users/odas0r/github.com/odas0r/dot/scripts \ No newline at end of file diff --git a/scripts/ssh-edit b/scripts/ssh-edit index e691ccc..bb76315 100755 --- a/scripts/ssh-edit +++ b/scripts/ssh-edit @@ -2,4 +2,4 @@ set -euo pipefail -nvimr $HOME/.ssh/config +nvim $HOME/.ssh/config diff --git a/scripts/tempf b/scripts/tempf index 37f60bf..25522de 100755 --- a/scripts/tempf +++ b/scripts/tempf @@ -12,4 +12,4 @@ fi file=$(mktemp -t tmpf.XXXXXX."$extension") -nvimr "$file" +nvim "$file" diff --git a/scripts/tmuxin b/scripts/tmuxin deleted file mode 100755 index bd40a8b..0000000 --- a/scripts/tmuxin +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/env bash - -set -e - -declare yellow="\e[33m" -declare reset="\e[0m" - -echo -e "\n${yellow}Initializing your work environment...${reset}\n" - -# ================================== -# Wallstreeters -# ================================== - -session="wallstreeters" -workspace="$HOME/github.com/wallstreeters/client" - -if tmux has-session -t $session &>/dev/null; then - tmux kill-session -t "$session" -fi - -tmux new-session -d -s "$session" -c "$workspace" - -window=1 -tmux rename-window -t "${session}:${window}" "neovim" -tmux send-keys -t "${session}:${window}" "nvimr-reset" C-m - -window=2 -tmux new-window -t "${session}:${window}" -n "server" -c "$workspace" -tmux send-keys -t "${session}:${window}" "yarn psql" C-m - -tmux select-window -t :+1 - -# ================================== -# ahorta -# ================================== - -session="ahorta" -workspace="$HOME/github.com/ahorta-labs/ahorta" - -if tmux has-session -t $session &>/dev/null; then - tmux kill-session -t "$session" -fi - -tmux new-session -d -s "$session" -c "$workspace" - -window=1 -tmux rename-window -t "${session}:${window}" "neovim" -tmux send-keys -t "${session}:${window}" "nvimr-reset" C-m - -window=2 -tmux new-window -t "${session}:${window}" -n "server" -c "$workspace" -tmux send-keys -t "${session}:${window}" "yarn psql" C-m - -tmux select-window -t :+1 - -# ================================== -# Other Configs -# ================================== - -# attach to the working tmux session -# tmux attach-session -t wallstreeters -session=$( - tmux ls | - fzf-tmux -p 40% --multi --prompt="Your sessions > " -) -session=${session%%:*} - -if [[ -z "$session" ]]; then - echo "session cannot be empty" - exit 1 -fi - -tmux attach-session -t "$session" diff --git a/scripts/today b/scripts/today deleted file mode 100755 index 4ece2c8..0000000 --- a/scripts/today +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash - -set -e - -declare -r ZET="${HOME}/github.com/odas0r/zet" -declare -r JOURNAL="$ZET/journal" -declare -r DAILY_TEMPLATE="$ZET/.templates/daily.tmpl.md" - -currentDate=$(date +"%Y-%m-%d") - -file="$JOURNAL/${currentDate}.md" - -if [[ ! -f "$file" ]]; then - # create a new journal using the `tmpl` script - export title="Journal Entry, ${currentDate}" - tmpl "$DAILY_TEMPLATE" >"$file" - - # Open the daily file - nvimr "$file" -else - nvimr "$file" -fi diff --git a/scripts/tunnel b/scripts/tunnel deleted file mode 100755 index feef353..0000000 --- a/scripts/tunnel +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env bash - -set -eo pipefail - -# start a cloudflared tunnel on a given domain to a given localhost -# usage: tunnel | -# example: tunnel localhost:80 - -DEFAULT_TUNNEL="preview" - -if [[ -n "$WSL_DISTRO_NAME" ]]; then - DEFAULT_TUNNEL="guilherme" -fi - -if [[ $# -eq 1 ]]; then - tunnel="$DEFAULT_TUNNEL" - localhost="$1" -elif [[ $# -eq 2 ]]; then - tunnel="$1" - localhost="$2" -else - echo "usage: tunnel | " - exit 1 -fi - -# check if the tunnel exists -if ! cloudflared tunnel list | grep -q "$tunnel"; then - echo "tunnel $tunnel does not exist" - exit 1 -fi - -echo -echo "starting tunnel $tunnel to $localhost" -echo "press ctrl-c to stop" -echo - -sudo sysctl -w net.core.rmem_max=2500000 -sudo sysctl -w net.core.wmem_max=2500000 - -# start the tunnel using quic protoco a.k.a http/3 -cloudflared tunnel --protocol quic --url "$localhost" run "$tunnel" diff --git a/scripts/tunnel-config b/scripts/tunnel-config deleted file mode 100755 index 9e8b12a..0000000 --- a/scripts/tunnel-config +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -nvimr /usr/local/etc/cloudflared/config.yml diff --git a/scripts/tunnel-ls b/scripts/tunnel-ls deleted file mode 100755 index becc4ea..0000000 --- a/scripts/tunnel-ls +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -cloudflared tunnel list "$@" diff --git a/scripts/tunnel-random b/scripts/tunnel-random deleted file mode 100755 index 07668df..0000000 --- a/scripts/tunnel-random +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash - -set -eo pipefail - -if [[ $# -eq 1 ]]; then - localhost="$1" -else - echo "usage: tunnel-random " - exit 1 -fi - -echo -echo "press ctrl-c to stop" -echo - -sudo sysctl -w net.core.rmem_max=2500000 -sudo sysctl -w net.core.wmem_max=2500000 - -# start the tunnel using quic protoco a.k.a http/3 -cloudflared tunnel --protocol quic --url "$localhost" diff --git a/scripts/unmark b/scripts/unmark deleted file mode 100755 index bf7fe3e..0000000 --- a/scripts/unmark +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -rm -i "$MARKPATH/$1" diff --git a/scripts/update b/scripts/update deleted file mode 100755 index 5d702a6..0000000 --- a/scripts/update +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -sudo apt update && sudo apt upgrade -y diff --git a/scripts/x b/scripts/x deleted file mode 120000 index 4c311c1..0000000 --- a/scripts/x +++ /dev/null @@ -1 +0,0 @@ -/home/odas0r/github.com/odas0r/x-cmd/x \ No newline at end of file diff --git a/scripts/xdg-open b/scripts/xdg-open deleted file mode 100755 index b864127..0000000 --- a/scripts/xdg-open +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -open "$1" diff --git a/scripts/zip-cp b/scripts/zip-cp deleted file mode 100755 index e2e4ed7..0000000 --- a/scripts/zip-cp +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -# zip an given directory recursively to /tmp and copy it to the clipboard -# and then remove the zip file -dir="$1" - -if [[ -z "$dir" ]]; then - echo "Usage: $0 " - exit 1 -fi - -if [[ ! -d "$dir" ]]; then - echo "Error: $dir is not a directory" - exit 1 -fi - -# cp the folder to tmp without node_modules -rsync -a --exclude=node_modules "$dir" "/tmp/$(basename "$dir")" - -# zip the folder -zip -r "/tmp/$(basename "$dir").zip" "/tmp/$(basename "$dir")" - -# open the folder in the file manager -open "/tmp" diff --git a/scripts/zl b/scripts/zl index c6baa55..6f84213 100755 --- a/scripts/zl +++ b/scripts/zl @@ -1,3 +1,3 @@ #!/bin/bash -nvimr -c "ZetLast" +nvim -c "ZetLast" diff --git a/scripts/zn b/scripts/zn index a8306ee..fd6ce42 100755 --- a/scripts/zn +++ b/scripts/zn @@ -2,4 +2,4 @@ set -euo pipefail -nvimr "$(zet new "$@")" +nvim "$(zet new "$@")" diff --git a/setup b/setup index 4c37b70..4407deb 100755 --- a/setup +++ b/setup @@ -1,28 +1,14 @@ #!/usr/bin/env bash -export DOT="$HOME/github.com/odas0r/dot" +DOT="$HOME/github.com/odas0r/dot" # install custom scripts mkdir -p "$HOME/.local/bin" -ln -sf "$DOT/scripts" "$HOME/.local/bin/scripts" +ln -sf "$HOME/github.com/odas0r/dot/scripts" "$HOME/.local/bin/scripts" -ln -sf "$DOT/bashrc" "$HOME/.bashrc" -ln -sf "$DOT/inputrc" "$HOME/.inputrc" -ln -sf "$DOT/psqlrc" "$HOME/.psqlrc" -ln -sf "$DOT/bash" "$HOME/.bash" +ln -sf "$HOME/github.com/odas0r/dot/bashrc" "$HOME/.bashrc" +ln -sf "$HOME/github.com/odas0r/dot/inputrc" "$HOME/.inputrc" +ln -sf "$HOME/github.com/odas0r/dot/psqlrc" "$HOME/.psqlrc" +ln -sf "$HOME/github.com/odas0r/dot/bash" "$HOME/.bash" -printf "Executing all setup scripts ✨...\n" - -readarray -d '' folders < <( - find "$DOT" -mindepth 1 -maxdepth 1 -type d \ - -not -path "$DOT/.git" -) - -for path in $folders; do - # if path contains install continue to next - [[ "$path" == *install* ]] && continue - - cd "$path" - [[ -f "./setup" ]] && ./setup - cd - >/dev/null || exit 1 -done +echo "Executing all setup scripts ✨..." diff --git a/tmux/setup b/tmux/setup deleted file mode 100755 index cf39d6a..0000000 --- a/tmux/setup +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -ln -sf "$DOT/tmux/tmux.conf" "$HOME/.tmux.conf" - -echo "Tmux setup done! 🌟" diff --git a/tmux/tmux.conf b/tmux/tmux.conf deleted file mode 100644 index e40dbcc..0000000 --- a/tmux/tmux.conf +++ /dev/null @@ -1,99 +0,0 @@ -# Man page on web -# -# https://man.openbsd.org/OpenBSD-current/man1/tmux.1 - -# General settings -set -g escape-time 50 -set -g repeat-time 200 -set -g default-terminal "$TERM" -set -ag terminal-overrides ",$TERM:Tc" -set -g renumber-windows on -set -g history-limit 50001 -set -g mouse on -set -g base-index 1 - -set -g focus-events on - -# Set default shell to bash -set-option -g default-shell /bin/bash -set-option -g default-command bash -set-option -g lock-after-time 1800 - -# Appearance and colors (Gruvbox theme) -set -g status-style fg=colour250 -set -g window-status-current-style fg=colour223 -set -g pane-border-style fg=colour237 -set -g pane-active-border-style fg=colour250 -set -g message-style bg=colour239,fg=colour223 - -# Status bar configuration -set -g status on -set -g status-interval 1 -set -g status-position top -set -g status-left "#[fg=gray,bold bg=black align=left] #(pomo print)" -set -g status-left-length 50 - -set -g status-right "%a, %b %-e, %-l:%M:%S %p" -set -g status-right-length 50 -set -g window-status-current-format "#[fg=black,bold bg=default]│#[fg=colour223 bg=black]#W#[fg=black,bold bg=default]│" - -# Enable aggressive resizing and automatic renaming of windows -setw -g aggressive-resize on -setw -g automatic-rename on -setw -g pane-base-index 1 - -# Clipboard synchronization (Ensure `xclip` or appropriate clipboard utility is installed) -set -g set-clipboard external - -# Undercurl and color support for specific terminals -set -as terminal-overrides ",$TERM:Smulx=\E[4::%p1%dm,Setulc=\E[58::2::%p1%{65536}%/%d::%p1%{256}%/%{255}%&%d::%p1%{255}%&%d%;m" - -# ----------------------------------------------------------------------------- -# Key bindings -# ----------------------------------------------------------------------------- - -# set a new prefix / leader key. -unbind C-b -unbind C-a -set -g prefix C-a -bind C-a send-prefix - -# reload config file -bind-key r source-file ~/.tmux.conf \; display "Config Reloaded!" - -# split panes. -unbind - -unbind c -unbind . -unbind C-m - -bind -r '\' split-window -h -c "#{pane_current_path}" -bind -r '§' split-window -h -c "#{pane_current_path}" -bind -r - split-window -v -c "#{pane_current_path}" -bind -r c new-window -c "#{pane_current_path}" - -# move pane to the right -bind -r . swap-window -t +1 \; select-window -t +1 -bind -r , swap-window -t -1 \; select-window -t -1 - -bind -r g display-popup -w 100% -h 100% -EE lzg -bind -r d display-popup -w 100% -h 100% -EE lzd - -# search-mode -bind -r f copy-mode - -# set key-mode to vi -set-window-option -g mode-keys vi - - -# vi keys to resize -bind -r C-k resize-pane -U 5 -bind -r C-j resize-pane -D 5 -bind -r C-h resize-pane -L 5 -bind -r C-l resize-pane -R 5 - -# vi keys to navigate panes -bind-key -r k select-pane -U -bind-key -r j select-pane -D -bind-key -r h select-pane -L -bind-key -r l select-pane -R From b3f8ed0c7b25e63dfb6db40225e5aa9e1aa55567 Mon Sep 17 00:00:00 2001 From: odas0r Date: Thu, 17 Apr 2025 05:22:36 +0100 Subject: [PATCH 2/7] fix: fixing gnu utils --- bash/aliases.sh | 8 ++++---- bash/path.sh | 14 +++++++++++++- bashrc | 2 ++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/bash/aliases.sh b/bash/aliases.sh index 473a533..42d708a 100644 --- a/bash/aliases.sh +++ b/bash/aliases.sh @@ -1,8 +1,8 @@ #!/usr/bin/env bash alias ..="cd .." -alias ls="gls --format=single-column --classify --color --group-directories-first" -alias la="gls --format=single-column --classify --color --group-directories-first -la" +alias ls="ls --format=single-column --classify --color --group-directories-first" +alias la="ls --format=single-column --classify --color --group-directories-first -la" alias sb="source ~/.bashrc" alias luamake="$HOME/tools/lua-language-server/3rd/luamake/luamake" @@ -18,9 +18,9 @@ repos() { for path in "${paths[@]}"; do if [[ -d "$path" ]]; then if [[ -z "$all_repos" ]]; then - all_repos=$(gfind "$path" -mindepth 2 -maxdepth 2 -type d) + all_repos=$(find "$path" -mindepth 2 -maxdepth 2 -type d) else - all_repos="$all_repos"$'\n'"$(gfind "$path" -mindepth 2 -maxdepth 2 -type d)" + all_repos="$all_repos"$'\n'"$(find "$path" -mindepth 2 -maxdepth 2 -type d)" fi fi done diff --git a/bash/path.sh b/bash/path.sh index 31a2220..8b5da30 100644 --- a/bash/path.sh +++ b/bash/path.sh @@ -19,8 +19,20 @@ export ZET="$HOME/github.com/odas0r/zet" export GOROOT="/usr/local/go" export GOPATH="$HOME/go" +# Fixing GNU utils in macOS +# +# brew install coreutils findutils gnu-sed gawk grep gnu-tar +# +GNU_UTILS="" +GNU_UTILS+="/opt/homebrew/opt/coreutils/libexec/gnubin/man:" +GNU_UTILS+="/opt/homebrew/opt/findutils/libexec/gnubin:" # find +GNU_UTILS+="/opt/homebrew/opt/grep/libexec/gnubin:" # grep +GNU_UTILS+="/opt/homebrew/opt/gawk/libexec/gnubin:" # awk +GNU_UTILS+="/opt/homebrew/opt/gnu-sed/libexec/gnubin:" # sed +GNU_UTILS+="/opt/homebrew/opt/gnu-tar/libexec/gnubin" # tar + # Global Path -PATH="$PATH:/usr/local/bin:/usr/bin:/bin:/sbin:/usr/sbin:" +PATH="$GNU_UTILS:$PATH:/usr/local/bin:/usr/bin:/bin:/sbin:/usr/sbin:" PATH+="$LOCAL_BIN:$LOCAL_BIN_SCRIPTS:" PATH+="$GOROOT/bin:$GOPATH/bin:" diff --git a/bashrc b/bashrc index 4dd74ef..fe1b23b 100644 --- a/bashrc +++ b/bashrc @@ -1,5 +1,7 @@ #!/usr/bin/env bash +export SHELL="/usr/local/bin/bash" + eval "$(/opt/homebrew/bin/brew shellenv)" # source all files From 0af9a62f9caf213ae02fcd634b2a971629a7ad5b Mon Sep 17 00:00:00 2001 From: odas0r Date: Thu, 17 Apr 2025 07:09:55 +0100 Subject: [PATCH 3/7] try: we're re-doing the configs for darwin since most failed --- bash/editor.sh | 21 +------- bash/nvim.sh | 3 ++ bash/path.sh | 13 ++--- install/fzf | 11 +++++ kitty/kitty.conf | 70 +++++++++++++-------------- nvim/lua/odas0r/plugins/formatter.lua | 29 +++++------ scripts/dot | 2 +- scripts/go | 8 ++- scripts/goinstall | 14 ++++++ scripts/localpid | 11 ----- scripts/newi | 2 +- scripts/newx | 2 +- scripts/nvr | 11 +++++ scripts/open | 18 ------- scripts/presenter-mode | 18 ------- scripts/zl | 2 +- scripts/zn | 2 +- 17 files changed, 107 insertions(+), 130 deletions(-) create mode 100644 bash/nvim.sh create mode 100755 install/fzf create mode 100755 scripts/goinstall delete mode 100755 scripts/localpid create mode 100755 scripts/nvr delete mode 100755 scripts/open delete mode 100755 scripts/presenter-mode diff --git a/bash/editor.sh b/bash/editor.sh index b2dcfa4..cee2833 100644 --- a/bash/editor.sh +++ b/bash/editor.sh @@ -1,26 +1,7 @@ #!/usr/bin/env bash -_hasDuckyKeyboard() { - test -n "$(lsusb -v 2>/dev/null | grep -E '(^Bus|Keyboard)' | grep -w 'Varmilo Keyboard')" -} - -if [[ -z "${WSL_DISTRO_NAME}" ]]; then - # remap capslock for whole system to ESC (X only) - if [[ -n "${DISPLAY}" ]]; then - # https://gist.github.com/jatcwang/ae3b7019f219b8cdc6798329108c9aee - if _hasDuckyKeyboard; then - setxkbmap -layout pt -model macintosh - else - setxkbmap -layout pt -model asus_laptop - fi - - # Default Options - setxkbmap -option caps:escape - fi -fi - export HRULEWIDTH=73 # Define the editor -export VISUAL="nvim" +export VISUAL="nvr" export EDITOR="$VISUAL" diff --git a/bash/nvim.sh b/bash/nvim.sh new file mode 100644 index 0000000..93dbaf3 --- /dev/null +++ b/bash/nvim.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +export NVIM_SOCKET="$HOME/.cache/nvim/nvim_socket.pipe" diff --git a/bash/path.sh b/bash/path.sh index 8b5da30..b7659c9 100644 --- a/bash/path.sh +++ b/bash/path.sh @@ -5,14 +5,11 @@ export DOT="$HOME/github.com/odas0r/dot" export SSH_AUTH_SOCK="$HOME/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock" export LOCAL_BIN="$HOME/.local/bin" -# the PATH for global scripts export LOCAL_BIN_SCRIPTS="$HOME/.local/bin/scripts" -# pnpm package manager export PNPM_HOME="$HOME/.local/share/pnpm" export VOLTA_HOME="$HOME/.volta" -# zet path export ZET="$HOME/github.com/odas0r/zet" # Go @@ -24,12 +21,12 @@ export GOPATH="$HOME/go" # brew install coreutils findutils gnu-sed gawk grep gnu-tar # GNU_UTILS="" -GNU_UTILS+="/opt/homebrew/opt/coreutils/libexec/gnubin/man:" +GNU_UTILS+="/opt/homebrew/opt/coreutils/libexec/gnubin:" # coreutils GNU_UTILS+="/opt/homebrew/opt/findutils/libexec/gnubin:" # find -GNU_UTILS+="/opt/homebrew/opt/grep/libexec/gnubin:" # grep -GNU_UTILS+="/opt/homebrew/opt/gawk/libexec/gnubin:" # awk -GNU_UTILS+="/opt/homebrew/opt/gnu-sed/libexec/gnubin:" # sed -GNU_UTILS+="/opt/homebrew/opt/gnu-tar/libexec/gnubin" # tar +GNU_UTILS+="/opt/homebrew/opt/grep/libexec/gnubin:" # grep +GNU_UTILS+="/opt/homebrew/opt/gawk/libexec/gnubin:" # awk +GNU_UTILS+="/opt/homebrew/opt/gnu-sed/libexec/gnubin:" # sed +GNU_UTILS+="/opt/homebrew/opt/gnu-tar/libexec/gnubin" # tar # Global Path PATH="$GNU_UTILS:$PATH:/usr/local/bin:/usr/bin:/bin:/sbin:/usr/sbin:" diff --git a/install/fzf b/install/fzf new file mode 100755 index 0000000..1850c29 --- /dev/null +++ b/install/fzf @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +set -euo pipefail + +if [[ ! -d "$HOME/.fzf" ]]; then + git clone --depth 1 https://github.com/junegunn/fzf.git "$HOME/.fzf" +else + cd "$HOME/.fzf" && git pull +fi + +"$HOME/.fzf/install" diff --git a/kitty/kitty.conf b/kitty/kitty.conf index 9caebf0..ba99e66 100644 --- a/kitty/kitty.conf +++ b/kitty/kitty.conf @@ -70,49 +70,49 @@ map ctrl+. kitten unicode_input enabled_layouts splits # layout creation -map cmd+a>- launch --location=hsplit --cwd=current -map cmd+a>\ launch --location=vsplit --cwd=current +map ctrl+a>- launch --location=hsplit --cwd=current +map ctrl+a>\ launch --location=vsplit --cwd=current # layout management like tmux -map cmd+a>h neighboring_window left -map cmd+a>l neighboring_window right -map cmd+a>k neighboring_window up -map cmd+a>j neighboring_window down +map ctrl+a>h neighboring_window left +map ctrl+a>l neighboring_window right +map ctrl+a>k neighboring_window up +map ctrl+a>j neighboring_window down -map cmd+a>left resize_window narrower -map cmd+a>right resize_window wider -map cmd+a>up resize_window taller -map cmd+a>down resize_window shorter 3 -map cmd+a>0 resize_window reset +map ctrl+a>left resize_window narrower +map ctrl+a>right resize_window wider +map ctrl+a>up resize_window taller +map ctrl+a>down resize_window shorter 3 +map ctrl+a>0 resize_window reset # Scrollback search buffer -map cmd+a>f show_scrollback -map cmd+a>g launch --type overlay --title='Lazygit' --cwd=current --copy-env lzg -map cmd+a>d launch --type overlay --title='Lazydocker' --cwd=current --copy-env lzd -# map cmd+a>l launch --type overlay --title='Logs' nvim ~/github.com/odas0r/zet/log.md +map ctrl+a>f show_scrollback +map ctrl+a>g launch --type overlay --title='Lazygit' --cwd=current --copy-env lzg +map ctrl+a>d launch --type overlay --title='Lazydocker' --cwd=current --copy-env lzd +# map ctrl+a>l launch --type overlay --title='Logs' nvim ~/github.com/odas0r/zet/log.md # tab navigation -map cmd+a>c launch --cwd=current --type=tab -map cmd+a>n next_tab -map cmd+a>p previous_tab -map cmd+a>r load_config_file -map cmd+, set_tab_title -map cmd+a>w close_window -map cmd+a>z toggle_layout stack # this does not work? :( -map cmd+a>: kitty_shell window -map cmd+a>Q close_window +map ctrl+a>c launch --cwd=current --type=tab +map ctrl+a>n next_tab +map ctrl+a>p previous_tab +map ctrl+a>r load_config_file +map ctrl+, set_tab_title +map ctrl+a>w close_window +map ctrl+a>z toggle_layout stack # this does not work? :( +map ctrl+a>: kitty_shell window +map ctrl+a>Q close_window # tab management to 1, 2, 3, 4, 5, 6, 7, 8, 9 -map cmd+a>1 goto_tab 1 -map cmd+a>2 goto_tab 2 -map cmd+a>3 goto_tab 3 -map cmd+a>4 goto_tab 4 -map cmd+a>5 goto_tab 5 -map cmd+a>6 goto_tab 6 -map cmd+a>7 goto_tab 7 -map cmd+a>8 goto_tab 8 -map cmd+a>9 goto_tab 9 +map ctrl+a>1 goto_tab 1 +map ctrl+a>2 goto_tab 2 +map ctrl+a>3 goto_tab 3 +map ctrl+a>4 goto_tab 4 +map ctrl+a>5 goto_tab 5 +map ctrl+a>6 goto_tab 6 +map ctrl+a>7 goto_tab 7 +map ctrl+a>8 goto_tab 8 +map ctrl+a>9 goto_tab 9 # move tab to the left -map cmd+a>, move_tab_backward -map cmd+a>. move_tab_forward +map ctrl+a>, move_tab_backward +map ctrl+a>. move_tab_forward diff --git a/nvim/lua/odas0r/plugins/formatter.lua b/nvim/lua/odas0r/plugins/formatter.lua index 0cabe31..efc29f0 100644 --- a/nvim/lua/odas0r/plugins/formatter.lua +++ b/nvim/lua/odas0r/plugins/formatter.lua @@ -1,14 +1,15 @@ -local Utils = require("odas0r.utils") +local util = require("odas0r.utils") return { "mhartington/formatter.nvim", cmd = "FormatWrite", init = function() - Utils.map("n", "gp", function() + util.map("n", "gp", function() vim.cmd("FormatWrite") end, { silent = false }) end, config = function() + local fmtUtil = require("formatter.util") local formatter = require("formatter") local prettierConfig = function() @@ -17,21 +18,21 @@ return { -- end -- set env variable - -- return { - -- exe = "prettier", - -- args = { - -- "--stdin-filepath", - -- util.escape_path(util.get_current_buffer_file_path()), - -- }, - -- stdin = true, - -- try_node_modules = true, - -- } - return { - exe = "prettierd", - args = { vim.api.nvim_buf_get_name(0) }, + exe = "prettier", + args = { + "--stdin-filepath", + fmtUtil.escape_path(fmtUtil.get_current_buffer_file_path()), + }, stdin = true, + try_node_modules = true, } + + -- return { + -- exe = "prettierd", + -- args = { vim.api.nvim_buf_get_name(0) }, + -- stdin = true, + -- } end local formatterConfig = { diff --git a/scripts/dot b/scripts/dot index 1f59907..5b012a3 100755 --- a/scripts/dot +++ b/scripts/dot @@ -19,6 +19,6 @@ if [[ -f $file ]]; then open "${file}" exit 0 else - nvim "${file}" + nvr "${file}" fi fi diff --git a/scripts/go b/scripts/go index b875329..c737544 100755 --- a/scripts/go +++ b/scripts/go @@ -2,6 +2,12 @@ set -euo pipefail -version="1.22.0" +version="1.24.2" + +# check if the command is available +if ! command -v "go${version}" &> /dev/null; then + echo "go${version} not found, please install it first." + exit 1 +fi exec "go${version}" "$@" diff --git a/scripts/goinstall b/scripts/goinstall new file mode 100755 index 0000000..57c9742 --- /dev/null +++ b/scripts/goinstall @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +set -euo pipefail + +version="$1" + +# validate version semver format +if ! [[ $version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "Invalid version format. Please use semver format (e.g., 1.24.2)." + exit 1 +fi + +/usr/local/go/bin/go install "golang.org/dl/go${version}@latest" +go${version} download diff --git a/scripts/localpid b/scripts/localpid deleted file mode 100755 index 2531af4..0000000 --- a/scripts/localpid +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -# Find the PID of a server w/ a given port - -if [[ -z $1 ]]; then - echo 'argument must be a PORT, e.g 80' - exit 1 - -fi - -sudo lsof -i tcp:"$1" diff --git a/scripts/newi b/scripts/newi index fefdfcc..6444224 100755 --- a/scripts/newi +++ b/scripts/newi @@ -24,4 +24,4 @@ set -euo pipefail EOF chmod +x "$installerPath" -nvim "$installerPath" +nvr "$installerPath" diff --git a/scripts/newx b/scripts/newx index 87932cd..4624a1f 100755 --- a/scripts/newx +++ b/scripts/newx @@ -20,4 +20,4 @@ set -euo pipefail EOF chmod +x "$path" -nvim "$path" +nvr "$path" diff --git a/scripts/nvr b/scripts/nvr new file mode 100755 index 0000000..d53d182 --- /dev/null +++ b/scripts/nvr @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +set -euo pipefail + +if [[ ! -S "$NVIM_SOCKET" ]]; then + nvim --listen "$NVIM_SOCKET" "$@" +else + # if we're on lazygit, we need to send the file to the correct buffer + filePath="$(realpath "$1")" + nvim --server "$NVIM_SOCKET" --remote-send ":wincmd p | e ${filePath}" +fi diff --git a/scripts/open b/scripts/open deleted file mode 100755 index 99e0591..0000000 --- a/scripts/open +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -if [[ -n "$WSL_DISTRO_NAME" ]]; then - if [[ "$1" =~ ^http.* ]]; then - # Debug - # tmux split-window -h "explorer.exe '$1'; echo 'URL: "$1"'; read -p 'Press enter to continue...';" - explorer.exe "$1" - else - # Debug - # string="$(wslpath -w "$1")" - # tmux split-window -h "explorer.exe '$(wslpath -w $1)'; echo 'Path: "$string"'; read -p 'Press enter to continue...';" - explorer.exe "$(wslpath -w "$1")" - fi -else - open "$@" -fi diff --git a/scripts/presenter-mode b/scripts/presenter-mode deleted file mode 100755 index 5a44df1..0000000 --- a/scripts/presenter-mode +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -STATE_FILE="$HOME/.keymap_state" - -if [ -f "$STATE_FILE" ]; then - xmodmap -e 'keycode 111 = Up' - xmodmap -e 'keycode 116 = Down' - rm "$STATE_FILE" - echo "Key mappings reset to default." -else - xmodmap -e 'keycode 111 = Left' - xmodmap -e 'keycode 116 = Right' - touch "$STATE_FILE" - echo "Key mappings remapped (Up to Left, Down to Right)." -fi - diff --git a/scripts/zl b/scripts/zl index 6f84213..2d6ef62 100755 --- a/scripts/zl +++ b/scripts/zl @@ -1,3 +1,3 @@ #!/bin/bash -nvim -c "ZetLast" +nvr -c "ZetLast" diff --git a/scripts/zn b/scripts/zn index fd6ce42..91843f4 100755 --- a/scripts/zn +++ b/scripts/zn @@ -2,4 +2,4 @@ set -euo pipefail -nvim "$(zet new "$@")" +nvr "$(zet new "$@")" From d5b6ae607b53bf40cc05406ce78158fc0327b2ef Mon Sep 17 00:00:00 2001 From: odas0r Date: Sat, 3 May 2025 19:10:42 +0100 Subject: [PATCH 4/7] refactor: darwin config is cooking --- bash/autocomplete/bash.sh | 4 - bash/autocomplete/bash_completion.sh | 8 + bash/autocomplete/brew.sh | 7 + bash/autocomplete/docker.sh | 429 ++++++++++++++++++ bash/autocomplete/ngrok.sh | 5 + bash/autocomplete/ssh.sh | 2 + bash/autocomplete/task.sh | 2 + bash/autocomplete/x.sh | 2 +- install/golang | 45 -- install/gotools | 8 + install/pnpm | 2 +- kitty/kitty.conf | 12 +- nvim/after/queries/typescript/injections.scm | 16 + nvim/lua/odas0r/internal/zet.lua | 174 +++---- .../odas0r/plugins/neovim-session-manager.lua | 1 + nvim/lua/odas0r/plugins/nvim-lspconfig.lua | 10 +- scripts/clipboard | 2 +- scripts/radius | 15 +- scripts/tunnel | 13 + 19 files changed, 611 insertions(+), 146 deletions(-) delete mode 100644 bash/autocomplete/bash.sh create mode 100644 bash/autocomplete/bash_completion.sh create mode 100644 bash/autocomplete/brew.sh create mode 100644 bash/autocomplete/docker.sh create mode 100644 bash/autocomplete/ngrok.sh delete mode 100755 install/golang create mode 100755 install/gotools create mode 100755 scripts/tunnel diff --git a/bash/autocomplete/bash.sh b/bash/autocomplete/bash.sh deleted file mode 100644 index 743f018..0000000 --- a/bash/autocomplete/bash.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -# debian,... -[[ -f "/usr/share/bash-completion/bash_completion" ]] && . "/usr/share/bash-completion/bash_completion" diff --git a/bash/autocomplete/bash_completion.sh b/bash/autocomplete/bash_completion.sh new file mode 100644 index 0000000..1630a8e --- /dev/null +++ b/bash/autocomplete/bash_completion.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +if [[ "$(uname)" == "Darwin" ]]; then + # https://docs.docker.com/engine/cli/completion/#bash + [[ -r "/opt/homebrew/etc/profile.d/bash_completion.sh" ]] && . "/opt/homebrew/etc/profile.d/bash_completion.sh" +else + [[ -f "/usr/share/bash-completion/bash_completion" ]] && . "/usr/share/bash-completion/bash_completion" +fi diff --git a/bash/autocomplete/brew.sh b/bash/autocomplete/brew.sh new file mode 100644 index 0000000..745a9bc --- /dev/null +++ b/bash/autocomplete/brew.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +for file in /opt/homebrew/etc/bash_completion.d/*; do + if [[ -f $file ]]; then + source "$file" + fi +done diff --git a/bash/autocomplete/docker.sh b/bash/autocomplete/docker.sh new file mode 100644 index 0000000..66cda05 --- /dev/null +++ b/bash/autocomplete/docker.sh @@ -0,0 +1,429 @@ +#!/usr/bin/env bash + +# bash completion V2 for docker -*- shell-script -*- + +__docker_debug() { + if [[ -n ${BASH_COMP_DEBUG_FILE-} ]]; then + echo "$*" >>"${BASH_COMP_DEBUG_FILE}" + fi +} + +# Macs have bash3 for which the bash-completion package doesn't include +# _init_completion. This is a minimal version of that function. +__docker_init_completion() { + COMPREPLY=() + _get_comp_words_by_ref "$@" cur prev words cword +} + +# This function calls the docker program to obtain the completion +# results and the directive. It fills the 'out' and 'directive' vars. +__docker_get_completion_results() { + local requestComp lastParam lastChar args + + # Prepare the command to request completions for the program. + # Calling ${words[0]} instead of directly docker allows handling aliases + args=("${words[@]:1}") + requestComp="${words[0]} __complete ${args[*]}" + + lastParam=${words[$((${#words[@]} - 1))]} + lastChar=${lastParam:$((${#lastParam} - 1)):1} + __docker_debug "lastParam ${lastParam}, lastChar ${lastChar}" + + if [[ -z ${cur} && ${lastChar} != = ]]; then + # If the last parameter is complete (there is a space following it) + # We add an extra empty parameter so we can indicate this to the go method. + __docker_debug "Adding extra empty parameter" + requestComp="${requestComp} ''" + fi + + # When completing a flag with an = (e.g., docker -n=) + # bash focuses on the part after the =, so we need to remove + # the flag part from $cur + if [[ ${cur} == -*=* ]]; then + cur="${cur#*=}" + fi + + __docker_debug "Calling ${requestComp}" + # Use eval to handle any environment variables and such + out=$(eval "${requestComp}" 2>/dev/null) + + # Extract the directive integer at the very end of the output following a colon (:) + directive=${out##*:} + # Remove the directive + out=${out%:*} + if [[ ${directive} == "${out}" ]]; then + # There is not directive specified + directive=0 + fi + __docker_debug "The completion directive is: ${directive}" + __docker_debug "The completions are: ${out}" +} + +__docker_process_completion_results() { + local shellCompDirectiveError=1 + local shellCompDirectiveNoSpace=2 + local shellCompDirectiveNoFileComp=4 + local shellCompDirectiveFilterFileExt=8 + local shellCompDirectiveFilterDirs=16 + local shellCompDirectiveKeepOrder=32 + + if (((directive & shellCompDirectiveError) != 0)); then + # Error code. No completion. + __docker_debug "Received error from custom completion go code" + return + else + if (((directive & shellCompDirectiveNoSpace) != 0)); then + if [[ $(type -t compopt) == builtin ]]; then + __docker_debug "Activating no space" + compopt -o nospace + else + __docker_debug "No space directive not supported in this version of bash" + fi + fi + if (((directive & shellCompDirectiveKeepOrder) != 0)); then + if [[ $(type -t compopt) == builtin ]]; then + # no sort isn't supported for bash less than < 4.4 + if [[ ${BASH_VERSINFO[0]} -lt 4 || (${BASH_VERSINFO[0]} -eq 4 && ${BASH_VERSINFO[1]} -lt 4) ]]; then + __docker_debug "No sort directive not supported in this version of bash" + else + __docker_debug "Activating keep order" + compopt -o nosort + fi + else + __docker_debug "No sort directive not supported in this version of bash" + fi + fi + if (((directive & shellCompDirectiveNoFileComp) != 0)); then + if [[ $(type -t compopt) == builtin ]]; then + __docker_debug "Activating no file completion" + compopt +o default + else + __docker_debug "No file completion directive not supported in this version of bash" + fi + fi + fi + + # Separate activeHelp from normal completions + local completions=() + local activeHelp=() + __docker_extract_activeHelp + + if (((directive & shellCompDirectiveFilterFileExt) != 0)); then + # File extension filtering + local fullFilter="" filter filteringCmd + + # Do not use quotes around the $completions variable or else newline + # characters will be kept. + for filter in ${completions[*]}; do + fullFilter+="$filter|" + done + + filteringCmd="_filedir $fullFilter" + __docker_debug "File filtering command: $filteringCmd" + $filteringCmd + elif (((directive & shellCompDirectiveFilterDirs) != 0)); then + # File completion for directories only + + local subdir + subdir=${completions[0]} + if [[ -n $subdir ]]; then + __docker_debug "Listing directories in $subdir" + pushd "$subdir" >/dev/null 2>&1 && _filedir -d && popd >/dev/null 2>&1 || return + else + __docker_debug "Listing directories in ." + _filedir -d + fi + else + __docker_handle_completion_types + fi + + __docker_handle_special_char "$cur" : + __docker_handle_special_char "$cur" = + + # Print the activeHelp statements before we finish + __docker_handle_activeHelp +} + +__docker_handle_activeHelp() { + # Print the activeHelp statements + if ((${#activeHelp[*]} != 0)); then + if [ -z $COMP_TYPE ]; then + # Bash v3 does not set the COMP_TYPE variable. + printf "\n" + printf "%s\n" "${activeHelp[@]}" + printf "\n" + __docker_reprint_commandLine + return + fi + + # Only print ActiveHelp on the second TAB press + if [ $COMP_TYPE -eq 63 ]; then + printf "\n" + printf "%s\n" "${activeHelp[@]}" + + if ((${#COMPREPLY[*]} == 0)); then + # When there are no completion choices from the program, file completion + # may kick in if the program has not disabled it; in such a case, we want + # to know if any files will match what the user typed, so that we know if + # there will be completions presented, so that we know how to handle ActiveHelp. + # To find out, we actually trigger the file completion ourselves; + # the call to _filedir will fill COMPREPLY if files match. + if (((directive & shellCompDirectiveNoFileComp) == 0)); then + __docker_debug "Listing files" + _filedir + fi + fi + + if ((${#COMPREPLY[*]} != 0)); then + # If there are completion choices to be shown, print a delimiter. + # Re-printing the command-line will automatically be done + # by the shell when it prints the completion choices. + printf -- "--" + else + # When there are no completion choices at all, we need + # to re-print the command-line since the shell will + # not be doing it itself. + __docker_reprint_commandLine + fi + elif [ $COMP_TYPE -eq 37 ] || [ $COMP_TYPE -eq 42 ]; then + # For completion type: menu-complete/menu-complete-backward and insert-completions + # the completions are immediately inserted into the command-line, so we first + # print the activeHelp message and reprint the command-line since the shell won't. + printf "\n" + printf "%s\n" "${activeHelp[@]}" + + __docker_reprint_commandLine + fi + fi +} + +__docker_reprint_commandLine() { + # The prompt format is only available from bash 4.4. + # We test if it is available before using it. + if (x=${PS1@P}) 2>/dev/null; then + printf "%s" "${PS1@P}${COMP_LINE[@]}" + else + # Can't print the prompt. Just print the + # text the user had typed, it is workable enough. + printf "%s" "${COMP_LINE[@]}" + fi +} + +# Separate activeHelp lines from real completions. +# Fills the $activeHelp and $completions arrays. +__docker_extract_activeHelp() { + local activeHelpMarker="_activeHelp_ " + local endIndex=${#activeHelpMarker} + + while IFS='' read -r comp; do + [[ -z $comp ]] && continue + + if [[ ${comp:0:endIndex} == $activeHelpMarker ]]; then + comp=${comp:endIndex} + __docker_debug "ActiveHelp found: $comp" + if [[ -n $comp ]]; then + activeHelp+=("$comp") + fi + else + # Not an activeHelp line but a normal completion + completions+=("$comp") + fi + done <<<"${out}" +} + +__docker_handle_completion_types() { + __docker_debug "__docker_handle_completion_types: COMP_TYPE is $COMP_TYPE" + + case $COMP_TYPE in + 37 | 42) + # Type: menu-complete/menu-complete-backward and insert-completions + # If the user requested inserting one completion at a time, or all + # completions at once on the command-line we must remove the descriptions. + # https://github.com/spf13/cobra/issues/1508 + + # If there are no completions, we don't need to do anything + ((${#completions[@]} == 0)) && return 0 + + local tab=$'\t' + + # Strip any description and escape the completion to handled special characters + IFS=$'\n' read -ra completions -d '' < <(printf "%q\n" "${completions[@]%%$tab*}") + + # Only consider the completions that match + IFS=$'\n' read -ra COMPREPLY -d '' < <( + IFS=$'\n' + compgen -W "${completions[*]}" -- "${cur}" + ) + + # compgen looses the escaping so we need to escape all completions again since they will + # all be inserted on the command-line. + IFS=$'\n' read -ra COMPREPLY -d '' < <(printf "%q\n" "${COMPREPLY[@]}") + ;; + + *) + # Type: complete (normal completion) + __docker_handle_standard_completion_case + ;; + esac +} + +__docker_handle_standard_completion_case() { + local tab=$'\t' + + # If there are no completions, we don't need to do anything + ((${#completions[@]} == 0)) && return 0 + + # Short circuit to optimize if we don't have descriptions + if [[ "${completions[*]}" != *$tab* ]]; then + # First, escape the completions to handle special characters + IFS=$'\n' read -ra completions -d '' < <(printf "%q\n" "${completions[@]}") + # Only consider the completions that match what the user typed + IFS=$'\n' read -ra COMPREPLY -d '' < <( + IFS=$'\n' + compgen -W "${completions[*]}" -- "${cur}" + ) + + # compgen looses the escaping so, if there is only a single completion, we need to + # escape it again because it will be inserted on the command-line. If there are multiple + # completions, we don't want to escape them because they will be printed in a list + # and we don't want to show escape characters in that list. + if ((${#COMPREPLY[@]} == 1)); then + COMPREPLY[0]=$(printf "%q" "${COMPREPLY[0]}") + fi + return 0 + fi + + local longest=0 + local compline + # Look for the longest completion so that we can format things nicely + while IFS='' read -r compline; do + [[ -z $compline ]] && continue + + # Before checking if the completion matches what the user typed, + # we need to strip any description and escape the completion to handle special + # characters because those escape characters are part of what the user typed. + # Don't call "printf" in a sub-shell because it will be much slower + # since we are in a loop. + printf -v comp "%q" "${compline%%$tab*}" &>/dev/null || comp=$(printf "%q" "${compline%%$tab*}") + + # Only consider the completions that match + [[ $comp == "$cur"* ]] || continue + + # The completions matches. Add it to the list of full completions including + # its description. We don't escape the completion because it may get printed + # in a list if there are more than one and we don't want show escape characters + # in that list. + COMPREPLY+=("$compline") + + # Strip any description before checking the length, and again, don't escape + # the completion because this length is only used when printing the completions + # in a list and we don't want show escape characters in that list. + comp=${compline%%$tab*} + if ((${#comp} > longest)); then + longest=${#comp} + fi + done < <(printf "%s\n" "${completions[@]}") + + # If there is a single completion left, remove the description text and escape any special characters + if ((${#COMPREPLY[*]} == 1)); then + __docker_debug "COMPREPLY[0]: ${COMPREPLY[0]}" + COMPREPLY[0]=$(printf "%q" "${COMPREPLY[0]%%$tab*}") + __docker_debug "Removed description from single completion, which is now: ${COMPREPLY[0]}" + else + # Format the descriptions + __docker_format_comp_descriptions $longest + fi +} + +__docker_handle_special_char() { + local comp="$1" + local char=$2 + if [[ "$comp" == *${char}* && "$COMP_WORDBREAKS" == *${char}* ]]; then + local word=${comp%"${comp##*${char}}"} + local idx=${#COMPREPLY[*]} + while ((--idx >= 0)); do + COMPREPLY[idx]=${COMPREPLY[idx]#"$word"} + done + fi +} + +__docker_format_comp_descriptions() { + local tab=$'\t' + local comp desc maxdesclength + local longest=$1 + + local i ci + for ci in ${!COMPREPLY[*]}; do + comp=${COMPREPLY[ci]} + # Properly format the description string which follows a tab character if there is one + if [[ "$comp" == *$tab* ]]; then + __docker_debug "Original comp: $comp" + desc=${comp#*$tab} + comp=${comp%%$tab*} + + # $COLUMNS stores the current shell width. + # Remove an extra 4 because we add 2 spaces and 2 parentheses. + maxdesclength=$((COLUMNS - longest - 4)) + + # Make sure we can fit a description of at least 8 characters + # if we are to align the descriptions. + if ((maxdesclength > 8)); then + # Add the proper number of spaces to align the descriptions + for ((i = ${#comp}; i < longest; i++)); do + comp+=" " + done + else + # Don't pad the descriptions so we can fit more text after the completion + maxdesclength=$((COLUMNS - ${#comp} - 4)) + fi + + # If there is enough space for any description text, + # truncate the descriptions that are too long for the shell width + if ((maxdesclength > 0)); then + if ((${#desc} > maxdesclength)); then + desc=${desc:0:$((maxdesclength - 1))} + desc+="…" + fi + comp+=" ($desc)" + fi + COMPREPLY[ci]=$comp + __docker_debug "Final comp: $comp" + fi + done +} + +__start_docker() { + local cur prev words cword split + + COMPREPLY=() + + # Call _init_completion from the bash-completion package + # to prepare the arguments properly + if declare -F _init_completion >/dev/null 2>&1; then + _init_completion -n =: || return + else + __docker_init_completion -n =: || return + fi + + __docker_debug + __docker_debug "========= starting completion logic ==========" + __docker_debug "cur is ${cur}, words[*] is ${words[*]}, #words[@] is ${#words[@]}, cword is $cword" + + # The user could have moved the cursor backwards on the command-line. + # We need to trigger completion from the $cword location, so we need + # to truncate the command-line ($words) up to the $cword location. + words=("${words[@]:0:$cword+1}") + __docker_debug "Truncated words[*]: ${words[*]}," + + local out directive + __docker_get_completion_results + __docker_process_completion_results +} + +if [[ $(type -t compopt) = "builtin" ]]; then + complete -o default -F __start_docker docker +else + complete -o default -o nospace -F __start_docker docker +fi + +# ex: ts=4 sw=4 et filetype=sh diff --git a/bash/autocomplete/ngrok.sh b/bash/autocomplete/ngrok.sh new file mode 100644 index 0000000..4aba527 --- /dev/null +++ b/bash/autocomplete/ngrok.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +if command -v ngrok &>/dev/null; then + eval "$(ngrok completion)" + fi diff --git a/bash/autocomplete/ssh.sh b/bash/autocomplete/ssh.sh index 420b5f6..152be85 100644 --- a/bash/autocomplete/ssh.sh +++ b/bash/autocomplete/ssh.sh @@ -1,3 +1,5 @@ +#!/usr/local/bin/bash + _ssh() { local cur prev opts COMPREPLY=() diff --git a/bash/autocomplete/task.sh b/bash/autocomplete/task.sh index 71784a2..3cafca2 100644 --- a/bash/autocomplete/task.sh +++ b/bash/autocomplete/task.sh @@ -1,3 +1,5 @@ +#!/usr/local/bin/bash + _taskfile_completions() { local cur tasks cur=${COMP_WORDS[COMP_CWORD]} diff --git a/bash/autocomplete/x.sh b/bash/autocomplete/x.sh index db1e4b0..39bad9e 100644 --- a/bash/autocomplete/x.sh +++ b/bash/autocomplete/x.sh @@ -1,4 +1,4 @@ -#! /usr/local/bin/bash +#!/usr/local/bin/bash if [[ -x "$(command -v x)" ]]; then complete -C x x diff --git a/install/golang b/install/golang deleted file mode 100755 index 6a45b70..0000000 --- a/install/golang +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/sh - -set -e - -full_version=$(curl -s https://go.dev/VERSION?m=text) -version=$(echo $full_version | grep -o 'go[0-9.]*') - -os="linux" -arch="amd64" -tarFile="${version}.${os}-${arch}.tar.gz" -url="https://go.dev/dl/${tarFile}" - -# Download the latest golang -wget --continue --show-progress "${url}" -printf "Downloaded Golang!\n" - -# Remove the old golang -sudo rm -rf /usr/local/go - -# Install the new Go -sudo tar -C /usr/local -xzf "$tarFile" -printf "Create the skeleton for your local users go directory\n" -mkdir -p "$HOME/go/bin" -mkdir -p "$HOME/go/pkg" -mkdir -p "$HOME/go/src" - -# GoPath -printf "Don't forget to add these:\n" -echo "export GOPATH=~/go" -echo 'export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin' - -# Remove Download -sudo rm "$tarFile" - -# Print Go Version -/usr/local/go/bin/go version - -######################################## -# Golang Dependencies, Tools -######################################## - -go install golang.org/x/tools/gopls@latest -go install golang.org/x/tools/cmd/goimports@latest -go install golang.org/x/tools/cmd/gorename@latest -go install golang.org/x/tools/cmd/godoc@latest diff --git a/install/gotools b/install/gotools new file mode 100755 index 0000000..698fece --- /dev/null +++ b/install/gotools @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -euo pipefail + +go install golang.org/x/tools/gopls@latest +go install golang.org/x/tools/cmd/goimports@latest +go install golang.org/x/tools/cmd/gorename@latest +go install golang.org/x/tools/cmd/godoc@latest diff --git a/install/pnpm b/install/pnpm index 25aa269..3d8c880 100755 --- a/install/pnpm +++ b/install/pnpm @@ -2,4 +2,4 @@ set -euo pipefail -curl -fsSL https://get.pnpm.io/install.sh | sh - +curl -fsSL https://get.pnpm.io/install.sh | env PNPM_VERSION=10.8.1 sh - diff --git a/kitty/kitty.conf b/kitty/kitty.conf index ba99e66..9520c03 100644 --- a/kitty/kitty.conf +++ b/kitty/kitty.conf @@ -1,6 +1,6 @@ # vim:ft=config -shell /usr/local/bin/bash +shell /opt/homebrew/bin/bash include ./themes/gruvbox.conf # include ./themes/gruvbox_light.conf @@ -8,10 +8,10 @@ include ./themes/gruvbox.conf term xterm-256color -font_family JetBrains Mono Normal -bold_font JetBrains Mono SemiBold -italic_font JetBrains Mono Italic -bold_italic_font JetBrains Mono SemiBold Italic +font_family JetBrains Mono Thin +bold_font JetBrains Mono Medium +italic_font JetBrains Mono Thin Italic +bold_italic_font JetBrains Mono Medium Italic modify_font underline_position 150% modify_font underline_thickness 1.10 @@ -23,7 +23,7 @@ adjust_column_width 100% font_size 14 # OS Specific -macos_thicken_font 0.0 +macos_thicken_font 1.0 # # Misc diff --git a/nvim/after/queries/typescript/injections.scm b/nvim/after/queries/typescript/injections.scm index 432d2a7..f7180a8 100644 --- a/nvim/after/queries/typescript/injections.scm +++ b/nvim/after/queries/typescript/injections.scm @@ -1,6 +1,22 @@ +; extends + ; css`...` (call_expression function: ((identifier) @_name (#eq? @_name "css")) arguments: ((template_string) @scss (#offset! @scss 0 1 0 -1)) ) + +; Handle member access like foo.html`...` or foo.html(`...`) +(call_expression + function: (member_expression + property: (property_identifier) @_html_prop ; Capture the property identifier + (#eq? @_html_prop "html")) ; Check if the property name is "html" + arguments: [ ; Match either arguments(...) or template_string + (arguments ; Case 1: foo.html(...) + (template_string) @injection.content) + (template_string) @injection.content ; Case 2: foo.html`...` + ] + (#offset! @injection.content 0 1 0 -1) ; Remove backticks ` and ` + (#set! injection.include-children) ; Include interpolated parts ${...} + (#set! injection.language "html")) ; Set the injected language to HTML diff --git a/nvim/lua/odas0r/internal/zet.lua b/nvim/lua/odas0r/internal/zet.lua index 28905b0..bcf4d04 100644 --- a/nvim/lua/odas0r/internal/zet.lua +++ b/nvim/lua/odas0r/internal/zet.lua @@ -5,20 +5,18 @@ local zet = {} local function exec(cmd, args) local result = nil - Job - :new({ - command = cmd, - args = args, - on_exit = function(j, code) - if code == 0 then - result = j:result()[1] - else - -- show Error message on red - print("Error: " .. j:stderr_result()[1]) - end - end, - }) - :sync() + Job:new({ + command = cmd, + args = args, + on_exit = function(j, code) + if code == 0 then + result = j:result()[1] + else + -- show Error message on red + print("Error: " .. j:stderr_result()[1]) + end + end, + }):sync() return result end @@ -26,16 +24,18 @@ zet.grep = function(query) if terminal ~= nil then terminal:close() end - require("telescope.builtin").live_grep(require("telescope.themes").get_dropdown({ - prompt_title = "Zet Query", - cwd = "$HOME/github.com/odas0r/zet", - preview_width = 0.6, - search_dirs = { - "fleet", - "permanent", - }, - default_text = query or "", - })) + require("telescope.builtin").live_grep( + require("telescope.themes").get_dropdown({ + prompt_title = "Zet Query", + cwd = "$HOME/github.com/odas0r/zet", + preview_width = 0.6, + search_dirs = { + "fleet", + "permanent", + }, + default_text = query or "", + }) + ) end zet.create = function(title) @@ -173,8 +173,16 @@ Utils.cmd("ZetNew", function(opts) end end, { nargs = "?", desc = "Create a new zet file" }) Utils.cmd("ZetHistory", zet.history, { nargs = 0, desc = "Show the history" }) -Utils.cmd("ZetLast", zet.open_last, { nargs = 0, desc = "Open the last zettel" }) -Utils.cmd("ZetBrokenLinks", zet.brokenlinks, { nargs = 0, desc = "Find broken links" }) +Utils.cmd( + "ZetLast", + zet.open_last, + { nargs = 0, desc = "Open the last zettel" } +) +Utils.cmd( + "ZetBrokenLinks", + zet.brokenlinks, + { nargs = 0, desc = "Find broken links" } +) Utils.cmd("ZetBacklog", zet.backlog, { nargs = 0, desc = "Show the backlog" }) Utils.cmd("ZetMakePermanent", function() local curr_path = vim.fn.expand("%:p") @@ -198,8 +206,8 @@ end, { nargs = 0, desc = "Make a zettel type fleet" }) Utils.autocmd({ "BufReadPost" }, { pattern = { - "/home/odas0r/github.com/odas0r/zet/permanent/*.md", - "/home/odas0r/github.com/odas0r/zet/fleet/*.md", + os.getenv("HOME") .. "/github.com/odas0r/zet/permanent/*.md", + os.getenv("HOME") .. "/github.com/odas0r/zet/fleet/*.md", }, callback = function() local curr_path_buf = vim.fn.expand("%:p") @@ -209,30 +217,28 @@ Utils.autocmd({ "BufReadPost" }, { return end - Job - :new({ - command = "zet", - args = { "save", curr_path_buf }, - on_exit = function(j, code) - if code == 0 then - local result = j:result()[1] - local zettel = vim.json.decode(result) - print("Saved: " .. zettel.title) - else - -- show Error message on red - P("Zet Error: ") - P(j:stderr_result()) - end - end, - }) - :start() + Job:new({ + command = "zet", + args = { "save", curr_path_buf }, + on_exit = function(j, code) + if code == 0 then + local result = j:result()[1] + local zettel = vim.json.decode(result) + print("Saved: " .. zettel.title) + else + -- show Error message on red + P("Zet Error: ") + P(j:stderr_result()) + end + end, + }):start() end, }) Utils.autocmd({ "BufWritePost" }, { pattern = { - "/home/odas0r/github.com/odas0r/zet/permanent/*.md", - "/home/odas0r/github.com/odas0r/zet/fleet/*.md", + os.getenv("HOME") .. "/github.com/odas0r/zet/permanent/*.md", + os.getenv("HOME") .. "/github.com/odas0r/zet/fleet/*.md", }, callback = function() local curr_path_buf = vim.fn.expand("%:p") @@ -265,24 +271,22 @@ Utils.autocmd({ "BufWritePost" }, { .. zettel.title .. "' && git push" - Job - :new({ - command = "bash", - args = { "-c", git_command }, - on_exit = function(j, code) - timer:stop() - if code == 0 then - print('Saved: "' .. zettel.title .. '"') - else - local git_error = table.concat(j:stderr_result(), " ") - if git_error == "" then - git_error = "Unknown Git Error" - end - P("Git Error: " .. git_error) + Job:new({ + command = "bash", + args = { "-c", git_command }, + on_exit = function(j, code) + timer:stop() + if code == 0 then + print('Saved: "' .. zettel.title .. '"') + else + local git_error = table.concat(j:stderr_result(), " ") + if git_error == "" then + git_error = "Unknown Git Error" end - end, - }) - :start() + P("Git Error: " .. git_error) + end + end, + }):start() else local zet_error = table.concat(j:stderr_result(), " ") if zet_error == "" then @@ -298,23 +302,21 @@ Utils.autocmd({ "BufWritePost" }, { Utils.autocmd({ "VimEnter", "VimLeave" }, { pattern = { - "/home/odas0r/github.com/odas0r/zet/permanent/*.md", - "/home/odas0r/github.com/odas0r/zet/fleet/*.md", + os.getenv("HOME") .. "/github.com/odas0r/zet/permanent/*.md", + os.getenv("HOME") .. "/github.com/odas0r/zet/fleet/*.md", }, callback = function() - Job - :new({ - command = "zet", - args = { "sync" }, - on_exit = function(j, code) - if code == 0 then - print("Synced successfully...") - else - print("Error: " .. j:stderr_result()[1]) - end - end, - }) - :start() + Job:new({ + command = "zet", + args = { "sync" }, + on_exit = function(j, code) + if code == 0 then + print("Synced successfully...") + else + print("Error: " .. j:stderr_result()[1]) + end + end, + }):start() end, }) @@ -376,8 +378,18 @@ function Input(opts) }) -- hide the line numbers - vim.api.nvim_set_option_value("winhighlight", "Normal:FloatBorder", { win = win }) - vim.cmd(string.format("autocmd WinLeave :lua vim.api.nvim_win_close(%s, true)", buf, win)) + vim.api.nvim_set_option_value( + "winhighlight", + "Normal:FloatBorder", + { win = win } + ) + vim.cmd( + string.format( + "autocmd WinLeave :lua vim.api.nvim_win_close(%s, true)", + buf, + win + ) + ) -- set prompt and make it "centered" by adding leading spaces vim.fn.prompt_setprompt(buf, " ") diff --git a/nvim/lua/odas0r/plugins/neovim-session-manager.lua b/nvim/lua/odas0r/plugins/neovim-session-manager.lua index e5e97ba..0b5c020 100644 --- a/nvim/lua/odas0r/plugins/neovim-session-manager.lua +++ b/nvim/lua/odas0r/plugins/neovim-session-manager.lua @@ -10,6 +10,7 @@ return { -- Define what to do when Neovim is started without arguments. See "Autoload mode" section below. autoload_mode = { + config.AutoloadMode.CurrentDir, config.AutoloadMode.GitSession, config.AutoloadMode.LastSession, }, diff --git a/nvim/lua/odas0r/plugins/nvim-lspconfig.lua b/nvim/lua/odas0r/plugins/nvim-lspconfig.lua index 8e0b87d..da24134 100644 --- a/nvim/lua/odas0r/plugins/nvim-lspconfig.lua +++ b/nvim/lua/odas0r/plugins/nvim-lspconfig.lua @@ -80,9 +80,7 @@ return { -- Mappings. Utils.map("n", "gD", "lua vim.lsp.buf.type_definition()", { buf = bufnr }) - Utils.map("n", "gi", "lua vim.lsp.buf.implementation()", { buf = bufnr }) Utils.map("n", "go", "lua vim.lsp.buf.document_symbol()", { buf = bufnr }) - Utils.map("n", "gu", organize_imports, { buf = bufnr }) Utils.map("n", "go", organize_imports, { buf = bufnr }) end, capabilities = capabilities, @@ -255,6 +253,12 @@ return { -- }, -- }) + require("lspconfig").marksman.setup({ + on_attach = on_attach, + capabilities = capabilities, + flags = flags, + }) + -- sudo apt-get install clangd-14 -- sudo update-alternatives --install /usr/bin/clangd clangd /usr/bin/clangd-14 100 require("lspconfig").clangd.setup({ @@ -332,6 +336,8 @@ return { -- }) -- + -- LSP for lua + -- https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#sumneko_lua local sumneko_binary_path = vim.fn.exepath("lua-language-server") local sumneko_root_path = vim.fn.fnamemodify(sumneko_binary_path, ":h:h:h") diff --git a/scripts/clipboard b/scripts/clipboard index 9ffb55c..0f1b3a6 100755 --- a/scripts/clipboard +++ b/scripts/clipboard @@ -2,4 +2,4 @@ set -euo pipefail -pbcopy +pbcopy "$*" diff --git a/scripts/radius b/scripts/radius index 029ba6f..bc18b26 100755 --- a/scripts/radius +++ b/scripts/radius @@ -7,12 +7,17 @@ if [[ $# -ne 2 ]]; then exit 1 fi -if ! [[ $1 =~ ^[0-9]+$ ]] || ! [[ $2 =~ ^[0-9]+$ ]]; then - echo "Error: Please provide valid numbers" +padding=$1 +inner_radius=$2 + +# Use bc for floating-point addition +# We echo the expression "padding + inner_radius" and pipe it to bc +border_radius=$(echo "$padding + $inner_radius" | bc) + +# Optional: Add a check in case bc fails or outputs nothing +if [[ -z "$border_radius" ]]; then + echo "Error: Calculation failed." >&2 # Print error to stderr exit 1 fi -padding=$1 -inner_radius=$2 -border_radius=$((padding + inner_radius)) echo "Outer Radius: border-radius: ${border_radius}px;" diff --git a/scripts/tunnel b/scripts/tunnel new file mode 100755 index 0000000..9a8cf04 --- /dev/null +++ b/scripts/tunnel @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +set -eo pipefail + +if [[ $# -eq 1 ]]; then + localhost="$1" +else + echo "usage: tunnel-random " + exit 1 +fi + +# start the tunnel using quic protoco a.k.a http/3 +cloudflared tunnel --protocol quic --url "$localhost" From 0e3e5e467904617c415f995860b5e9883bf64b13 Mon Sep 17 00:00:00 2001 From: odas0r Date: Wed, 2 Jul 2025 18:51:50 +0100 Subject: [PATCH 5/7] feat: added a lots of scripts --- bash/aliases.sh | 2 + git/gitconfig | 20 +---- git/gitconfig-github | 16 ++++ git/gitconfig-github-key | 8 ++ git/gitconfig-gitlab | 16 ++++ git/gitconfig-gitlab-key | 8 ++ git/gitconfig.key.example | 2 - git/setup | 10 ++- kitty/kitty.conf | 8 +- nvim/lua/odas0r/init.lua | 1 + nvim/lua/odas0r/snippets/bash.lua | 2 +- scripts/clamp | 102 +++++++++++++-------- scripts/scale | 144 ++++++++++++++++++++++-------- scripts/version | 143 +++++++++++++++++++++++++++++ scripts/zn | 2 +- 15 files changed, 389 insertions(+), 95 deletions(-) create mode 100644 git/gitconfig-github create mode 100644 git/gitconfig-github-key create mode 100644 git/gitconfig-gitlab create mode 100644 git/gitconfig-gitlab-key delete mode 100644 git/gitconfig.key.example create mode 100755 scripts/version diff --git a/bash/aliases.sh b/bash/aliases.sh index 42d708a..b5a9119 100644 --- a/bash/aliases.sh +++ b/bash/aliases.sh @@ -8,6 +8,8 @@ alias sb="source ~/.bashrc" alias luamake="$HOME/tools/lua-language-server/3rd/luamake/luamake" alias android-studio="$HOME/tools/android-studio/bin/studio.sh" +alias yarn="yarnpkg" + repos() { local paths=( "$HOME/github.com" diff --git a/git/gitconfig b/git/gitconfig index f2f058d..ce99bef 100644 --- a/git/gitconfig +++ b/git/gitconfig @@ -1,16 +1,4 @@ -[include] - path = ~/.gitconfig.key -[user] - name = odas0r - email = guilherme.odas0r@gmail.com -[push] - followTags = true - default = current -[core] - editor = nvim - autocrlf = false - sshCommand = ssh -[init] - defaultBranch = main -[pull] - rebase = false +[includeIf "gitdir:~/github.com/"] + path = ~/.gitconfig-github +[includeIf "gitdir:~/gitlab.com/"] + path = ~/.gitconfig-gitlab diff --git a/git/gitconfig-github b/git/gitconfig-github new file mode 100644 index 0000000..6d8d406 --- /dev/null +++ b/git/gitconfig-github @@ -0,0 +1,16 @@ +[include] + path = ~/.gitconfig-github-key +[user] + name = odas0r + email = guilherme.odas0r@gmail.com +[push] + followTags = true + default = current +[core] + editor = nvim + autocrlf = false + sshCommand = ssh +[init] + defaultBranch = main +[pull] + rebase = false diff --git a/git/gitconfig-github-key b/git/gitconfig-github-key new file mode 100644 index 0000000..0b2504d --- /dev/null +++ b/git/gitconfig-github-key @@ -0,0 +1,8 @@ +[user] + signingkey = +[gpg] + format = ssh +[gpg "ssh"] + program = "/Applications/1Password.app/Contents/MacOS/op-ssh-sign" +[commit] + gpgsign = true diff --git a/git/gitconfig-gitlab b/git/gitconfig-gitlab new file mode 100644 index 0000000..b907f87 --- /dev/null +++ b/git/gitconfig-gitlab @@ -0,0 +1,16 @@ +[include] + path = ~/.gitconfig-gitlab-key +[user] + name = Guilherme Rosado + email = guilherme.rosado@mypolis.eu +[push] + followTags = true + default = current +[core] + editor = nvim + autocrlf = false + sshCommand = ssh +[init] + defaultBranch = main +[pull] + rebase = false diff --git a/git/gitconfig-gitlab-key b/git/gitconfig-gitlab-key new file mode 100644 index 0000000..0b2504d --- /dev/null +++ b/git/gitconfig-gitlab-key @@ -0,0 +1,8 @@ +[user] + signingkey = +[gpg] + format = ssh +[gpg "ssh"] + program = "/Applications/1Password.app/Contents/MacOS/op-ssh-sign" +[commit] + gpgsign = true diff --git a/git/gitconfig.key.example b/git/gitconfig.key.example deleted file mode 100644 index 4d86da2..0000000 --- a/git/gitconfig.key.example +++ /dev/null @@ -1,2 +0,0 @@ -[user] - signingkey = YOUR_KEY diff --git a/git/setup b/git/setup index 8c0b0e7..3100c31 100755 --- a/git/setup +++ b/git/setup @@ -2,7 +2,16 @@ set -e +DOT="$HOME/github.com/odas0r/dot" + +mkdir -p $HOME/github.com +mkdir -p $HOME/gitlab.com + ln -sf "$DOT/git/gitconfig" "$HOME/.gitconfig" +ln -sf "$DOT/git/gitconfig-github" "$HOME/.gitconfig-github" +cp "$DOT/git/gitconfig-github-key" "$HOME/.gitconfig-github-key" +ln -sf "$DOT/git/gitconfig-gitlab" "$HOME/.gitconfig-gitlab" +cp "$DOT/git/gitconfig-gitlab-key" "$HOME/.gitconfig-gitlab-key" printf "Git setup done! 🌟\n" @@ -15,4 +24,3 @@ Add GPG key. Please generate one and add it to $SIGNKEY [user] signingkey = YOUR_KEY EOF - diff --git a/kitty/kitty.conf b/kitty/kitty.conf index 9520c03..83c51d7 100644 --- a/kitty/kitty.conf +++ b/kitty/kitty.conf @@ -20,9 +20,13 @@ modify_font cell_height 120% adjust_line_height 120% adjust_column_width 100% -font_size 14 +# Desktop: +# +# font_size 16.0 -# OS Specific +# Laptop: +# +font_size 14.0 macos_thicken_font 1.0 # diff --git a/nvim/lua/odas0r/init.lua b/nvim/lua/odas0r/init.lua index ea09412..ff8dd96 100644 --- a/nvim/lua/odas0r/init.lua +++ b/nvim/lua/odas0r/init.lua @@ -11,3 +11,4 @@ require("odas0r.internal.refactor") require("odas0r.internal.checkbox") require("odas0r.internal.zet") require("odas0r.internal.exec") + diff --git a/nvim/lua/odas0r/snippets/bash.lua b/nvim/lua/odas0r/snippets/bash.lua index 8a52ee3..d578647 100644 --- a/nvim/lua/odas0r/snippets/bash.lua +++ b/nvim/lua/odas0r/snippets/bash.lua @@ -22,7 +22,7 @@ local fmt = require("luasnip.extras.fmt").fmt return { s("#!", { - t("#!/bin/bash"), + t("#!/usr/bin/env bash"), i(0), }), s("safe", { diff --git a/scripts/clamp b/scripts/clamp index 9a9c9a4..36969f9 100755 --- a/scripts/clamp +++ b/scripts/clamp @@ -1,55 +1,83 @@ -#!/usr/bin/env bash +#!/usr/bin/env node -set -euo pipefail - -show_help() { - cat < parseFloat(num.toFixed(4)); -MIN_SIZE_REM=$(px_to_rem $MIN_SIZE) -MAX_SIZE_REM=$(px_to_rem $MAX_SIZE) + const pxToRem = (px) => px / rootSize; -# Calculate slope: (max - min) / (maxWidth - minWidth) -SLOPE=$(echo "scale=4; ($MAX_SIZE - $MIN_SIZE) / ($MAX_WIDTH - $MIN_WIDTH)" | bc) + const minSizeRem = round(pxToRem(minSize)); + const maxSizeRem = round(pxToRem(maxSize)); -# Calculate preferred size: min - slope * minWidth -PREFERRED=$(echo "scale=4; $MIN_SIZE - ($SLOPE * $MIN_WIDTH)" | bc) + // Calculate the slope of the line (the fluid part of the clamp) + // (maxSize - minSize) / (maxWidth - minWidth) + const slope = (maxSize - minSize) / (maxWidth - minWidth); -SLOPE=$(echo "scale=4; $SLOPE * 100" | bc) -PREFERRED=$(echo "scale=4; $PREFERRED/16" | bc) + // Calculate the y-intercept (the 'preferred' value) + // This is where the line would cross the y-axis (at 0 viewport width) + // y = mx + b => b = y - mx + // Using min values: intercept = minSize - slope * minWidth + const yInterceptPx = minSize - slope * minWidth; + const yInterceptRem = round(pxToRem(yInterceptPx)); + + // The slope is multiplied by 100 to convert it to a 'vw' unit + const slopeVw = round(slope * 100); + + const clampValue = `clamp(${minSizeRem}rem, ${yInterceptRem}rem + ${slopeVw}vw, ${maxSizeRem}rem)`; + + console.log(clampValue); +} -echo "clamp(${MIN_SIZE_REM}rem, ${PREFERRED}rem + ${SLOPE}vw, ${MAX_SIZE_REM}rem)" +main(); diff --git a/scripts/scale b/scripts/scale index 0ac160a..a0ef14d 100755 --- a/scripts/scale +++ b/scripts/scale @@ -1,42 +1,116 @@ -#!/usr/bin/env bash +#!/usr/bin/env node -set -euo pipefail +/** + * Generates the CSS for the typographic scale. + * @param {object} options - The configuration for the scale. + * @param {number} options.baseSize - The base font size in pixels. + * @param {number} options.scale - The multiplier for the scale. + * @param {number} options.stepsDown - The number of smaller sizes to generate. + * @param {number} options.stepsUp - The number of larger sizes to generate. + * @returns {string} The formatted CSS string. + */ +function generateTypographyScale(options) { + const { baseSize, scale, stepsDown, stepsUp } = options; -# Default values -BASE_SIZE=${1:-16} -SCALE=${2:-1.2} -STEPS_DOWN=${3:-3} -STEPS_UP=${4:-7} + const results = []; + const downNames = ["sm", "xs", "2xs", "3xs", "4xs"]; // Names for steps below base -pow() { - echo "scale=6; $1^$2" | bc + // 1. Calculate sizes below base + for (let i = 1; i <= stepsDown; i++) { + const size = baseSize / Math.pow(scale, i); + // Use pre-defined names, or fall back to a generic name if stepsDown > length of downNames + const name = downNames[i - 1] || `${i + 1}s`; + results.push({ + name, + px: size, + percentage: (size / baseSize) * 100, + }); + } + // Reverse to have smallest sizes first in the array for processing + results.reverse(); + + // 2. Add the base size + results.push({ + name: "base", + px: baseSize, + percentage: 100, + }); + + // 3. Calculate sizes above base + for (let i = 1; i <= stepsUp; i++) { + const size = baseSize * Math.pow(scale, i); + let name; + // Use specific names for the first few steps up + switch (i) { + case 1: + name = "lg"; + break; + case 2: + name = "xl"; + break; + default: + name = `${i}x`; + break; + } + results.push({ + name, + px: size, + percentage: (size / baseSize) * 100, + }); + } + + // 4. Format the final CSS string + const cssLines = results.map((res) => { + // Round percentage to the nearest whole number + const percentageVal = Math.round(res.percentage); + // Format pixel value to 6 decimal places to match original script's precision + const pxVal = res.px.toFixed(6); + return ` --text-${res.name}: ${percentageVal}%; /* ${pxVal}px */`; + }); + + // Add a blank line for readability after the base size + const baseIndex = results.findIndex((res) => res.name === "base"); + if (baseIndex !== -1 && baseIndex < cssLines.length - 1) { + cssLines.splice(baseIndex + 1, 0, ""); + } + + // Assemble the final output + let output = `:root {\n`; + output += ` --scale: ${scale};\n`; + output += ` --base-size: 100%; /* ${baseSize}px */\n\n`; + output += cssLines.join("\n"); + output += `\n}\n`; + + return output; } -calc_percentage() { - echo "scale=2; $1 * 100" | bc +/** + * Main execution block + */ +function main() { + const baseSizeArg = process.argv[2]; + const scaleArg = process.argv[3]; + const stepsDownArg = process.argv[4]; + const stepsUpArg = process.argv[5]; + + const baseSize = baseSizeArg ? parseFloat(baseSizeArg) : 16; + const scale = scaleArg ? parseFloat(scaleArg) : 1.125; + const stepsDown = stepsDownArg ? parseInt(stepsDownArg, 10) : 2; + const stepsUp = stepsUpArg ? parseInt(stepsUpArg, 10) : 12; + + // Validate that parsing was successful and arguments are numbers + if (isNaN(baseSize) || isNaN(scale) || isNaN(stepsDown) || isNaN(stepsUp)) { + console.error("Error: Invalid arguments. All arguments must be numbers."); + console.error( + "Usage: scale [baseSize] [scale] [stepsDown] [stepsUp]", + ); + process.exit(1); + } + + const options = { baseSize, scale, stepsDown, stepsUp }; + const cssOutput = generateTypographyScale(options); + process.stdout.write(cssOutput); } -# Output CSS header -echo ":root {" -echo " --scale: $SCALE;" -echo " --base-size: 100%;" -echo - -# Calculate sizes below base -for ((i = STEPS_DOWN; i > 0; i--)); do - size=$(echo "scale=6; $BASE_SIZE / $(pow $SCALE $i)" | bc) - percentage=$(calc_percentage "$size"/$BASE_SIZE) - echo " --font-size-${i}down: ${percentage}%; /* ${size}px */" -done - -# Base size -echo " --font-size-base: 100%; /* ${BASE_SIZE}px */" - -# Calculate sizes above base -for ((i = 1; i <= STEPS_UP; i++)); do - size=$(echo "scale=6; $BASE_SIZE * $(pow $SCALE $i)" | bc) - percentage=$(calc_percentage "$size"/$BASE_SIZE) - echo " --font-size-${i}: ${percentage}%; /* ${size}px */" -done - -echo "}" +// Run the script +main(); diff --git a/scripts/version b/scripts/version new file mode 100755 index 0000000..d67b3c0 --- /dev/null +++ b/scripts/version @@ -0,0 +1,143 @@ +#!/usr/bin/env bash + +set -e + +PREID="rc" + +# handles the --preid flag and finds the main command. +BUMP_TYPE="" +for arg in "$@"; do + case $arg in + --preid=*) + PREID="${arg#*=}" + shift # remove --preid=... from the list of arguments + ;; + *) + # Assume the first non-flag argument is the bump type + if [ -z "$BUMP_TYPE" ]; then + BUMP_TYPE=$arg + fi + ;; + esac +done + +# --- Usage Message --- +usage() { + echo "Usage: version [--preid=]" + echo " Bumps the version in package.json and creates a git commit and tag." + echo "" + echo "Commands:" + echo " major, minor, patch Bump the respective version part." + echo " prerelease, rc Start or increment a prerelease (e.g., 1.2.3-rc.0)." + echo " Set a specific version string (e.g., v1.2.3)." + echo "" + echo "Options:" + echo " --preid= Specify the identifier for prereleases (default: 'rc')." + echo "" + echo "Examples:" + echo " version minor" + echo " version prerelease" + echo " version prerelease --preid=beta" +} + +# --- Check for dependencies --- +if ! command -v jq &>/dev/null; then + echo "Error: jq is not installed. Please install it to continue." + exit 1 +fi + +# --- Check for clean git working directory --- +if ! git diff-index --quiet HEAD --; then + echo "Error: Uncommitted changes detected. Please commit or stash them first." + exit 1 +fi + +# --- Input Validation --- +if [[ -z "$BUMP_TYPE" ]]; then + usage + exit 1 +fi + +# --- Main Logic --- + +current_version=$(jq -r '.version' package.json) +current_version_v="v${current_version//v/}" + +# Check for specific version set +if [[ "$BUMP_TYPE" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.+)?[0-9]*$ || "$BUMP_TYPE" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-.+)?[0-9]*$ ]]; then + new_version_v="v${BUMP_TYPE//v/}" +else + # --- Advanced Version Parsing --- + # Separate core version from prerelease suffix (e.g., "1.2.3" and "rc.0") + current_version_clean="${current_version//v/}" + IFS='-' read -r core_version prerelease_part <<<"$current_version_clean" + + # Parse the core version numbers + IFS='.' read -r major minor patch <<<"$core_version" + + # --- Bumping Logic --- + case $BUMP_TYPE in + major) + major=$((major + 1)) + minor=0 + patch=0 + new_version_v="v$major.$minor.$patch" + ;; + minor) + minor=$((minor + 1)) + patch=0 + new_version_v="v$major.$minor.$patch" + ;; + patch) + # If graduating from a prerelease, the version stays the same. + # Otherwise, increment the patch number. + if [ -z "$prerelease_part" ]; then + patch=$((patch + 1)) + fi + new_version_v="v$major.$minor.$patch" + ;; + prerelease | rc) + if [ -z "$prerelease_part" ]; then + # STARTING a prerelease series from a stable version + # Bumps patch version first, e.g., 1.2.0 -> 1.2.1-rc.0 + patch=$((patch + 1)) + new_version_v="v$major.$minor.$patch-$PREID.0" + else + # INCREMENTING an existing prerelease series + IFS='.' read -r current_preid current_prenum <<<"$prerelease_part" + + if [ "$current_preid" != "$PREID" ]; then + # If the preid is different (e.g. from 'alpha' to 'rc'), start at 0 + new_version_v="v$major.$minor.$patch-$PREID.0" + else + # If the preid is the same, just increment the number + current_prenum=$((current_prenum + 1)) + new_version_v="v$major.$minor.$patch-$current_preid.$current_prenum" + fi + fi + ;; + *) + echo "Error: Invalid argument '$BUMP_TYPE'" + usage + exit 1 + ;; + esac +fi + +# Remove the 'v' for the package.json version string +new_version="${new_version_v//v/}" + +echo "Bumping version from $current_version to $new_version" + +# Update package.json using jq and a temporary file for safety +jq ".version = \"$new_version\"" package.json >package.json.tmp && mv package.json.tmp package.json + +echo "Updated package.json to version $new_version" + +# --- Git Actions --- +git add package.json +git commit -m "chore(release): ${new_version_v}" +git tag -a "${new_version_v}" -m "Release ${new_version_v}" + +echo "Successfully created commit and tag ${new_version_v}" +echo "Run 'git push && git push --tags' to publish." diff --git a/scripts/zn b/scripts/zn index 91843f4..fd6ce42 100755 --- a/scripts/zn +++ b/scripts/zn @@ -2,4 +2,4 @@ set -euo pipefail -nvr "$(zet new "$@")" +nvim "$(zet new "$@")" From 6bfd58c998ecd19cae46683a2b45e66c856af26c Mon Sep 17 00:00:00 2001 From: odas0r Date: Thu, 24 Jul 2025 11:55:25 +0100 Subject: [PATCH 6/7] refactor: simplify `version` --- scripts/version | 54 ++++++++++++------------------------------------- 1 file changed, 13 insertions(+), 41 deletions(-) diff --git a/scripts/version b/scripts/version index d67b3c0..4b5c29e 100755 --- a/scripts/version +++ b/scripts/version @@ -24,7 +24,8 @@ done # --- Usage Message --- usage() { echo "Usage: version [--preid=]" - echo " Bumps the version in package.json and creates a git commit and tag." + echo " Bumps the version by creating a git tag." + echo " If package.json is present, it's also updated and committed." echo "" echo "Commands:" echo " major, minor, patch Bump the respective version part." @@ -33,19 +34,8 @@ usage() { echo "" echo "Options:" echo " --preid= Specify the identifier for prereleases (default: 'rc')." - echo "" - echo "Examples:" - echo " version minor" - echo " version prerelease" - echo " version prerelease --preid=beta" } -# --- Check for dependencies --- -if ! command -v jq &>/dev/null; then - echo "Error: jq is not installed. Please install it to continue." - exit 1 -fi - # --- Check for clean git working directory --- if ! git diff-index --quiet HEAD --; then echo "Error: Uncommitted changes detected. Please commit or stash them first." @@ -60,19 +50,18 @@ fi # --- Main Logic --- -current_version=$(jq -r '.version' package.json) -current_version_v="v${current_version//v/}" - # Check for specific version set if [[ "$BUMP_TYPE" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.+)?[0-9]*$ || "$BUMP_TYPE" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-.+)?[0-9]*$ ]]; then new_version_v="v${BUMP_TYPE//v/}" else + # Source the current version from the latest git tag. + # Fallback to v0.0.0 if no tags are found. + current_version=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") + echo "Current version (from git tag): $current_version" + # --- Advanced Version Parsing --- - # Separate core version from prerelease suffix (e.g., "1.2.3" and "rc.0") current_version_clean="${current_version//v/}" IFS='-' read -r core_version prerelease_part <<<"$current_version_clean" - - # Parse the core version numbers IFS='.' read -r major minor patch <<<"$core_version" # --- Bumping Logic --- @@ -89,28 +78,18 @@ else new_version_v="v$major.$minor.$patch" ;; patch) - # If graduating from a prerelease, the version stays the same. - # Otherwise, increment the patch number. - if [ -z "$prerelease_part" ]; then - patch=$((patch + 1)) - fi + if [ -z "$prerelease_part" ]; then patch=$((patch + 1)); fi new_version_v="v$major.$minor.$patch" ;; prerelease | rc) if [ -z "$prerelease_part" ]; then - # STARTING a prerelease series from a stable version - # Bumps patch version first, e.g., 1.2.0 -> 1.2.1-rc.0 patch=$((patch + 1)) new_version_v="v$major.$minor.$patch-$PREID.0" else - # INCREMENTING an existing prerelease series IFS='.' read -r current_preid current_prenum <<<"$prerelease_part" - if [ "$current_preid" != "$PREID" ]; then - # If the preid is different (e.g. from 'alpha' to 'rc'), start at 0 new_version_v="v$major.$minor.$patch-$PREID.0" else - # If the preid is the same, just increment the number current_prenum=$((current_prenum + 1)) new_version_v="v$major.$minor.$patch-$current_preid.$current_prenum" fi @@ -124,20 +103,13 @@ else esac fi -# Remove the 'v' for the package.json version string +# Remove the 'v' for the version string if exists new_version="${new_version_v//v/}" -echo "Bumping version from $current_version to $new_version" - -# Update package.json using jq and a temporary file for safety -jq ".version = \"$new_version\"" package.json >package.json.tmp && mv package.json.tmp package.json - -echo "Updated package.json to version $new_version" +echo "New version: $new_version_v" -# --- Git Actions --- -git add package.json -git commit -m "chore(release): ${new_version_v}" +# Otherwise, just create the tag on the current commit git tag -a "${new_version_v}" -m "Release ${new_version_v}" -echo "Successfully created commit and tag ${new_version_v}" -echo "Run 'git push && git push --tags' to publish." +echo "✅ Successfully created tag ${new_version_v}" +echo "Run 'git push --tags' to publish the new tag." From 9ba387047642694a48d9833bc558d60f34768773 Mon Sep 17 00:00:00 2001 From: odas0r Date: Tue, 9 Sep 2025 19:03:29 +0100 Subject: [PATCH 7/7] feat: better ps1, copilot.lua, scripts... --- bash/ps1.sh | 53 ++++++++- nvim/lua/odas0r/plugins/copilot.lua | 65 ++++++----- nvim/lua/odas0r/plugins/nvim-lspconfig.lua | 121 ++++++++++++++++++--- nvim/lua/odas0r/snippets/bash.lua | 51 +++++++-- nvim/lua/odas0r/snippets/sh.lua | 2 +- nvim/lua/odas0r/snippets/typescript.lua | 44 ++++++++ scripts/format | 3 +- scripts/pgfmt | 41 ++++++- scripts/route53-list-records | 17 +++ 9 files changed, 335 insertions(+), 62 deletions(-) create mode 100644 nvim/lua/odas0r/snippets/typescript.lua create mode 100755 scripts/route53-list-records diff --git a/bash/ps1.sh b/bash/ps1.sh index 1a51027..aa37250 100644 --- a/bash/ps1.sh +++ b/bash/ps1.sh @@ -1,22 +1,63 @@ #!/usr/bin/env bash declare magenta="\e[1;35m" +declare yellow="\e[1;33m" declare cyan="\e[1;36m" +declare green="\e[1;32m" +declare red="\e[1;31m" declare reset="\e[0m" parse_git_branch() { - if ! git rev-parse HEAD -- >/dev/null 2>&1; then - git branch 2>/dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/[\1 ⚡] /' - else - git branch 2>/dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/[\1] /' + # 1. Exit immediately if not a git repository. + if ! git rev-parse --is-inside-work-tree &>/dev/null; then + return fi + + # 2. Check for uncommitted changes ("dirty" state). + local color=$magenta + if ! git diff --quiet --ignore-submodules HEAD &>/dev/null; then + color=$yellow + fi + + # 3. Get the current branch name or commit hash for detached HEAD. + local branch=$(git branch --show-current 2>/dev/null) + if [[ -z "$branch" ]]; then + # In detached HEAD state, show the short commit hash. + branch="($(git rev-parse --short HEAD))" + fi + + # 4. Print the final, formatted output. + echo -e "${color}[${branch}]${reset}" } +parse_docker_context() { + local DANGEROUS_CONTEXTS=("muxit" "mypolis") + local context=$(docker context show 2>/dev/null) + + if [[ -n "$context" ]]; then + local is_dangerous=false + for dangerous_ctx in "${DANGEROUS_CONTEXTS[@]}"; do + if [[ "$context" == "$dangerous_ctx" ]]; then + is_dangerous=true + break + fi + done + + if [[ "$is_dangerous" == true ]]; then + echo -e "${red}[🐳${context}]${reset}" # Red for dangerous contexts + else + echo -e "${green}[🐳${context}]${reset}" # Green for safe contexts + fi + fi +} + +# --- Prompt Assembly --- + ret=$? PS1=$(if [[ ${ret} = 0 ]]; then echo "🚀 "; else echo "🔥 "; fi) -# PS1="=> " PS1+="$cyan/\W$reset" -PS1+=" $magenta\$(parse_git_branch)$reset" +PS1+=" \$(parse_git_branch)" +PS1+=" \$(parse_docker_context) " # <-- This is the new line PS1+="$ " PS2="Keep typing...> " diff --git a/nvim/lua/odas0r/plugins/copilot.lua b/nvim/lua/odas0r/plugins/copilot.lua index 33fbcb5..5359bac 100644 --- a/nvim/lua/odas0r/plugins/copilot.lua +++ b/nvim/lua/odas0r/plugins/copilot.lua @@ -1,32 +1,37 @@ return { - "zbirenbaum/copilot.lua", - event = "InsertEnter", - config = function() - require("copilot").setup({ - suggestion = { - enabled = true, - auto_trigger = true, - hide_during_completion = true, - debounce = 50, - keymap = { - accept = "", - accept_word = false, - accept_line = false, - next = "j", - prev = "k", - dismiss = "", - }, - }, - filetypes = { - ["*"] = true, - sh = function() - -- disable for .env files - if string.match(vim.fs.basename(vim.api.nvim_buf_get_name(0)), "^%.env.*") then - return false - end - return true - end, - }, - }) - end, + "zbirenbaum/copilot.lua", + event = "InsertEnter", + config = function() + require("copilot").setup({ + suggestion = { + enabled = true, + auto_trigger = true, + hide_during_completion = true, + debounce = 50, + keymap = { + accept = "", + accept_word = false, + accept_line = false, + next = "j", + prev = "k", + dismiss = "", + }, + }, + filetypes = { + ["*"] = true, + sh = function() + -- disable for .env files + if + string.match( + vim.fs.basename(vim.api.nvim_buf_get_name(0)), + "^%.env.*" + ) + then + return false + end + return true + end, + }, + }) + end, } diff --git a/nvim/lua/odas0r/plugins/nvim-lspconfig.lua b/nvim/lua/odas0r/plugins/nvim-lspconfig.lua index da24134..eea0bc6 100644 --- a/nvim/lua/odas0r/plugins/nvim-lspconfig.lua +++ b/nvim/lua/odas0r/plugins/nvim-lspconfig.lua @@ -9,19 +9,54 @@ return { Utils.set_option("omnifunc", "v:lua.vim.lsp.omnifunc", { buf = bufnr }) -- Common mappings for all language servers - Utils.map("n", "gd", vim.lsp.buf.definition, { buffer = bufnr, desc = "Go to definition" }) - Utils.map("n", "gD", vim.lsp.buf.declaration, { buffer = bufnr, desc = "Go to declaration" }) - Utils.map("n", "gi", vim.lsp.buf.implementation, { buffer = bufnr, desc = "Go to implementation" }) - Utils.map("n", "gh", vim.lsp.buf.hover, { buffer = bufnr, desc = "Show hover information" }) - Utils.map("n", "gk", vim.lsp.buf.references, { buffer = bufnr, desc = "Show references" }) + Utils.map( + "n", + "gd", + vim.lsp.buf.definition, + { buffer = bufnr, desc = "Go to definition" } + ) + Utils.map( + "n", + "gD", + vim.lsp.buf.declaration, + { buffer = bufnr, desc = "Go to declaration" } + ) + Utils.map( + "n", + "gi", + vim.lsp.buf.implementation, + { buffer = bufnr, desc = "Go to implementation" } + ) + Utils.map( + "n", + "gh", + vim.lsp.buf.hover, + { buffer = bufnr, desc = "Show hover information" } + ) + Utils.map( + "n", + "gk", + vim.lsp.buf.references, + { buffer = bufnr, desc = "Show references" } + ) Utils.map("n", "K", function() vim.diagnostic.jump({ count = -1, float = true }) end, { buffer = bufnr, desc = "Previous diagnostic" }) Utils.map("n", "J", function() vim.diagnostic.jump({ count = 1, float = true }) end, { buffer = bufnr, desc = "Next diagnostic" }) - Utils.map("n", "gr", vim.lsp.buf.rename, { buffer = bufnr, desc = "Rename symbol" }) - Utils.map("n", "ga", vim.lsp.buf.code_action, { buffer = bufnr, desc = "Code action" }) + Utils.map( + "n", + "gr", + vim.lsp.buf.rename, + { buffer = bufnr, desc = "Rename symbol" } + ) + Utils.map( + "n", + "ga", + vim.lsp.buf.code_action, + { buffer = bufnr, desc = "Code action" } + ) end local util = require("lspconfig").util @@ -79,8 +114,18 @@ return { end -- Mappings. - Utils.map("n", "gD", "lua vim.lsp.buf.type_definition()", { buf = bufnr }) - Utils.map("n", "go", "lua vim.lsp.buf.document_symbol()", { buf = bufnr }) + Utils.map( + "n", + "gD", + "lua vim.lsp.buf.type_definition()", + { buf = bufnr } + ) + Utils.map( + "n", + "go", + "lua vim.lsp.buf.document_symbol()", + { buf = bufnr } + ) Utils.map("n", "go", organize_imports, { buf = bufnr }) end, capabilities = capabilities, @@ -108,9 +153,24 @@ return { end -- Mappings. - Utils.map("n", "gD", "lua vim.lsp.buf.type_definition()", { buf = bufnr }) - Utils.map("n", "gi", "lua vim.lsp.buf.implementation()", { buf = bufnr }) - Utils.map("n", "go", "lua vim.lsp.buf.document_symbol()", { buf = bufnr }) + Utils.map( + "n", + "gD", + "lua vim.lsp.buf.type_definition()", + { buf = bufnr } + ) + Utils.map( + "n", + "gi", + "lua vim.lsp.buf.implementation()", + { buf = bufnr } + ) + Utils.map( + "n", + "go", + "lua vim.lsp.buf.document_symbol()", + { buf = bufnr } + ) Utils.map("n", "gu", organize_imports, { buf = bufnr }) Utils.map("n", "go", organize_imports, { buf = bufnr }) end, @@ -217,7 +277,14 @@ return { require("lspconfig").tailwindcss.setup({ on_attach = on_attach, capabilities = capabilities, - filetypes = { "templ", "astro", "html", "css", "javascript", "typescript" }, + filetypes = { + "templ", + "astro", + "html", + "css", + "javascript", + "typescript", + }, init_options = { userLanguages = { templ = "html" } }, }) @@ -349,7 +416,11 @@ return { on_attach = on_attach, capabilities = capabilities, flags = flags, - cmd = { sumneko_binary_path, "-E", sumneko_root_path .. "/lua-language-server/main.lua" }, + cmd = { + sumneko_binary_path, + "-E", + sumneko_root_path .. "/lua-language-server/main.lua", + }, settings = { Lua = { runtime = { @@ -381,5 +452,27 @@ return { }, }, }) + + -- Fix for bug https://github.com/neovim/neovim/issues/12970 + vim.lsp.util.apply_text_document_edit = function( + text_document_edit, + index, + offset_encoding + ) + local text_document = text_document_edit.textDocument + local buf = vim.uri_to_bufnr(text_document.uri) + if offset_encoding == nil then + vim.notify_once( + "apply_text_document_edit must be called with valid offset encoding", + vim.log.levels.WARN + ) + end + + vim.lsp.util.apply_text_edits( + text_document_edit.edits, + buf, + offset_encoding + ) + end end, } diff --git a/nvim/lua/odas0r/snippets/bash.lua b/nvim/lua/odas0r/snippets/bash.lua index d578647..ade5f8f 100644 --- a/nvim/lua/odas0r/snippets/bash.lua +++ b/nvim/lua/odas0r/snippets/bash.lua @@ -19,10 +19,9 @@ local fmt = require("luasnip.extras.fmt").fmt -- local types = require("luasnip.util.types") -- local conds = require("luasnip.extras.conditions") -- local conds_expand = require("luasnip.extras.conditions.expand") - return { s("#!", { - t("#!/usr/bin/env bash"), + t("#!/bin/bash"), i(0), }), s("safe", { @@ -31,15 +30,53 @@ return { }), s( "cmd", + fmt( + [[if ! command -v {1}; then + {2} +fi]], + { + i(1, "nvim"), + i(2, 'echo "Command not found"'), + } + ) + ), + s( + "taskfile", fmt( [[ - if ! command -v {}; then - {} - fi +#!/bin/bash +PATH=./node_modules/.bin:$PATH + +function {1} {{ + {2} +}} + +function build {{ + {3} +}} + +function test {{ + {4} +}} + +function default {{ + {1} +}} + +function help {{ + echo "$0 " + echo "Tasks:" + compgen -A function | cat -n +}} + +TIMEFORMAT="Task completed in %3lR" +time "${{@:-default}}" ]], { - i(1, "nvim"), - i(0), + i(1, "dev"), + i(2, 'echo "not implemented"'), + i(3, 'echo "not implemented"'), + i(4, 'echo "not implemented"'), } ) ), diff --git a/nvim/lua/odas0r/snippets/sh.lua b/nvim/lua/odas0r/snippets/sh.lua index ade5f8f..f9ddd01 100644 --- a/nvim/lua/odas0r/snippets/sh.lua +++ b/nvim/lua/odas0r/snippets/sh.lua @@ -21,7 +21,7 @@ local fmt = require("luasnip.extras.fmt").fmt -- local conds_expand = require("luasnip.extras.conditions.expand") return { s("#!", { - t("#!/bin/bash"), + t("#!/bin/sh"), i(0), }), s("safe", { diff --git a/nvim/lua/odas0r/snippets/typescript.lua b/nvim/lua/odas0r/snippets/typescript.lua new file mode 100644 index 0000000..9b9cfc1 --- /dev/null +++ b/nvim/lua/odas0r/snippets/typescript.lua @@ -0,0 +1,44 @@ +local ls = require("luasnip") +-- shorthands +local s = ls.snippet +-- local sn = ls.snippet_node +local t = ls.text_node +local i = ls.insert_node +-- local f = ls.function_node +-- local c = ls.choice_node +-- local d = ls.dynamic_node +-- local r = ls.restore_node +-- local l = require("luasnip.extras").lambda +-- local rep = require("luasnip.extras").rep +-- local p = require("luasnip.extras").partial +-- local m = require("luasnip.extras").match +-- local n = require("luasnip.extras").nonempty +-- local dl = require("luasnip.extras").dynamic_lambda +local fmt = require("luasnip.extras.fmt").fmt +-- local fmta = require("luasnip.extras.fmt").fmta +-- local types = require("luasnip.util.types") +-- local conds = require("luasnip.extras.conditions") +-- local conds_expand = require("luasnip.extras.conditions.expand") + +return { + -- Add your snippets here + -- Example: + -- s("trigger", { + -- t("expansion"), + -- i(0), + -- }), + s("test", { + t({ + 'import test from "node:test";', + 'import assert from "node:assert";', + "", + "", + }), + t('test("'), + i(1, "should do something"), + t({ '", () => {', "\t" }), + i(2, "assert.strictEqual(actual, expected);"), + t({ "", "});" }), + i(0), + }), +} diff --git a/scripts/format b/scripts/format index c85f2f8..a514500 100755 --- a/scripts/format +++ b/scripts/format @@ -2,4 +2,5 @@ set -euo pipefail -fmt -w 80 -p "${1:-}" +# fmt -w 80 -p "${1:-}" +par -r -w80 diff --git a/scripts/pgfmt b/scripts/pgfmt index 30d50b0..650d871 100755 --- a/scripts/pgfmt +++ b/scripts/pgfmt @@ -1,12 +1,47 @@ #!/usr/bin/env bash +# Check if pg_format is installed if [[ ! -x "$(command -v pg_format)" ]]; then - echo "You need to install pg_format" + echo "Error: pg_format is not installed or not in PATH" + echo "Install it via: cpan install pgFormatter" exit 1 fi +# Run pg_format with idiomatic PostgreSQL formatting options LANG=C pg_format \ --tabs \ - --spaces 2 \ + --spaces 4 \ --keyword-case 2 \ - --no-extra-line + --function-case 1 \ + --type-case 2 \ + --no-extra-line \ + --wrap-limit 120 \ + --wrap-after 1 \ + --comma-end \ + --comma-break \ + --format-type \ + --no-space-function \ + --placeholder "^(\\$\\d+|\\?)$" \ + "$@" + +# Option explanations: +# --tabs: Use tabs for indentation +# --spaces 2: Use 2 spaces for alignment (not indentation) +# --keyword-case 2: Keywords in uppercase (SELECT, FROM, WHERE) +# --function-case 1: Functions in lowercase (count(), sum()) +# --type-case 2: Data types in uppercase (VARCHAR, INTEGER) +# --no-extra-line: No extra blank lines +# --wrap-limit 80: Wrap lines at 80 characters +# --wrap-after 1: Wrap after first element in lists +# --comma-end: Place commas at end of line (SQL standard) +# --comma-break: Break after commas in lists +# --format-type: Format data type definitions +# --no-space-function: No space between function name and parentheses +# --placeholder: Regex for placeholder recognition ($1, $2, ?) +# "$@": Pass through any additional arguments + +# Note: Use either --tabs OR --spaces for indentation, not both +# If you prefer spaces for indentation, use: +# --spaces 2 (without --tabs) +# If you prefer tabs for indentation, use: +# --tabs --spaces 2 (spaces for alignment only) diff --git a/scripts/route53-list-records b/scripts/route53-list-records new file mode 100755 index 0000000..29ca3ae --- /dev/null +++ b/scripts/route53-list-records @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +set -euo pipefail + +ZONE_ID="$1" +if [[ -z "$ZONE_ID" ]]; then + echo "Usage: $0 [aws-profile]" + exit 1 +fi + +PROFILE="${2:-}" +if [[ -z "$PROFILE" ]]; then + echo "Usage: $0 [aws-profile]" + exit 1 +fi + +aws route53 list-resource-record-sets --hosted-zone-id "$ZONE_ID" --profile "$PROFILE" --output json