优化bash使用体验:实用技巧与功能拓展
1. 创建更便捷的cd命令
在日常使用中,我们常常需要切换到深层目录。传统的 cd 命令在向上多级切换时,输入 cd ../../.. 等操作较为繁琐。为了简化这一过程,我们可以自定义一个 cd 函数。
# cookbook filename: func_cd
# Allow use of 'cd ...' to cd up 2 levels, 'cd ....' up 3, etc. (like 4NT/4DOS)
# Usage: cd ..., etc.
function cd {
local option= length= count= cdpath= i= # Local scope and start clean
# If we have a -L or -P sym link option, save then remove it
if [ "$1" = "-P" -o "$1" = "-L" ]; then
option="$1"
shift
fi
# Are we using the special syntax? Make sure $1 isn't empty, then
# match the first 3 characters of $1 to see if they are '...' then
# make sure there isn't a slash by trying a substi
超级会员免费看
订阅专栏 解锁全文
3

被折叠的 条评论
为什么被折叠?



