Skip to content

Commit e43ecbc

Browse files
Claude/update readme content dn jab (#8)
Co-authored-by: Claude <noreply@anthropic.com>
1 parent 4855605 commit e43ecbc

17 files changed

Lines changed: 927 additions & 0 deletions

README.adoc

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,97 @@ core/
279279
| Visual customisations: colours, themes, terminal-specific settings
280280
|===
281281

282+
== Examples
283+
284+
The `examples/` directory contains ready-to-use configuration snippets:
285+
286+
[source,bash]
287+
----
288+
# Copy all examples to your modshells directory
289+
cp -r examples/* ~/.config/nushell/modshells/
290+
291+
# Or copy individual files
292+
cp examples/tools/git.sh ~/.config/nushell/modshells/tools/
293+
cp examples/misc/aliases.sh ~/.config/nushell/modshells/misc/
294+
----
295+
296+
=== Available Examples
297+
298+
[cols="1,2"]
299+
|===
300+
| File | Description
301+
302+
| `core/00-path.sh`
303+
| PATH modifications for ~/.local/bin, Cargo, Go, Deno
304+
305+
| `core/10-history.sh`
306+
| History size, deduplication, timestamps, ignore patterns
307+
308+
| `core/20-options.sh`
309+
| Shell options (extglob, cdspell, globstar), editor, locale
310+
311+
| `tools/git.sh`
312+
| Git aliases (gs, ga, gc, gp, gl, glog, etc.)
313+
314+
| `tools/fzf.sh`
315+
| Fuzzy finder setup with fd integration
316+
317+
| `tools/starship.sh`
318+
| Starship prompt initialisation
319+
320+
| `misc/aliases.sh`
321+
| Navigation (.., ...), ls variants, safety nets (rm -i)
322+
323+
| `misc/functions.sh`
324+
| Utility functions: mkcd, extract, ff, fd, backup
325+
326+
| `os/linux.sh`
327+
| Package manager aliases, systemd shortcuts
328+
329+
| `os/macos.sh`
330+
| Homebrew setup, macOS-specific utilities
331+
332+
| `ui/colours.sh`
333+
| Terminal colours, GCC colours, man page colours
334+
335+
| `ui/prompt.sh`
336+
| Custom bash prompt with git branch (fallback for non-starship)
337+
|===
338+
339+
== Testing
340+
341+
=== Smoke Test
342+
343+
Run the shell-based smoke test to verify the build:
344+
345+
[source,bash]
346+
----
347+
# From the repository root
348+
./tests/smoke_test.sh
349+
----
350+
351+
The smoke test verifies:
352+
353+
* Source files exist
354+
* Examples have correct structure
355+
* SPDX license headers present
356+
* Binary runs (if built)
357+
* Directory creation works
358+
* Idempotency check passes
359+
360+
=== Unit Tests
361+
362+
Build and run the Ada unit tests:
363+
364+
[source,bash]
365+
----
366+
# Build tests
367+
gprbuild -p -j0 -P tests/tests.gpr
368+
369+
# Run tests
370+
./bin/test_shell_manager
371+
----
372+
282373
== Development Status
283374

284375
Current version: **v0.1**

examples/README.adoc

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
= Modshells Example Configurations
2+
:toc:
3+
4+
Example shell configuration snippets for use with Modshells.
5+
6+
== Usage
7+
8+
Copy the snippets you want into your modshells directory:
9+
10+
[source,bash]
11+
----
12+
# Copy all examples
13+
cp -r examples/* ~/.config/nushell/modshells/
14+
15+
# Or copy individual files
16+
cp examples/tools/git.sh ~/.config/nushell/modshells/tools/
17+
----
18+
19+
== Directory Structure
20+
21+
[cols="1,3"]
22+
|===
23+
| Directory | Purpose
24+
25+
| `core/`
26+
| Essential settings loaded first (PATH, history, shell options)
27+
28+
| `tools/`
29+
| Tool-specific configurations (git, fzf, starship)
30+
31+
| `misc/`
32+
| General aliases and utility functions
33+
34+
| `os/`
35+
| Operating system specific settings (Linux, macOS)
36+
37+
| `ui/`
38+
| Visual customisations (colours, prompt)
39+
|===
40+
41+
== File Naming
42+
43+
Files are sourced alphabetically. Use numeric prefixes to control load order:
44+
45+
* `00-*.sh` - Load first (PATH, critical settings)
46+
* `10-*.sh` - Load early (history, options)
47+
* `20-*.sh` - Load later (depends on earlier settings)
48+
* No prefix - Load in alphabetical order
49+
50+
== Customisation
51+
52+
These examples are starting points. Modify them to suit your workflow:
53+
54+
1. Copy the file to your modshells directory
55+
2. Edit to add/remove aliases and settings
56+
3. Restart your shell or run `source ~/.bashrc`
57+
58+
== Shell Compatibility
59+
60+
These examples use POSIX-compatible syntax and work with:
61+
62+
* Bash
63+
* Zsh
64+
* Ksh
65+
* Dash (limited)
66+
* Oils (OSH/YSH)
67+
68+
For Fish, Nushell, or PowerShell, you'll need to translate the syntax.
69+
See the main README for shell-specific sourcing blocks.

examples/core/00-path.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# SPDX-License-Identifier: AGPL-3.0-or-later OR MIT
2+
# core/00-path.sh - PATH modifications (loaded first)
3+
#
4+
# Add custom directories to PATH. Use numeric prefix to control load order.
5+
6+
# Local binaries
7+
export PATH="$HOME/.local/bin:$PATH"
8+
9+
# Cargo (Rust)
10+
[ -d "$HOME/.cargo/bin" ] && export PATH="$HOME/.cargo/bin:$PATH"
11+
12+
# Go
13+
[ -d "$HOME/go/bin" ] && export PATH="$HOME/go/bin:$PATH"
14+
15+
# Deno
16+
[ -d "$HOME/.deno/bin" ] && export PATH="$HOME/.deno/bin:$PATH"

examples/core/10-history.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# SPDX-License-Identifier: AGPL-3.0-or-later OR MIT
2+
# core/10-history.sh - Shell history configuration
3+
4+
# Increase history size
5+
export HISTSIZE=10000
6+
export HISTFILESIZE=20000
7+
8+
# Ignore duplicates and commands starting with space
9+
export HISTCONTROL=ignoreboth:erasedups
10+
11+
# Append to history file, don't overwrite
12+
shopt -s histappend 2>/dev/null || true
13+
14+
# Timestamp history entries
15+
export HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S "
16+
17+
# Ignore common commands
18+
export HISTIGNORE="ls:ll:la:cd:pwd:exit:clear:history"

examples/core/20-options.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# SPDX-License-Identifier: AGPL-3.0-or-later OR MIT
2+
# core/20-options.sh - Shell options and settings
3+
4+
# Check window size after each command
5+
shopt -s checkwinsize 2>/dev/null || true
6+
7+
# Enable extended globbing
8+
shopt -s extglob 2>/dev/null || true
9+
10+
# Correct minor spelling errors in cd
11+
shopt -s cdspell 2>/dev/null || true
12+
13+
# Enable recursive globbing with **
14+
shopt -s globstar 2>/dev/null || true
15+
16+
# Case-insensitive globbing
17+
shopt -s nocaseglob 2>/dev/null || true
18+
19+
# Default editor
20+
export EDITOR="${EDITOR:-vim}"
21+
export VISUAL="${VISUAL:-$EDITOR}"
22+
23+
# Locale
24+
export LANG="${LANG:-en_US.UTF-8}"
25+
export LC_ALL="${LC_ALL:-en_US.UTF-8}"

examples/misc/aliases.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# SPDX-License-Identifier: AGPL-3.0-or-later OR MIT
2+
# misc/aliases.sh - General purpose aliases
3+
4+
# Navigation
5+
alias ..='cd ..'
6+
alias ...='cd ../..'
7+
alias ....='cd ../../..'
8+
9+
# List files
10+
alias ls='ls --color=auto'
11+
alias ll='ls -alF'
12+
alias la='ls -A'
13+
alias l='ls -CF'
14+
15+
# Grep with colour
16+
alias grep='grep --color=auto'
17+
alias fgrep='fgrep --color=auto'
18+
alias egrep='egrep --color=auto'
19+
20+
# Safety nets
21+
alias rm='rm -i'
22+
alias cp='cp -i'
23+
alias mv='mv -i'
24+
25+
# Disk usage
26+
alias df='df -h'
27+
alias du='du -h'
28+
29+
# Process management
30+
alias psg='ps aux | grep -v grep | grep -i'
31+
32+
# Quick edit
33+
alias bashrc='$EDITOR ~/.bashrc'
34+
alias zshrc='$EDITOR ~/.zshrc'

examples/misc/functions.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# SPDX-License-Identifier: AGPL-3.0-or-later OR MIT
2+
# misc/functions.sh - Utility functions
3+
4+
# Create directory and cd into it
5+
mkcd() {
6+
mkdir -p "$1" && cd "$1"
7+
}
8+
9+
# Extract various archive formats
10+
extract() {
11+
if [ -f "$1" ]; then
12+
case "$1" in
13+
*.tar.bz2) tar xjf "$1" ;;
14+
*.tar.gz) tar xzf "$1" ;;
15+
*.tar.xz) tar xJf "$1" ;;
16+
*.bz2) bunzip2 "$1" ;;
17+
*.gz) gunzip "$1" ;;
18+
*.tar) tar xf "$1" ;;
19+
*.tbz2) tar xjf "$1" ;;
20+
*.tgz) tar xzf "$1" ;;
21+
*.zip) unzip "$1" ;;
22+
*.Z) uncompress "$1" ;;
23+
*.7z) 7z x "$1" ;;
24+
*) echo "'$1' cannot be extracted" ;;
25+
esac
26+
else
27+
echo "'$1' is not a valid file"
28+
fi
29+
}
30+
31+
# Find file by name
32+
ff() {
33+
find . -type f -iname "*$1*"
34+
}
35+
36+
# Find directory by name
37+
fd() {
38+
find . -type d -iname "*$1*"
39+
}
40+
41+
# Quick backup
42+
backup() {
43+
cp "$1" "$1.bak.$(date +%Y%m%d-%H%M%S)"
44+
}

examples/os/linux.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# SPDX-License-Identifier: AGPL-3.0-or-later OR MIT
2+
# os/linux.sh - Linux-specific configuration
3+
4+
# Only load on Linux
5+
[ "$(uname -s)" = "Linux" ] || return 0
6+
7+
# Package manager aliases (adjust for your distro)
8+
if command -v apt >/dev/null 2>&1; then
9+
alias apt-update='sudo apt update && sudo apt upgrade'
10+
alias apt-search='apt search'
11+
alias apt-install='sudo apt install'
12+
elif command -v dnf >/dev/null 2>&1; then
13+
alias dnf-update='sudo dnf upgrade'
14+
alias dnf-search='dnf search'
15+
alias dnf-install='sudo dnf install'
16+
elif command -v pacman >/dev/null 2>&1; then
17+
alias pac-update='sudo pacman -Syu'
18+
alias pac-search='pacman -Ss'
19+
alias pac-install='sudo pacman -S'
20+
fi
21+
22+
# Systemd shortcuts
23+
if command -v systemctl >/dev/null 2>&1; then
24+
alias sc='systemctl'
25+
alias scs='systemctl status'
26+
alias scr='sudo systemctl restart'
27+
alias sce='sudo systemctl enable'
28+
alias scd='sudo systemctl disable'
29+
fi
30+
31+
# Open file manager
32+
alias open='xdg-open'

examples/os/macos.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# SPDX-License-Identifier: AGPL-3.0-or-later OR MIT
2+
# os/macos.sh - macOS-specific configuration
3+
4+
# Only load on macOS
5+
[ "$(uname -s)" = "Darwin" ] || return 0
6+
7+
# Homebrew
8+
if [ -x /opt/homebrew/bin/brew ]; then
9+
eval "$(/opt/homebrew/bin/brew shellenv)"
10+
elif [ -x /usr/local/bin/brew ]; then
11+
eval "$(/usr/local/bin/brew shellenv)"
12+
fi
13+
14+
# Homebrew aliases
15+
alias brew-update='brew update && brew upgrade'
16+
alias brew-cleanup='brew cleanup -s && brew autoremove'
17+
18+
# macOS-specific aliases
19+
alias showfiles='defaults write com.apple.finder AppleShowAllFiles YES && killall Finder'
20+
alias hidefiles='defaults write com.apple.finder AppleShowAllFiles NO && killall Finder'
21+
22+
# Flush DNS cache
23+
alias flushdns='sudo dscacheutil -flushcache && sudo killall -HUP mDNSResponder'
24+
25+
# Open current directory in Finder
26+
alias finder='open -a Finder .'
27+
28+
# Quick Look preview
29+
alias ql='qlmanage -p'
30+
31+
# Copy to clipboard
32+
alias copy='pbcopy'
33+
alias paste='pbpaste'

examples/tools/fzf.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# SPDX-License-Identifier: AGPL-3.0-or-later OR MIT
2+
# tools/fzf.sh - Fuzzy finder configuration
3+
4+
# Check if fzf is installed
5+
command -v fzf >/dev/null 2>&1 || return 0
6+
7+
# Default options
8+
export FZF_DEFAULT_OPTS='--height 40% --layout=reverse --border'
9+
10+
# Use fd if available (faster than find)
11+
if command -v fd >/dev/null 2>&1; then
12+
export FZF_DEFAULT_COMMAND='fd --type f --hidden --follow --exclude .git'
13+
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
14+
export FZF_ALT_C_COMMAND='fd --type d --hidden --follow --exclude .git'
15+
fi
16+
17+
# Ctrl+R for history search with preview
18+
export FZF_CTRL_R_OPTS='--preview "echo {}" --preview-window=down:3:wrap'
19+
20+
# fzf key bindings (if available)
21+
[ -f /usr/share/fzf/key-bindings.bash ] && . /usr/share/fzf/key-bindings.bash
22+
[ -f /usr/share/fzf/completion.bash ] && . /usr/share/fzf/completion.bash

0 commit comments

Comments
 (0)