first commit

This commit is contained in:
Dan Milne
2025-03-11 15:36:25 +11:00
commit eb9b51fe52
4 changed files with 135 additions and 0 deletions

13
README.md Normal file
View File

@@ -0,0 +1,13 @@
# Dotfiles
## Installation
### Curl2Bash
```bash
curl -fsSL https://git.booko.info/Booko/server-dotfiles/raw/branch/main/install.sh | bash
```
### Manually
```bash
mkdir -p .config
git clone https://git.booko.info/Booko/server-dotfiles.git .config/dotfiles
```

38
bashrc Normal file
View File

@@ -0,0 +1,38 @@
# Function to parse git branch
function parse_git_branch {
git branch 2>/dev/null | grep '^*' | colrm 1 2
}
# Function to parse git status
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working tree clean" ]] && echo "✗"
}
# Custom prompt with proper Unicode escapes and hexadecimal notation
PS1=$'\[\e[38;5;10m\]\u\[\e[m\] \[\e[38;5;14m\]\w\[\e[m\] \[\e[38;5;9m\]\uE0B0\[\e[m\] \[\e[38;5;11m\]$(parse_git_branch)$(parse_git_dirty)\[\e[m\] \[\e[38;5;15m\]\uF013\[\e[m\] '
function _update_ps1() {
#PS1="$(/opt/homebrew/bin/powerline-go -hostname-only-if-ssh -cwd-mode fancy -modules direnv,dotenv,rbenv -error $? -jobs $(jobs -p | wc -l))"
PS1="$(/opt/homebrew/bin/powerline-go -hostname-only-if-ssh -cwd-mode fancy -modules="venv,user,host,ssh,cwd,perms,git,hg,jobs,exit,rbenv,root" -error $? -cwd-max-depth 2 -jobs $(jobs -p | wc -l))"
# Uncomment the following line to automatically clear errors after showing
# them once. This not only clears the error for powerline-go, but also for
# everything else you run in that shell. Don't enable this if you're not
# sure this is what you want.
set "?"
}
if [ "$TERM" != "linux" ] && [ -f "/opt/homebrew/bin/powerline-go" ]; then
PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
fi
set -o vi
export RUBY_YJIT_ENABLE=1
HISTSIZE=50000
HISTFILESIZE=100000
shopt -s histappend
eval "$(direnv hook bash)"

1
inputrc Normal file
View File

@@ -0,0 +1 @@
set editing-mode vi

83
install.sh Normal file
View File

@@ -0,0 +1,83 @@
#!/bin/bash
# 16.5mm
# Define paths
DOTFILES_DIR="$HOME/.config/dotfiles"
DOTFILES_REPO="https://git.tbdb.info/Booko/server-dotfiles.git" # Replace with your actual repo URL
BASHRC="$HOME/.bashrc"
BASH_PROFILE="$HOME/.bash_profile"
# Install Git if not present
if ! command -v git &> /dev/null; then
echo "Git not found. Installing Git..."
if command -v apt &> /dev/null; then
sudo apt update
sudo apt install -y git
elif command -v dnf &> /dev/null; then
sudo dnf install -y git
elif command -v yum &> /dev/null; then
sudo yum install -y git
elif command -v pacman &> /dev/null; then
sudo pacman -Sy git
else
echo "Error: Unsupported package manager. Please install Git manually."
exit 1
fi
elif command -v git &> /dev/null; then
echo "Git is already installed."
else
echo "Error: Cannot install Git on unknown operating system."
exit 1
fi
# Clone the repository if it doesn't exist
if [ ! -d "$DOTFILES_DIR" ]; then
echo "Cloning dotfiles repository to $DOTFILES_DIR..."
git clone "$DOTFILES_REPO" "$DOTFILES_DIR"
else
echo "Dotfiles directory already exists at $DOTFILES_DIR"
echo "Pulling latest changes..."
cd "$DOTFILES_DIR" && git pull
fi
# Add sourcing code to .bashrc if not already present
if ! grep -q "DOTFILES_DIR.*config/dotfiles" "$BASHRC"; then
cat << 'EOF' >> "$BASHRC"
# Load dotfiles configuration
DOTFILES_DIR="$HOME/.config/dotfiles"
# Load base configuration
if [ -f "$DOTFILES_DIR/bashrc" ]; then
source "$DOTFILES_DIR/bashrc"
fi
EOF
echo "Updated $BASHRC to load dotfiles configurations"
else
echo "$BASHRC already configured to load dotfiles"
fi
# Ensure .bash_profile sources .bashrc (for login shells)
if [ -f "$BASH_PROFILE" ]; then
if ! grep -q "source.*bashrc" "$BASH_PROFILE"; then
echo -e "\n# Source .bashrc for login shells\nif [ -f \"$BASHRC\" ]; then\n source \"$BASHRC\"\nfi" >> "$BASH_PROFILE"
echo "Updated $BASH_PROFILE to source $BASHRC"
else
echo "$BASH_PROFILE already sources $BASHRC"
fi
else
echo "# Source .bashrc for login shells" > "$BASH_PROFILE"
echo "if [ -f \"$BASHRC\" ]; then" >> "$BASH_PROFILE"
echo " source \"$BASHRC\"" >> "$BASH_PROFILE"
echo "fi" >> "$BASH_PROFILE"
echo "Created $BASH_PROFILE to source $BASHRC"
fi
# Install additional software
install_additional_software
echo "Dotfiles installation complete!"
echo "Your configurations will be loaded from:"
echo "- Base: $DOTFILES_DIR/base/bashrc"