Skip to content

Commit

Permalink
♻️ refactor: reorganize shell aliases into a common file for better m…
Browse files Browse the repository at this point in the history
…aintainability

Move shared shell aliases from `.aliases` and `.aliases.fish` into a new `.aliases.common` file. Update both `.aliases` and `.aliases.fish` to source this common file. Adjust `install.conf.yaml` to include the new `.aliases.common` file in the installation process.

This change reduces redundancy and makes it easier to manage and update aliases across different shell configurations. It also ensures consistency between shell environments.
  • Loading branch information
jmarcelomb committed Feb 9, 2025
1 parent 6319653 commit e0911ab
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 130 deletions.
59 changes: 2 additions & 57 deletions .aliases
Original file line number Diff line number Diff line change
Expand Up @@ -3,71 +3,16 @@
if command -v eza >/dev/null 2>&1; then
alias ls=eza
fi
alias la="ls -AlH" # Show hidden files, detailed listing
alias ll="ls -lH" # Detailed listing
alias lt="ls --tree" # Display directory as a tree
alias ld="ls -ld */" # List only directories

alias lg=lazygit

# Check if zoxide exists and alias cd to zoxide
if command -v zoxide >/dev/null 2>&1; then
alias cd=z
alias zi="z -i" # Interactive mode for zoxide
alias zb="z -b" # Jump to the best match
fi

# Check if bat exists and alias cat to bat
if command -v bat >/dev/null 2>&1; then
alias cat="bat --style=plain --paging=never"
alias batn="bat --style=numbers" # Bat with line numbers
alias batc="bat --style=changes" # Bat with Git diff highlights
alias less='bat --paging=always'
fi

# Directory navigation aliases
alias ..="cd .."
alias ...="cd ../../"
alias ....="cd ../../../"
alias -- -="cd -" # Go back to the previous directory

# Editor aliases
alias vim=nvim
alias v=nvim
alias edit=nvim

# Git aliases
alias gs="git status"
alias ga="git add"
alias gA="git add -A"
alias gr="git restore"
alias grs="git restore --staged"
alias gc="git commit -s"
alias gcm="git commit -s -m"
alias gP="git push"
alias gPf="git push --force-with-lease"
alias gPF="git push --force"
alias ga="git add"
alias gp="git pull"
alias gl="git log --oneline --graph --decorate"
alias gco="git checkout"
alias gb="git branch"
alias gcp="git cherry-pick"
alias gcpn="git cherry-pick -n"
alias gwa="git worktree add"
alias gwr="git worktree remove"
alias gwls="git worktree list"

# File search and manipulation aliases
alias f="find . -type f -iname" # Search for files by name
alias grep="grep --color=auto" # Colored grep

# System monitoring aliases
alias dfh="df -h" # Disk usage in human-readable format
alias duh="du -sh" # Directory size in human-readable format
alias top="htop" # Use htop if installed
alias meminfo="free -h" # Memory usage

# Networking aliases
alias ip="ip -c a" # Colorful IP address display
alias ping="ping -c 5" # Limit ping to 5 packets
alias ports="netstat -tulanp" # Show open ports
source ~/.aliases.common
64 changes: 64 additions & 0 deletions .aliases.common
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
## ls aliases
alias la="ls -AlH" # Show hidden files, detailed listing
alias ll="ls -lH" # Detailed listing
alias lt="ls --tree" # Display directory as a tree
alias ld="ls -ld */" # List only directories

# zoxide aliases
alias zi="z -i" # Interactive mode for zoxide
alias zb="z -b" # Jump to the best match

# bat aliases
alias batn="bat --style=numbers" # Bat with line numbers
alias batc="bat --style=changes" # Bat with Git diff highlights

# lazygit aliases
alias lg="lazygit"

# Directory navigation aliases
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../../"

# Editor aliases
alias vim="nvim"
alias v="nvim"
alias edit="nvim"
alias e="nvim"

# Git aliases
alias gs="git status"

alias ga="git add"
alias gA="git add -A"

alias gr="git restore"
alias grs="git restore --staged"

alias gc="git commit -s"
alias gcm="git commit -s -m"

alias gP="git push"
alias gPf="git push --force-with-lease"
alias gPF="git push --force"

alias gp="git pull"
alias gpr="git pull --rebase"

alias gck="git checkout"
alias gsw="git switch"

alias gl="git log --oneline --graph --decorate"
alias glo="git log --oneline"

alias gb="git branch"
alias gba="git branch -a"

alias gcp="git cherry-pick"
alias gcpn="git cherry-pick -n"

alias gwa="git worktree add"
alias gwr="git worktree remove"
alias gwls="git worktree list"
### End of git aliases

73 changes: 2 additions & 71 deletions .aliases.fish
Original file line number Diff line number Diff line change
Expand Up @@ -2,85 +2,16 @@
if type -q eza
alias ls="eza"
end
alias la="ls -AlH" # Show hidden files, detailed listing
alias ll="ls -lH" # Detailed listing
alias lt="ls --tree" # Display directory as a tree
alias ld="ls -ld */" # List only directories

alias lg="lazygit"

# Check if zoxide exists and alias cd to zoxide
if type -q zoxide
alias cd="z"
alias zi="z -i" # Interactive mode for zoxide
alias zb="z -b" # Jump to the best match
end

# Check if bat exists and alias cat to bat
if type -q bat
alias cat="bat --style=plain --paging=never"
alias batn="bat --style=numbers" # Bat with line numbers
alias batc="bat --style=changes" # Bat with Git diff highlights
alias less='bat --paging=always'
end

# Directory navigation aliases
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../../"

# Editor aliases
alias vim="nvim"
alias v="nvim"
alias edit="nvim"
alias e="nvim"

# Git aliases
alias gs="git status"

alias ga="git add"
alias gA="git add -A"

alias gr="git restore"
alias grs="git restore --staged"

alias gc="git commit -s"
alias gcm="git commit -s -m"

alias gP="git push"
alias gPf="git push --force-with-lease"
alias gPF="git push --force"

alias gp="git pull"
alias gpr="git pull --rebase"

alias gck="git checkout"
alias gsw="git switch"

alias gl="git log --oneline --graph --decorate"
alias glo="git log --oneline"

alias gb="git branch"
alias gba="git branch -a"

alias gcp="git cherry-pick"
alias gcpn="git cherry-pick -n"

alias gwa="git worktree add"
alias gwr="git worktree remove"
alias gwls="git worktree list"
### End of git aliases

# File search and manipulation aliases
alias f="find . -type f -iname"
alias grep="grep --color=auto"

# System monitoring aliases
alias dfh="df -h" # Disk usage in human-readable format
alias duh="du -sh" # Directory size in human-readable format
alias top="htop" # Use htop if installed
alias meminfo="free -h" # Memory usage

# Networking aliases
alias ip="ip -c a"
alias ping="ping -c 5"
alias ports="netstat -tulanp"
source ~/.aliases.common
5 changes: 3 additions & 2 deletions install.conf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
~/.config/ghostty/: .config/ghostty/
~/.config/aerospace/: .config/aerospace/
~/.config/sketchybar/: .config/sketchybar/
~/.config/fish/: .config/fish/
~/.aliases.fish: .aliases.fish
~/.zshrc: .zshrc
~/.bashrc.marcelo: .bashrc.marcelo
~/.aliases: .aliases
~/.aliases.common: .aliases.common
~/.aliases.fish: .aliases.fish
~/.config/fish/: .config/fish/
~/.tmux.conf: .tmux.conf

# - create:
Expand Down

0 comments on commit e0911ab

Please sign in to comment.