Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 540b18e6e8 | |||
| 49300923f7 | |||
| 5008a3384a | |||
| 74e779ff54 |
85
config/shared/addpaths
Executable file
85
config/shared/addpaths
Executable file
@@ -0,0 +1,85 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
echo "Usage: $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"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
comment_sym=""
|
||||||
|
excludes=()
|
||||||
|
|
||||||
|
while getopts "c:e:h" opt; do
|
||||||
|
case $opt in
|
||||||
|
c) comment_sym="$OPTARG" ;;
|
||||||
|
e) excludes+=("$OPTARG") ;;
|
||||||
|
h) usage ;;
|
||||||
|
*) usage ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
shift $((OPTIND - 1))
|
||||||
|
[[ $# -ne 1 ]] && usage
|
||||||
|
[[ -z "$comment_sym" ]] && usage
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
local path_comment="$comment_sym path: $rel_path"
|
||||||
|
|
||||||
|
# Read first two lines
|
||||||
|
local line1 line2
|
||||||
|
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
|
||||||
|
if [[ "$line1" =~ ^#! ]]; then
|
||||||
|
{
|
||||||
|
echo "$line1"
|
||||||
|
echo "$path_comment"
|
||||||
|
tail -n +2 "$file"
|
||||||
|
} >"$file.tmp"
|
||||||
|
else
|
||||||
|
{
|
||||||
|
echo "$path_comment"
|
||||||
|
cat "$file"
|
||||||
|
} >"$file.tmp"
|
||||||
|
fi
|
||||||
|
|
||||||
|
mv "$file.tmp" "$file"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ -f "$target" ]]; then
|
||||||
|
process_file "$target"
|
||||||
|
elif [[ -d "$target" ]]; then
|
||||||
|
while IFS= read -r -d '' file; do
|
||||||
|
process_file "$file"
|
||||||
|
done < <(find "$target" -type f -print0)
|
||||||
|
else
|
||||||
|
echo "Error: $target is not a file or directory" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
/home/tomas/bin/dev "$@" 2>&1
|
/home/tomas/bin/flow "$@" 2>&1
|
||||||
exit_code=$?
|
exit_code=$?
|
||||||
|
|
||||||
if [ $exit_code -ne 0 ]; then
|
if [ $exit_code -ne 0 ]; then
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ DEFAULT_REGISTRY="registry.tomastm.com"
|
|||||||
DEFAULT_TAG="latest"
|
DEFAULT_TAG="latest"
|
||||||
PROJECT_DIR="$HOME/projects"
|
PROJECT_DIR="$HOME/projects"
|
||||||
PROJECT_ABBR="p"
|
PROJECT_ABBR="p"
|
||||||
|
CONTAINER_HOME="/home/dev"
|
||||||
|
|
||||||
fail() {
|
fail() {
|
||||||
printf 'Error: %b\n' "$*" >&2
|
printf 'Error: %b\n' "$*" >&2
|
||||||
|
|||||||
@@ -14,6 +14,11 @@
|
|||||||
[remote]
|
[remote]
|
||||||
pushDefault = origin
|
pushDefault = origin
|
||||||
[alias]
|
[alias]
|
||||||
amend = commit -a --amend --no-edit
|
amend = commit --amend --no-edit
|
||||||
rename = branch -m
|
rename = branch -m
|
||||||
|
st = status
|
||||||
|
unstage = reset HEAD
|
||||||
|
last = log -1 HEAD
|
||||||
|
tags = tag -l
|
||||||
|
undo = reset --mixed HEAD~1
|
||||||
|
|
||||||
|
|||||||
Submodule config/shared/nvim updated: 4419f2e5f3...b84e46bda1
@@ -44,6 +44,9 @@ bind -r j select-pane -D
|
|||||||
bind -r k select-pane -U
|
bind -r k select-pane -U
|
||||||
bind -r l select-pane -R
|
bind -r l select-pane -R
|
||||||
|
|
||||||
|
# Last window instead of session
|
||||||
|
bind ';' last-window
|
||||||
|
|
||||||
unbind '"'
|
unbind '"'
|
||||||
unbind "%"
|
unbind "%"
|
||||||
unbind s
|
unbind s
|
||||||
@@ -63,6 +66,6 @@ bind r source-file ~/.tmux.conf \; display "Reloaded!"
|
|||||||
unbind d
|
unbind d
|
||||||
bind e detach
|
bind e detach
|
||||||
|
|
||||||
bind d command-prompt -I "dev " 'run-shell "/home/tomas/bin/dev-tmux-wrapper.sh %1 --from #{session_name}"'
|
bind d command-prompt -I "flow " 'run-shell "/home/tomas/bin/dev-tmux-wrapper.sh %1 --from #{session_name}"'
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -49,3 +49,9 @@ alias ll='ls -lF'
|
|||||||
alias lla='ll -a'
|
alias lla='ll -a'
|
||||||
alias ld='ls -ld */'
|
alias ld='ls -ld */'
|
||||||
|
|
||||||
|
alias ga='git add'
|
||||||
|
alias gcm='git commit -m'
|
||||||
|
alias gp='git push'
|
||||||
|
alias gst='git status'
|
||||||
|
alias gd='git diff --patience --color-moved=dimmed-zebra --word-diff=plain --function-context --ignore-space-change -U3'
|
||||||
|
alias glg='git log --oneline --graph --decorate --all'
|
||||||
|
|||||||
@@ -12,6 +12,12 @@
|
|||||||
"to": "~/.local/bin/barg"
|
"to": "~/.local/bin/barg"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"addpaths": {
|
||||||
|
"link": {
|
||||||
|
"from": "shared/addpaths",
|
||||||
|
"to": "~/.local/bin/addpaths"
|
||||||
|
}
|
||||||
|
},
|
||||||
"htop": {
|
"htop": {
|
||||||
"link": {
|
"link": {
|
||||||
"from": "shared/htop",
|
"from": "shared/htop",
|
||||||
@@ -131,6 +137,7 @@
|
|||||||
"linux-vm": [
|
"linux-vm": [
|
||||||
"bin",
|
"bin",
|
||||||
"barg",
|
"barg",
|
||||||
|
"addpaths",
|
||||||
"gitignore",
|
"gitignore",
|
||||||
{
|
{
|
||||||
"package": "htop",
|
"package": "htop",
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ fi
|
|||||||
|
|
||||||
NEW_HOSTNAME="$1"
|
NEW_HOSTNAME="$1"
|
||||||
|
|
||||||
|
if ! sudo -v; then
|
||||||
|
echo "Sudo access required. Exiting."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
mkdir ~/projects
|
mkdir ~/projects
|
||||||
# /bin/bash ./scripts/linux-setup_sudoers.sh
|
# /bin/bash ./scripts/linux-setup_sudoers.sh
|
||||||
|
|||||||
Reference in New Issue
Block a user