Skip to content

Commit

Permalink
add note
Browse files Browse the repository at this point in the history
  • Loading branch information
hxf0223 committed Aug 23, 2024
1 parent ae7b4a2 commit 3605d0d
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions _posts/2024-08-21-ubuntu-bash-alias.md
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)

0 comments on commit 3605d0d

Please sign in to comment.