bashrc/alias

1路径

PS1='\\\e\[1;32m\\\\w\\\e\[0m\\ \$ '

路径效果预览:

· 当前完整路径 $ (路径部分显示为绿色)

· 例如:/home/user/project$

PS1='\\\e\[1;32m\\\\W\\\e\[0m\\ \$ '

路径效果预览:

· 当前最后一级目录路径 $ (路径部分显示为绿色)

· 例如:project$

2 重命名terminal窗口的名字

###Change thetitle function title

function title () {

if \[ -z ''$ORIG'' ]; then

ORIG=$PS1

fi

TITLE="\\\e2;$*\a\]"

PS1={ORIG}{TITLE}

}

PS1='\\w'

3把以上两个需求综合运用

1. 先定义你想要的绿色提示符

PS1='\\\e\[1;31m\\\\w\\\e\[0m\\ \$ '

2. 保存当前 PS1(此时已带颜色)到 ORIG

ORIG="$PS1"

3. 定义 title 函数(使用已保存的 ORIG)

function title () {

if \[ -z "$ORIG" ]; then

ORIG="$PS1" # 保存带颜色的原始 PS1

fi

TITLE="\\\e2;$*\a\]"

PS1="{ORIG}{TITLE}"

}

相关推荐
Mr -老鬼1 天前
EasyClick 入门指南:Shell 命令与 ADB 完全指南
android·adb·自动化·shell·easyclick·易点云测
tianyuanwo5 天前
Shell 脚本中的“字典”功能:从基础到工程化的最佳实践
shell·字典
爱睡觉1115 天前
在 Android 模拟器 Shell 下运行 ncnn 推理的性能排查记录
linux·shell
Bolt6 天前
Kimi code 用不了 Figma?看这里解决
shell·mcp
星光不问赶路人7 天前
Shell 脚本避坑指南:从模式匹配到错误处理的实用技巧
shell
日晨难再8 天前
C语言&Python&Bash&Tcl:全局变量和局部变量
c语言·python·bash·tcl
pr_note9 天前
balance_points
shell·tcl
pr_note9 天前
icc2/fc屏蔽指定warning
shell·tcl
诸神缄默不语15 天前
Linux shell脚本教程
linux·bash·shell·sh
liyoro19 天前
用 Codex + 提示词生成一个快速打开 Ghostty 的 macOS 小工具
macos·shell·ai编程