Re-organize the shells' initialization logic
- unify ~/.config/shell/aliases.sh and ~/.config/shell/utils.sh into a common ~/.config/shell/init.sh - split the contents of ~/.config/shell/aliases.sh into the folder ~/.config/shell/aliases.d - split the contents of ~/.config/shell/utils.sh into the folder ~/.config/shell/utils.d
This commit is contained in:
parent
8aad11aed1
commit
a8f8caccc0
17 changed files with 665 additions and 621 deletions
24
.config/shell/aliases.d/git.sh
Normal file
24
.config/shell/aliases.d/git.sh
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
# All git aliases (with < 7 characters) become shell aliases with a "g" prefix
|
||||
|
||||
|
||||
_command_exists() {
|
||||
command -v "$1" 1>/dev/null 2>&1
|
||||
}
|
||||
|
||||
|
||||
if _command_exists git; then
|
||||
alias g='git'
|
||||
|
||||
for al in $(git internal-aliases); do
|
||||
[ ${#al} -lt 7 ] && eval "alias g$al='git $al'"
|
||||
done
|
||||
|
||||
# Check if a 'main' branch exists in place of a 'master' branch
|
||||
git_main_branch() {
|
||||
if [[ -n "$(git branch --list main)" ]]; then
|
||||
echo 'main'
|
||||
else
|
||||
echo 'master'
|
||||
fi
|
||||
}
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue