forked from nhs-england-tools/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdot_aliases
More file actions
113 lines (100 loc) · 7.61 KB
/
dot_aliases
File metadata and controls
113 lines (100 loc) · 7.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# ==============================================================================
# git
alias g="git" # Run git
alias ga="git add" # Stage files
alias gb+="git branch -vv --all" # List all branches (local and remote) with tracking info
alias gb="git branch -vv" # List local branches with tracking info
alias gbd="git branch -D" # Force-delete a local branch
alias gc+="git commit --all --gpg-sign -m" # Stage all changes and commit (signed)
alias gc="git commit --gpg-sign -m" # Commit staged changes (signed)
alias gco="git checkout" # Switch branches or restore files
alias gd+="git diff --cached" # Show staged (cached) changes
alias gd="git diff" # Show unstaged working-tree changes
alias gf="git fetch --prune" # Fetch remote refs and remove stale tracking branches
alias gl+="git log --graph --oneline --decorate --stat" # Compact log graph with file-change stats
alias gl="git log --graph --oneline --decorate" # Compact log graph
alias gm="git merge --no-ff" # Merge with an explicit merge commit (no fast-forward)
alias gp="git pull --prune" # Pull and remove stale tracking branches
alias gpu+="git push --force-with-lease" # Force-push safely (rejects if remote has new commits)
alias gpu="git push" # Push to remote
alias gpuo="git push --set-upstream origin" # Push and set upstream tracking to origin
alias gr++="git reset --hard HEAD~1" # Undo last commit and discard all changes
alias gr+="git reset --hard HEAD" # Discard all uncommitted changes
alias gr="git reset HEAD" # Unstage all staged files (keep working-tree changes)
alias gs="git status --short" # Show short working-tree status
alias gst="git stash" # Stash working-tree changes
alias gstp="git stash pop" # Apply and remove the latest stash
alias gstl="git stash list" # List all stashes
alias gcl="git clone --recurse-submodules" # Clone a repo including submodules
alias gcp="git cherry-pick" # Apply a commit from another branch
alias grl="git reflog" # Show reference log (undo safety net)
alias gbl="git blame" # Show line-by-line authorship of a file
alias gt="git tag" # List or create tags
alias grb="git rebase" # Rebase current branch
alias grbi="git rebase --interactive" # Interactive rebase (squash, reorder, edit commits)
alias gsw="git switch" # Switch branches (modern alternative to checkout)
alias gswc="git switch --create" # Create and switch to a new branch
# ==============================================================================
# containers (docker / podman)
# Resolve the container CLI: prefer docker, fall back to podman
if command -v docker > /dev/null 2>&1; then
_container_cmd="docker"
elif command -v podman > /dev/null 2>&1; then
_container_cmd="podman"
fi
alias d="$_container_cmd" # Run container CLI
alias dbu="$_container_cmd build --tag" # Build an image with a tag
alias dex="$_container_cmd exec --interactive --tty" # Execute interactive shell in a running container
alias dhi="$_container_cmd history" # Show image layer history
alias dim="$_container_cmd images" # List local images
alias dip="$_container_cmd inspect --format '{{ .NetworkSettings.IPAddress }}'" # Get container IP address (empty in Podman rootless mode)
alias dlo="$_container_cmd logs --follow" # Tail container logs
alias dnl="$_container_cmd network ls" # List networks
alias dnr="$_container_cmd network prune --force" # Remove unused networks
alias dps="$_container_cmd ps --all" # List all containers (running and stopped)
alias dpu="$_container_cmd pull" # Pull an image
alias drc='$_container_cmd rm --volumes --force $($_container_cmd ps --all --quiet) 2> /dev/null' # Remove all containers and their anonymous volumes
alias dri="$_container_cmd image prune --all --force" # Remove all unused images
alias drun="$_container_cmd run --rm --interactive --tty" # Run a disposable container
alias dsp="$_container_cmd system prune --all --force" # Remove all unused containers, networks, images and volumes
alias dst="$_container_cmd stop" # Stop a container
alias dtop="$_container_cmd stats --no-stream" # Show resource usage snapshot
alias dvl="$_container_cmd volume ls" # List volumes
alias dvr="$_container_cmd volume prune --force" # Remove unused volumes
# Compose
alias dcup="$_container_cmd compose up --detach" # Start compose stack in the background
alias dcdn="$_container_cmd compose down" # Tear down compose stack
alias dcl="$_container_cmd compose logs --follow" # Tail compose logs
# ==============================================================================
# [tools]
alias code='\code --user-data-dir ~/.config/Code/'
alias c='\code --user-data-dir ~/.config/Code/ $(ls -1 *.code-workspace)'
alias cz="chezmoi"
# ==============================================================================
# [shell]
alias reload="exec $SHELL -l" # Reload shell
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias ~="cd ~"
alias -- -="cd -"
# Ubuntu compatibility aliases (package names differ)
if ! command -v bat > /dev/null 2>&1 && command -v batcat > /dev/null 2>&1; then
alias bat='batcat'
fi
if ! command -v fd > /dev/null 2>&1 && command -v fdfind > /dev/null 2>&1; then
alias fd='fdfind'
fi
alias ls='eza --classify=auto --color --group-directories-first --icons --git -A'
alias ll='eza --classify=auto --color --group-directories-first --icons --git -la'
alias lt='eza --classify=auto --color --group-directories-first --icons --git --tree --level=2'
alias cat='bat --paging=never'
alias man='bat --plain --language=man'
# ==============================================================================
# [grc - generic colouriser]
if command -v grc > /dev/null 2>&1; then
alias diff='grc --colour=auto diff'
alias make='grc --colour=auto make'
alias ping='grc --colour=auto ping'
alias traceroute='grc --colour=auto traceroute'
fi