配置shell命令别名 提效

检查当前 shell

echo $SHELL

# 切换
chsh -s /bin/zsh

编辑

vim ~/.zshrc

alias nw='npm run whistle'
alias nd='npm run dev'
alias nid='npm install -D'
alias ni='npm i'
alias gc='git commit -m'
alias grsa='git restore .'
alias gcl='git clean'
alias gaa='git add .'
alias gp='git push'
alias gpu='git push upstream'
alias gpo='git push origin'
alias gr='git reset'
alias gsu='git stash save -u'
alias gs='git stash save'
alias gsl='git stash list'
alias gsp='git stash pop'
alias gsa='git stash apply'
alias gsd='git stash drop'
alias gsc='git stash clear'
alias gf='git fetch'
alias gfu='git fetch upstream'
alias gl='git log --oneline'
alias gck='git checkout'
alias gcp='git cherry-pick'
alias c='clear'
alias gckb='git checkout -b'
alias gbd='git branch -D'
alias gb='git branch'
alias gri='git rebase -i'
gpoc(){
    echo "push origin current branch"
    current_branch=$(git branch --show-current)
    echo $current_branch
    if [ -z $current_branch ]; then
        echo "no $current_branch"
        return 1
    fi
    git push origin $current_branch $1
}
gpuc() {
    echo "push upstream current branch"
    current_branch=$(git branch --show-current)
    echo $current_branch
    if [ -z $current_branch ]; then
        echo "no $current_branch"
        return 1
    fi
    git push upstream $current_branch $1
}
alias gm='git merge'
gmuc() {
    local current_branch
    current_branch=$(git branch --show-current 2>/dev/null)
    echo "current branch $current_branch"
    # 检查当前分支是否存在
    if [[ -z "$current_branch" ]]; then
        echo "Error: Not on a Git branch!"
        return 1
    fi
    git merge upstream/$current_branch $1
}
gmu() {
    # 如果未提供分支名,提示错误
    if [[ $# -eq 0 ]]; then
        echo "Error: Please specify a branch name or use '-c'"
        return 1
    fi
    # 合并指定分支
    git merge "upstream/$1"
}
# 在多个 shell 会话之间共享历史记录
setopt SHARE_HISTORY
# pb格式转ts类型
pb2ts(){
    protoc --plugin=protoc-gen-ts_proto=$(which protoc-gen-ts_proto) \
    --ts_proto_out=.\
    --ts_proto_opt=outputEncodeMethods=false,outputJsonMethods=false,outputClientImpl=false\
    $1
}

立即生效

source ~/.zshrc

删除别名

unalias nw
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

鲤余

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

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

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

打赏作者

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

抵扣说明:

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

余额充值