From 49dd72c1700cc22bac17fb29d6b8d58e69b476ae Mon Sep 17 00:00:00 2001 From: Tomas Mirchev Date: Wed, 11 Feb 2026 07:32:06 +0200 Subject: [PATCH] update --- config/shared/addpaths | 79 ++++++++++++++++++++++++++---------------- config/shared/nvim | 2 +- config/shared/tmux | 6 ++++ config/shared/zsh | 27 ++++++++++++++- 4 files changed, 83 insertions(+), 31 deletions(-) diff --git a/config/shared/addpaths b/config/shared/addpaths index 30f26bd..f9325a5 100755 --- a/config/shared/addpaths +++ b/config/shared/addpaths @@ -3,7 +3,7 @@ set -euo pipefail usage() { - echo "Usage: $0 -c COMMENT_SYMBOL [-e EXCLUDE_PATTERN]... TARGET" + echo "Usage: $(basename "$0") -c COMMENT_SYMBOL [-e EXCLUDE_PATTERN]... TARGET" echo " -c Comment symbol (e.g., '#' or '//')" echo " -e Exclude pattern (can be specified multiple times)" echo " TARGET File or directory to process" @@ -29,21 +29,10 @@ shift $((OPTIND - 1)) target="$(realpath "$1")" base_dir="$(pwd)" -should_exclude() { - local path="$1" - for pattern in "${excludes[@]}"; do - if [[ "$path" == *"$pattern"* ]]; then - return 0 - fi - done - return 1 -} - process_file() { local file="$1" - local rel_path="${file#"$base_dir"/}" - - should_exclude "$rel_path" && return + # shellcheck disable=SC2295 + local rel_path="${file#$base_dir/}" local path_comment="$comment_sym path: $rel_path" @@ -52,22 +41,37 @@ process_file() { IFS= read -r line1 <"$file" 2>/dev/null || line1="" IFS= read -r line2 < <(tail -n +2 "$file") 2>/dev/null || line2="" - # Check if path comment exists in first or second line - [[ "$line1" == *"path: "* ]] && return - [[ "$line2" == *"path: "* ]] && return - - # Insert after shebang if present, otherwise at top + # Handle shebang case if [[ "$line1" =~ ^#! ]]; then - { - echo "$line1" - echo "$path_comment" - tail -n +2 "$file" - } >"$file.tmp" + if [[ "$line2" == *"path: "* ]]; then + # Replace existing path comment on line 2 + { + echo "$line1" + echo "$path_comment" + tail -n +3 "$file" + } >"$file.tmp" + else + # Insert new path comment after shebang + { + echo "$line1" + echo "$path_comment" + tail -n +2 "$file" + } >"$file.tmp" + fi else - { - echo "$path_comment" - cat "$file" - } >"$file.tmp" + if [[ "$line1" == *"path: "* ]]; then + # Replace existing path comment on line 1 + { + echo "$path_comment" + tail -n +2 "$file" + } >"$file.tmp" + else + # Insert new path comment at top + { + echo "$path_comment" + cat "$file" + } >"$file.tmp" + fi fi mv "$file.tmp" "$file" @@ -76,9 +80,26 @@ process_file() { if [[ -f "$target" ]]; then process_file "$target" elif [[ -d "$target" ]]; then + find_cmd=(find "$target") + + # Always exclude hidden files and directories + find_cmd+=(\( -name ".*" -prune \)) + + if [[ ${#excludes[@]} -gt 0 ]]; then + find_cmd+=(-o \() + for i in "${!excludes[@]}"; do + [[ $i -gt 0 ]] && find_cmd+=(-o) + find_cmd+=(-path "*/${excludes[$i]}" -prune) + find_cmd+=(-o -path "*/${excludes[$i]}/*" -prune) + done + find_cmd+=(\)) + fi + + find_cmd+=(-o -type f -print0) + while IFS= read -r -d '' file; do process_file "$file" - done < <(find "$target" -type f -print0) + done < <("${find_cmd[@]}") else echo "Error: $target is not a file or directory" >&2 exit 1 diff --git a/config/shared/nvim b/config/shared/nvim index b84e46b..2c8524d 160000 --- a/config/shared/nvim +++ b/config/shared/nvim @@ -1 +1 @@ -Subproject commit b84e46bda1d9671b7b0589e42c522a6a5cd02397 +Subproject commit 2c8524df9db4d5cd31aa36c72e1015254ef55e8b diff --git a/config/shared/tmux b/config/shared/tmux index 7baf5a2..f57e76a 100644 --- a/config/shared/tmux +++ b/config/shared/tmux @@ -44,6 +44,12 @@ bind -r j select-pane -D bind -r k select-pane -U bind -r l select-pane -R +# Resize Opt/Alt-hjkl +bind -n M-h resize-pane -L 5 +bind -n M-j resize-pane -D 5 +bind -n M-k resize-pane -U 5 +bind -n M-l resize-pane -R 5 + # Last window instead of session bind ';' last-window diff --git a/config/shared/zsh b/config/shared/zsh index bfb4639..0b975fd 100644 --- a/config/shared/zsh +++ b/config/shared/zsh @@ -25,7 +25,26 @@ git_prompt_info() { echo " %F{green}($branch)%f" fi } -PROMPT='%n@%m%f %F{blue}%~%f$(git_prompt_info) $ ' +abbrev_path() { + local pwd="${PWD/#$HOME/~}" + local parts=("${(@s:/:)pwd}") + local len=${#parts} + + if (( len <= 1 )); then + echo "$pwd" + return + fi + + local result="" + for (( i=1; i