generated from cotes2020/chirpy-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
title: 备份:Ubuntu Bash Alias, 以及 bash 显示 git status | ||
date: 2024-08-21 +0800 # 2022-01-01 13:14:15 +0800 只写日期也行;不写秒也行;这样也行 2022-03-09T00:55:42+08:00 | ||
categories: [bash] | ||
tags: [bash, linux] # TAG names should always be lowercase | ||
|
||
# 以下默认false | ||
math: true | ||
mermaid: true | ||
# pin: true | ||
--- | ||
|
||
## bash alias | ||
|
||
```bash | ||
################### | ||
# bash alias | ||
alias g='git status -sb' | ||
|
||
alias ll='ls -alF' | ||
alias la='ls -A' | ||
alias l='ls -ltrhA' | ||
alias gl='ls|grep --color' | ||
# alias .='cd ../' | ||
# alias ..='cd ../..' | ||
alias ..='cd ..' | ||
alias ...='cd ..; cd ..' | ||
alias ....='cd ..; cd ..; cd ..' | ||
|
||
alias c='clear' | ||
alias r='reset' | ||
``` | ||
|
||
## bash 显示 git status | ||
|
||
```bash | ||
# Show git branch name | ||
force_color_prompt=yes | ||
color_prompt=yes | ||
parse_git_branch() { | ||
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' | ||
} | ||
if [ "$color_prompt" = yes ]; then | ||
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\]$(parse_git_branch)\[\033[00m\]\$ ' | ||
else | ||
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(parse_git_branch)\$ ' | ||
fi | ||
unset color_prompt force_color_prompt | ||
``` | ||
|
||
参考:[How do I show the git branch with colours in Bash prompt?](https://askubuntu.com/questions/730754/how-do-i-show-the-git-branch-with-colours-in-bash-prompt) |