Make aliases portable

This commit is contained in:
Saravana Achu Mac 2026-05-05 10:44:25 -07:00
parent c894621e64
commit 7b90188a37
5 changed files with 92 additions and 12 deletions

40
aliases/README.md Normal file
View File

@ -0,0 +1,40 @@
# Shell Aliases
Reusable Bash/Zsh aliases for common shell, git, tmux, directory, and listing shortcuts.
## Install
Source the aggregate loader from your shell startup file.
For Zsh, add this to `~/.zshrc`:
```bash
source /Users/saravana/BytelystAI/bytelyst-devops-tools/aliases/_source_all.alias
```
For Bash, add this to `~/.bashrc`:
```bash
source /Users/saravana/BytelystAI/bytelyst-devops-tools/aliases/_source_all.alias
```
The loader can be sourced from any directory. It discovers the `aliases/` folder and loads each alias file from that path.
## Requirements
- Supported shells: Bash and Zsh
- Optional commands used by aliases: `git`, `tmux`, `tree`, and `vim` or `$EDITOR`
## Examples
```bash
gs # git status
gd # git diff
tl # tmux list-sessions
tn work # tmux new-session -s work
ta work # tmux attach-session -t work
```
## Local Aliases
Keep machine- or org-specific shortcuts out of the portable default files. Start from `_local.example.alias` if you want private local aliases such as branch-specific git commands.

View File

@ -1,5 +1,18 @@
alias oga='vim ~/_git.alias'
alias sga='source ~/_git.alias'
if [ -z "${BYTELYST_ALIAS_DIR:-}" ]; then
if [ -n "${BASH_SOURCE[0]:-}" ]; then
_bytelyst_git_alias_source="${BASH_SOURCE[0]}"
elif [ -n "${ZSH_VERSION:-}" ]; then
_bytelyst_git_alias_source="${(%):-%N}"
else
_bytelyst_git_alias_source="$0"
fi
BYTELYST_ALIAS_DIR="$(cd -- "$(dirname -- "$_bytelyst_git_alias_source")" >/dev/null 2>&1 && pwd -P)"
unset _bytelyst_git_alias_source
fi
alias oga='${EDITOR:-vim} "$BYTELYST_ALIAS_DIR/_git.alias"'
alias sga='source "$BYTELYST_ALIAS_DIR/_git.alias"'
alias gcl='git checkout -'
alias gcb='git checkout -b'
alias gcm='git checkout main'
@ -11,7 +24,6 @@ alias gs='git status'
alias gdc='git diff --cached'
alias gd='git diff'
alias gr='git reset'
alias grhm='git reset --hard origin/mainline'
alias ga='git add'
alias gc='git checkout'
alias gaa='git add .'
@ -22,11 +34,9 @@ alias gima='git commit -a -m'
alias gim='git commit -m'
alias gp='git push'
alias gfp='git push --force-with-lease'
alias gpm='git push origin HEAD:mainline'
alias gri='git rebase -i'
alias grc='git rebase --continue'
alias gra='git rebase --abort'
alias gprm='git pull --rebase origin mainline'
alias gpr='git pull -r'
alias gst='git stash'
alias gsp='git stash pop'
@ -42,4 +52,4 @@ alias gl1='git log -p -1'
# show content of last commit (HEAD)
alias gsh='git show HEAD'
#help
alias ghh='cat ~/_git.alias'
alias ghh='cat "$BYTELYST_ALIAS_DIR/_git.alias"'

View File

@ -0,0 +1,10 @@
# Optional local aliases.
#
# Copy this file to _local.alias for machine- or org-specific shortcuts.
# Do not source _local.alias from _source_all.alias unless you are comfortable
# with those shortcuts becoming part of your default shell environment.
# ByteLyst/mainline-specific examples:
# alias grhm='git reset --hard origin/mainline'
# alias gpm='git push origin HEAD:mainline'
# alias gprm='git pull --rebase origin mainline'

View File

@ -1,6 +1,17 @@
source ./_git.alias
source ./_tmux.alias
source ./_cd.alias
source ./_ls.alias
source ./_general.alias
source ./_shell.alias
if [ -n "${BASH_SOURCE[0]:-}" ]; then
_bytelyst_alias_source="${BASH_SOURCE[0]}"
elif [ -n "${ZSH_VERSION:-}" ]; then
_bytelyst_alias_source="${(%):-%N}"
else
_bytelyst_alias_source="$0"
fi
BYTELYST_ALIAS_DIR="$(cd -- "$(dirname -- "$_bytelyst_alias_source")" >/dev/null 2>&1 && pwd -P)"
unset _bytelyst_alias_source
source "$BYTELYST_ALIAS_DIR/_git.alias"
source "$BYTELYST_ALIAS_DIR/_tmux.alias"
source "$BYTELYST_ALIAS_DIR/_cd.alias"
source "$BYTELYST_ALIAS_DIR/_ls.alias"
source "$BYTELYST_ALIAS_DIR/_general.alias"
source "$BYTELYST_ALIAS_DIR/_shell.alias"

View File

@ -80,6 +80,15 @@ Key files:
- `ubuntu-vm-security-update.sh`
- `README.md`
### `aliases/`
Reusable Bash/Zsh alias bundle for common git, tmux, shell, directory, and listing shortcuts.
Key files:
- `_source_all.alias`
- `README.md`
### `github_access_scripts/`
Focused GitHub access checks.