自用 bash配置

本文档介绍了如何编辑.bashrc文件以增加shell分支显示功能、彩色提示、历史搜索补全以及配置adb环境变量,旨在优化Linux终端使用体验,特别是对于在Windows Subsystem for Linux (WSL)环境下进行Android开发的用户。
摘要由CSDN通过智能技术生成

在这个文件下增加下面的语句

1.编辑这个配置文件

gedit  ~/.bashrc &

2.增加的语句

# add 2022.6.9 start
# shell分支显示
function git_branch {
   branch="`git branch 2>/dev/null | grep "^\*" | sed -e "s/^\*\ //"`"
   if [ "${branch}" != "" ];then
       if [ "${branch}" = "(no branch)" ];then
           branch="(`git rev-parse --short HEAD`...)"
       fi
       echo " [*$branch]"
   fi
}
# 彩色显示
export PS1='\[\033[01;32m\]\@ \[\033[01;33m\]\w\[\033[01;31m\]$(git_branch)\[\033[01;37m\]\n\u \$ '
# ccache
export CCACHE_EXEC=/usr/bin/ccache
export USE_CCACHE=true
export CCACHE_SLOPPINESS=file_macro,include_file_mtime,time_macros
export CCACHE_UMASK=002
export CCACHE_DIR=/media/root/2.0T_pro/project_ssd/ccache

# 上下键补全
if [[ $- == *i* ]]
then
    bind '"\e[A": history-search-backward'
    bind '"\e[B": history-search-forward'
fi
# add 2022.6.9 over

# shell分支显示
function git_branch {
   branch="`git branch 2>/dev/null | grep "^\*" | sed -e "s/^\*\ //"`"
   if [ "${branch}" != "" ];then
       if [ "${branch}" = "(no branch)" ];then
           branch="(`git rev-parse --short HEAD`...)"
       fi
       echo " [*$branch]"
   fi
}

# 彩色显示
export PS1='\[\033[01;32m\]\@ \[\033[01;33m\]\w\[\033[01;31m\]$(git_branch)\[\033[01;37m\]\n\u \$ '

# 上下键补全
if [[ $- == *i* ]]
then
	    bind '"\e[A": history-search-backward'
	    bind '"\e[B": history-search-forward'
fi
# add 2022.6.9 over

#用于win10 WSL 子系统adb 连接手机 2022.12.6 add start
export PATH=$PATH:/mnt/d/adb/adb #adb安装位置 环境变量配置
alias adb='/mnt/d/adb/adb/adb.exe'
export PATH=$PATH:/mnt/d/adb/adb
alias fastboot='/mnt/d/adb/adb/fastboot.exe'
#用于win10 WSL 子系统adb 连接手机 2022.12.6 add over

3.让文件生效

source  ~/.bashrc
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Running_pink

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值