首页 » 操作系统 » Linux » 正文

~/.config/fish/config.fish

发布者:站点默认
2020/01/1 浏览数(1,155) 分类:Linux, macOS ~/.config/fish/config.fish已关闭评论
alias zc='z -c' # 严格匹配当前路径的子路径                                                                                                 
alias zz='z -i' # 使用交互式选择模式
alias zf='z -I' # 使用 fzf 对多个结果进行选择
alias zb='z -b' # 快速回到父目录
alias emu="$ANDROID_HOME/tools/emulator"
alias dl="axel -ak"
alias ls="gls -hF --color"
alias ll="ls -l --time-style=long-iso"
alias bye="exit"
alias port="lsof -i"
alias tree="tree -aNFA --dirsfirst"
alias ip="ifconfig | grep 'inet ' && ifconfig | grep 'inet6'"
alias ..="cd .."
alias ...="cd ../../"
alias cd..="cd .."
alias ra="react-native run-android"
alias ri="react-native run-ios --simulator 'iPhone 7'"
alias ns="npm start"
alias nb="npm run build"
alias gp="git pull"
alias gs="git status"
alias gb="git branch"
alias go="git checkout"
alias ga="git add"
alias gc="git commit"
alias gac="git add . && git commit -m"
alias gu="git push"
alias gl="git lg1"
alias gf="git fetch"
alias gm="git merge"
alias ys="yarn serve"
alias yb="yarn build"
alias vs="cd ~/Homestead/ && vagrant up && vagrant ssh && cd -"
alias vh="cd ~/Homestead/ && vagrant halt && cd -"

# 隐藏欢迎语
function fish_greeting
end

# 按下 ^c 时要用 ├ 代替 ┌ 这里先打个 abort 的记号
function onAbort --on-signal INT
  set -g __on_aborted 1
end

# 判断是否是git仓库的工具函数
function is_git_repo --description 'Check if directory is a repository'
    test -d .git
    or command git rev-parse --git-dir >/dev/null ^/dev/null
end

# PS1
function fish_prompt --description 'Write out the prompt'
    set last_status $status

    set -g __fish_git_prompt_showupstream "informative"
    set -g __fish_git_prompt_showdirtystate 1
    set -g __fish_git_prompt_showstashstate 1
    set -g __fish_git_prompt_showuntrackedfiles 1
    set -g __fish_git_prompt_char_stateseparator " "
    set -g __fish_git_prompt_char_upstream_prefix " "
    # set -g __fish_git_prompt_showcolorhints 1

    set -l os (uname --operating-system)
    if test "$os" != "GNU/Linux"
        set -g __fish_git_prompt_show_informative_status 1
    end

    if not test $last_status -eq 0
        set status_color (set_color red)
    else
        set status_color (set_color normal)
    end

    if set --query SSH_TTY
        set fish_color_host red
    end

    set git_info
    if is_git_repo
        if set -q __fish_git_prompt_show_informative_status
            set file_status (__fish_git_prompt "%s")
            set git_info (set_color yellow)"$file_status"
        else
            __fish_git_prompt >/dev/null 2>&1
            set upstream (__fish_git_prompt_show_upstream)
            set branch (git branch | grep \* | sed 's/* //')
            set file_status (__fish_git_prompt_informative_status)
            set git_info (set_color yellow)"$branch$__fish_git_prompt_char_stateseparator$file_status$upstream"
        end
    end

    set prefix $status_color'┌─'
    set user_info "$USER@"(prompt_hostname)
    set path (set_color blue)(dirs)
    set suffix $status_color'└─$ '
    if set -q __on_aborted
        or not test $last_status -eq 0
        set prefix $status_color'├─'
        set -eg __on_aborted
    end

    echo -ne "$prefix$user_info $path$git_info\n$suffix"

    set_color normal
end

function fish_right_prompt
    set last_status $status
    if not test $last_status -eq 0
        set_color $fish_color_error
        echo $last_status
        set_color normal
    end
end

fish shell with git

点击返回顶部
  1. 留言
  2. 联系方式