aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/.bashrc61
-rw-r--r--linux/home/.bashrc93
2 files changed, 41 insertions, 113 deletions
diff --git a/common/.bashrc b/common/.bashrc
index dd0aee5..fbc86fe 100644
--- a/common/.bashrc
+++ b/common/.bashrc
@@ -50,7 +50,7 @@ alias wallset='feh --bg-fill'
if [[ -d "$HOME/.cfg" && -d "$HOME/.cfg/refs" ]]; then
# Core git wrapper with repository as work-tree
_config() {
- git --git-dir="$HOME/.cfg" --work-tree="$HOME" "$@"
+ git --git-dir="$HOME/.cfg" --work-tree="$HOME/.cfg" "$@"
}
# Detect OS
@@ -165,7 +165,7 @@ if [[ -d "$HOME/.cfg" && -d "$HOME/.cfg/refs" ]]; then
# Main config command
config() {
local cmd="$1"; shift
-
+ local target_dir=""
# Parse optional --target flag for add
if [[ "$cmd" == "add" ]]; then
while [[ "$1" == --* ]]; do
@@ -188,13 +188,10 @@ if [[ -d "$HOME/.cfg" && -d "$HOME/.cfg/refs" ]]; then
for file_path in "$@"; do
local repo_path
if [[ -n "$target_dir" ]]; then
- # Keep relative path inside target_dir
local rel_path
if [[ "$file_path" == /* ]]; then
- # Absolute path → just take the filename
rel_path="$(basename "$file_path")"
else
- # Relative path → preserve nested dirs
rel_path="$file_path"
fi
repo_path="$target_dir/$rel_path"
@@ -204,11 +201,8 @@ if [[ -d "$HOME/.cfg" && -d "$HOME/.cfg/refs" ]]; then
local full_repo_path="$HOME/.cfg/$repo_path"
mkdir -p "$(dirname "$full_repo_path")"
-
- # Copy the file safely
cp -a "$file_path" "$full_repo_path"
- # Add to git safely
git --git-dir="$HOME/.cfg" --work-tree="$HOME/.cfg" add "$repo_path"
echo "Added: $file_path -> $repo_path"
@@ -288,20 +282,47 @@ if [[ -d "$HOME/.cfg" && -d "$HOME/.cfg/refs" ]]; then
;;
deploy)
_config ls-files | while read -r repo_file; do
- local sys_file="$(_sys_path "$repo_file")"
local full_repo_path="$HOME/.cfg/$repo_file"
- if [[ -e "$full_repo_path" ]]; then
- if [[ -n "$sys_file" ]]; then
- local dest_dir="$(dirname "$sys_file")"
- if [[ "$sys_file" == /* && "$sys_file" != "$HOME/"* ]]; then
- _sudo_prompt mkdir -p "$dest_dir"
- _sudo_prompt cp -a "$full_repo_path" "$sys_file"
- else
- mkdir -p "$dest_dir"
- cp -a "$full_repo_path" "$sys_file"
- fi
- echo "Deployed: $repo_file -> $sys_file"
+ local sys_file="$(_sys_path "$repo_file")" # destination only
+
+ # Only continue if the source exists
+ if [[ -e "$full_repo_path" && -n "$sys_file" ]]; then
+ local dest_dir
+ dest_dir="$(dirname "$sys_file")"
+
+ # Create destination if needed
+ if [[ "$sys_file" == /* && "$sys_file" != "$HOME/"* ]]; then
+ _sudo_prompt mkdir -p "$dest_dir"
+ _sudo_prompt cp -a "$full_repo_path" "$sys_file"
+ else
+ mkdir -p "$dest_dir"
+ cp -a "$full_repo_path" "$sys_file"
fi
+
+ echo "Deployed: $repo_file -> $sys_file"
+ fi
+ done
+ ;;
+ checkout)
+ echo "Checking out dotfiles from .cfg..."
+ _config ls-files | while read -r repo_file; do
+ local full_repo_path="$HOME/.cfg/$repo_file"
+ local sys_file="$(_sys_path "$repo_file")"
+
+ if [[ -e "$full_repo_path" && -n "$sys_file" ]]; then
+ local dest_dir
+ dest_dir="$(dirname "$sys_file")"
+
+ # Create destination if it doesn't exist
+ if [[ "$sys_file" == /* && "$sys_file" != "$HOME/"* ]]; then
+ _sudo_prompt mkdir -p "$dest_dir"
+ _sudo_prompt cp -a "$full_repo_path" "$sys_file"
+ else
+ mkdir -p "$dest_dir"
+ cp -a "$full_repo_path" "$sys_file"
+ fi
+
+ echo "Checked out: $repo_file -> $sys_file"
fi
done
;;
diff --git a/linux/home/.bashrc b/linux/home/.bashrc
deleted file mode 100644
index 6cefd9d..0000000
--- a/linux/home/.bashrc
+++ /dev/null
@@ -1,93 +0,0 @@
-# shellcheck shell=bash
-#
-#██████╗ █████╗ ███████╗██╗ ██╗██████╗ ██████╗
-#██╔══██╗██╔══██╗██╔════╝██║ ██║██╔══██╗██╔════╝
-#██████╔╝███████║███████╗███████║██████╔╝██║
-#██╔══██╗██╔══██║╚════██║██╔══██║██╔══██╗██║
-#██████╔╝██║ ██║███████║██║ ██║██║ ██║╚██████╗
-#╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝
-#
-# ~/.bashrc
-#
-
-if [[ $- != *i* ]]; then
- . ~/.profile
- return
-fi
-
-# Get the current active terminal
-term="$(cat /proc/"$PPID"/comm)"
-
-# Set a default prompt
-p='\[\033[01;37m\]┌─[\[\033[01;32m\]srdusr\[\033[01;37m\]]-[\[\033[01;36m\]archlinux\[\033[01;37m\]]-[\[\033[01;33m\]\W\]\[\033[00;37m\]\[\033
-\[\033[01;37m\]└─[\[\033[05;33m\]$\[\033[00;37m\]\[\033[01;37m\]]\[\033[00;37m\] '
-
-# Set transparency and prompt while using st
-if [[ $term = "st" ]]; then
- transset-df "0.65" --id "$WINDOWID" >/dev/null
-
- # [Your_Name]-----| |=======|------[Your_Distro]
- # [Color]--------| | [Color]------| |
- # [Style]------------| | | [Style]---------| | |
- # V V V V V V
- p='\[\033[01;37m\]┌─[\[\033[01;32m\]srdusr\[\033[01;37m\]]-[\[\033[01;36m\]archlinux\[\033[01;37m\]]-[\[\033[01;33m\]\W\[\033[00;37m\]\[\033[01;37m\]]
-\[\033[01;37m\]└─[\[\033[05;33m\]$\[\033[00;37m\]\[\033[01;37m\]]\[\033[00;37m\] '
-# A A A
-# [Style]----| | |-------- [Your_Choice]
-# [Color]------------|
-
-fi
-
-# If not running interactively, dont do anything
-[[ $- != *i* ]] && return
-
-# My alias commands
-alias ls='ls --color=auto -1'
-alias shred='shred -uzvn3'
-alias wallset='feh --bg-fill'
-
-# normal bare repo alias
-alias _config='git --git-dir=$HOME/.cfg --work-tree=$HOME'
-
-config() {
- if [ "$1" = "add" ]; then
- shift
- for f in "$@"; do
- case "$(uname -s)" in
- Linux)
- _config add -- "linux/home/$f"
- ;;
- Darwin)
- _config add -- "macos/home/$f"
- ;;
- MINGW*|MSYS*|CYGWIN*)
- _config add -- "windows/Documents/$f"
- ;;
- *)
- _config add -- "$f"
- ;;
- esac
- done
- else
- _config "$@"
- fi
-}
-
-PS1=$p
-
-bind -m vi-command 'Control-l: clear-screen'
-bind -m vi-insert 'Control-l: clear-screen'
-
-export EDITOR="nvim"
-# pfetch
-
-#export NVM_DIR="$HOME/.local/share/nvm"
-#[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
-#[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
-
-export PROMPT_COMMAND="resize &>/dev/null ; $PROMPT_COMMAND"
-
-export RUSTUP_HOME=${XDG_DATA_HOME:-$HOME/.local/share}/rustup
-export CARGO_HOME=${XDG_DATA_HOME:-$HOME/.local/share}/cargo
-export PATH="${CARGO_HOME}/bin:${RUSTUP_HOME}/bin:$PATH"
-if which rustc >/dev/null; then export RUST_BACKTRACE=1; fi