A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/alexiszamanidis/zsh-git-worktree below:

alexiszamanidis/zsh-git-fzf: An interactive ZSH plugin that wraps some git operations for simplicity and productivity. Also, it contains completions and combines the FZF tool to make the operations more convenient.

A ZSH plugin that wraps git operations for simplicity and productivity. Also, it contains completions and combines the FZF tool to make the operations more convenient.

You can find my plugin listed among other useful plugin in the awesome-zsh-plugins repository!

  1. Install Plugin
wget -q https://raw.githubusercontent.com/alexiszamanidis/zsh-git-fzf/master/install -O install && \
chmod +x install && \
./install && \
rm -rf ./install
  1. Add plugin to plugin list
plugins=(... zsh-git-fzf)
  1. Restart your shell or reload config file(source ~/.zshrc)

After installing the plugin you can execute git-fzf help to check the operations that are provided:

You can add the following properties to your .zshrc file:

Property Type Default value Description ZSH_GIT_FZF_REMOVE_STALLED_BRANCHES string false Removes local(stalled) branches that do not exist on remote

Include the code below in your .zshrc file

bindkey -s ^o "git-fzf checkout\n"
bindkey -s ^l "git-fzf log\n"
bindkey -s ^d "git-fzf diff\n"

If you want to execute automatically some code after executing any of the operations below, you can by adding each of the following hooks to your .bashrc(.zshrc, dotfiles, etc).

# Arguments
# - $1: branch name
# - $2: current path

# Example
zsh_git_fzf_on_checkout() {
    BRANCH_NAME=$1
    if [[ "$BRANCH_NAME" = "master" ]]
    then
        # code
    elif [[ "$BRANCH_NAME" = "dev" ]]
    then
        # code
    fi

    PWD=$2
    PROJECT_NAME_1='project-name-1'
    PROJECT_NAME_2='project-name-2'
    if [[ "$PWD" == *"$PROJECT_NAME_1"* ]]
    then
        # code
    elif [[ "$PWD" == *"$PROJECT_NAME_2"* ]]
    then
        # code
    fi
}
# Arguments
# - $1: worktree operation("add", "remove", "list")
# Rest arguments based on the worktree operation
# - "add":
#   - $2: path where worktree created
#   - $3: branch name
# - "remove":
#   - $2: path where worktree deleted
# - "list":
#   - $2: path you switched to
#   - $3: previous worktree path

# Example
zsh_git_fzf_on_worktree_operation() {
    IS_BARE_REPO=$(git rev-parse --is-bare-repository)
    if [ $IS_BARE_REPO = "true" ]; then
        return 1
    fi

    WORKTREE_OPERATION=$1
    if [[ "$WORKTREE_OPERATION" = "list" ]]
    then
        # code
    elif [[ "$WORKTREE_OPERATION" = "add" ]]
    then
        # code
    elif [[ "$WORKTREE_OPERATION" = "remove" ]]
    then
        # code
    fi

    PWD=$2
    PROJECT_NAME_1='project-name-1'
    PROJECT_NAME_2='project-name-2'
    if [[ "$PWD" == *"$PROJECT_NAME_1"* ]]
    then
        # code
    elif [[ "$PWD" == *"$PROJECT_NAME_2"* ]]
    then
        # code
    fi
}

MIT © Alexis Zamanidis


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4