Last active
August 30, 2024 14:18
-
-
Save alexlovelltroy/70af48b195bec4f9c7d0faaa9dd217b3 to your computer and use it in GitHub Desktop.
Portable dotfiles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# .bashrc | |
# curl -sSL https://gist.github.com/alexlovelltroy/70af48b195bec4f9c7d0faaa9dd217b3/raw -o ~/.bashrc | |
# If not running interactively, don't do anything | |
case $- in | |
*i*) ;; | |
*) return;; | |
esac | |
# Source global definitions | |
if [ -f /etc/bashrc ]; then | |
. /etc/bashrc | |
fi | |
# Function to add directories to PATH if they exist and are not already in PATH | |
add_to_path_if_exists() { | |
for dir in "$@"; do | |
if [ -d "$dir" ] && [[ ":$PATH:" != *":$dir:"* ]]; then | |
export PATH="$dir:$PATH" | |
fi | |
done | |
} | |
# User specific environment | |
if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]] | |
then | |
PATH="$HOME/.local/bin:$HOME/bin:$PATH" | |
fi | |
export PATH | |
# add go path | |
add_to_path_if_exists /usr/local/go/bin | |
add_to_path_if_exists "${GOPATH}/bin:${PATH}" | |
# add local things to path | |
add_to_path_if_exists /usr/local/bin | |
add_to_path_if_exists /usr/local/sbin | |
# User specific aliases and functions | |
if [ -d ~/.bashrc.d ]; then | |
for rc in ~/.bashrc.d/*; do | |
if [ -f "$rc" ]; then | |
. "$rc" | |
fi | |
done | |
fi | |
unset rc | |
# Set some basic helpful options | |
# don't put duplicate lines or lines starting with space in the history. | |
# See bash(1) for more options | |
HISTCONTROL=ignoreboth | |
# append to the history file, don't overwrite it | |
shopt -s histappend | |
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) | |
HISTSIZE=1000 | |
HISTFILESIZE=2000 | |
# Update the window size after each command | |
shopt -s checkwinsize | |
# Case-insensitive globbing (used in pathname expansion) | |
shopt -s nocaseglob | |
# Append to the Bash history file, rather than overwriting it | |
shopt -s histappend | |
# Autocorrect typos in path names when using `cd` | |
shopt -s cdspell | |
# If this is an xterm set the title to user@host:dir | |
case "$TERM" in | |
xterm*|rxvt*) | |
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" | |
;; | |
*) | |
;; | |
esac | |
# enable color support of ls and also add handy aliases | |
if [ -x /usr/bin/dircolors ]; then | |
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" | |
alias ls='ls --color=auto' | |
alias dir='dir --color=auto' | |
alias vdir='vdir --color=auto' | |
alias grep='grep --color=auto' | |
alias fgrep='fgrep --color=auto' | |
alias egrep='egrep --color=auto' | |
fi | |
# enable programmable completion features (you don't need to enable | |
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile | |
# sources /etc/bash.bashrc). | |
if ! shopt -oq posix; then | |
if [ -f /usr/share/bash-completion/bash_completion ]; then | |
. /usr/share/bash-completion/bash_completion | |
elif [ -f /etc/bash_completion ]; then | |
. /etc/bash_completion | |
fi | |
fi | |
install_starship() { | |
curl -sS https://starship.rs/install.sh | sh | |
mkdir -p ~/.config && touch ~/.config/starship.toml | |
starship preset bracketed-segments -o ~/.config/starship.toml | |
} | |
install_ssh_keys() { | |
mkdir -p ~/.ssh | |
chmod 700 ~/.ssh | |
curl -fSsL https://github.com/alexlovelltroy.keys >> ~/.ssh/authorized_keys | |
} | |
install_zellij() { | |
bash <(curl -L zellij.dev/launch) | |
sudo cp /tmp/zellij/bootstrap/zellij /usr/local/bin/zellij | |
} | |
bootstrap_debian() { | |
sudo apt install git vim sudo curl wget jq debian-keyring debian-archive-keyring apt-transport-https telnet | |
curl -fsSL https://tailscale.com/install.sh | sh | |
} | |
install_kubectl() { | |
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" | |
sudo mv kubectl /usr/local/bin/kubectl | |
sudo chmod +x /usr/local/bin/kubectl | |
} | |
install_tailscale() { | |
curl -fsSL https://tailscale.com/install.sh | sh | |
} | |
setup_venv() { | |
# Define the virtual environment directory | |
VENV_DIR=".venv" | |
# Check if .venv directory exists | |
if [ ! -d "$VENV_DIR" ]; then | |
echo "Creating virtual environment in $VENV_DIR..." | |
python3 -m venv "$VENV_DIR" | |
else | |
echo "Virtual environment already exists in $VENV_DIR." | |
fi | |
# Activate the virtual environment | |
source "$VENV_DIR/bin/activate" | |
# Install dependencies from requirements.txt | |
if [ -f "requirements.txt" ]; then | |
echo "Installing dependencies from requirements.txt..." | |
pip install -r requirements.txt | |
else | |
echo "requirements.txt not found. No dependencies to install." | |
fi | |
} | |
# This is the prompt. It should be last | |
eval "$(starship init bash)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment