38、优化bash使用体验:实用技巧与功能拓展

优化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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值