xonecas.io
56101
Df

dotfiles / commit 01f356d

feat(shell): add shared shell install

Sean2026-01-29 01f356d392c262de7f5a27c4d9e11e12801fc94e parent 7ccc3e6

2 files changed

shell/install.sh+27−0
@@ -0,0 +1,27 @@
1+#!/usr/bin/env bash
2+# Link shared shell config and source it from existing shell rc files.
3+set -euo pipefail
4+
5+repo_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6+config_dir="${XDG_CONFIG_HOME:-$HOME/.config}/shell"
7+shared_target="$config_dir/shared.sh"
8+
9+mkdir -p "$config_dir"
10+
11+if [ ! -e "$shared_target" ] && [ ! -L "$shared_target" ]; then
12+ ln -s "$repo_dir/shared.sh" "$shared_target"
13+fi
14+
15+# Use POSIX-compatible '.' instead of 'source'; bash/zsh are not strictly POSIX by default.
16+source_line='[ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/shared.sh" ] && . "${XDG_CONFIG_HOME:-$HOME/.config}/shell/shared.sh"'
17+
18+for rc_file in "$HOME/.zshrc" "$HOME/.bashrc"; do
19+ if [ -f "$rc_file" ]; then
20+ if ! grep -q "shell/shared.sh" "$rc_file"; then
21+ printf '\n# Load shared shell config\n%s\n' "$source_line" >> "$rc_file"
22+ fi
23+ fi
24+done
25+
26+echo "Installed shared shell config to $shared_target"
27+echo "Note: install dependencies (fortune, cowsay, lolcat) if you haven't yet."
shell/shared.sh+30−0
@@ -0,0 +1,30 @@
1+# These are the shared shell configurations, used by zsh on mac and bash on linux.
2+# to install these please include them at the bottom of your shell's config (zshrc or bashrc)
3+
4+# Convenience alias:
5+export EDITOR=nvim
6+
7+alias ll='ls -Fal --color=always'
8+alias ls='ls --color=always'
9+
10+alias g='git'
11+alias gst='git status'
12+alias gc='git commit --verbose'
13+alias gp='git pull origin'
14+alias gpo='git push origin'
15+
16+alias rg='rg --color always'
17+alias les='less -r'
18+
19+# Greetings!
20+function greet() {
21+ local cows=(
22+ "default" "flaming-sheep" "fox" "llama" "sheep" "skeleton" "three-eyes" "tux" "udder" "www"
23+ )
24+ local cow=${cows[$RANDOM % ${#cows[@]}]:-"default"}
25+ fortune -s | cowsay -f $cow -W 80 | lolcat -p 1.0 -F 0.06 -S $(echo $RANDOM)
26+ # echo "\n cow: $cow" | lolcat -p 1.0 -F 0.06 -S $(echo $RANDOM) # Show the cow used
27+}
28+
29+# Run the greeting function
30+greet