GithubHelp home page GithubHelp logo

sublime_text's Introduction

Sublime Text & Merge Configurations

What's nicer that having all your configurations version controlled and synced between your work and personal machines?

I use HomeSchick to manage my configs. So they are formatted to be checked out and linked by me.

Folders of Note

  • Users is my Sublime Text 4 Users Package
  • Users-Sublime-Merge is unsurprisingly my Sublime Merge Users Package
  • home/bin has my shell scripts I use to enhance both

Scripts

Some commands relies on scripts and git aliases that are all found in my dotfiles

Using Sublime Text as EDITOR

I have found that the subl command line has some gotchas when used as EDITOR so I have a subl_wait script which lets me use sublime for things like crontab -e.

Sublime Merge and GitHub/GitLab/Bitbucket Integration

I use an amazing git alias found on the Sublime Merge Discourse Forum.

In case that post vanishes here is the git alias for 'open'

git config --global alias.open '!f() {
    local type="${1:-branch}"
    local target="${2:-HEAD}"
    local remote="origin"

    if [ "$type" = "branch" -o "$type" = "pr" ]; then
        # get full name (i.e. refs/heads/*; refs/remotes/*/*); src: https://stackoverflow.com/a/9753364
        target="$(git rev-parse --symbolic-full-name "$target")"

        if [ "$target" != "${target#"refs/remotes/"}" ]; then
            # extract from remote branch reference
            target="${target#"refs/remotes/"}"
        else
            # extract from local branch reference; src: https://stackoverflow.com/a/9753364
            target="$(git for-each-ref --format="%(upstream:short)" "$target")"
        fi
        # split remote/branch
        remote="${target%%/*}"
        target="${target#"$remote/"}"

        if [ -z "$remote" ]; then
            echo "Branch ($2) does not point to a remote repository." >&2
            return 2
        fi
    fi

    local repo_url="$(git remote get-url "$remote" | sed -E -e "s/(\.(com|org|io))\:/\1\//" -e "s/git@/https:\/\//" -e "s/\.git$//")"
    if [ -z "$repo_url" ]; then
        echo "Cannot open: no remote repository configured under (origin)" >&2
        return 1
    fi

    case "$(tr "[:upper:]" "[:lower:]" <<< "$repo_url")" in
        *github*)
            [ "$type" = "commit" ] && repo_url="$repo_url/commit/$(git rev-parse "$target")"
            [ "$type" = "pr"     ] && repo_url="$repo_url/compare/$target?expand=1"
            [ "$type" = "tag"    ] && repo_url="$repo_url/releases/tag/$target"
            [ "$type" = "branch" ] && repo_url="$repo_url/tree/$target"
            ;;
        *bitbucket*)
            [ "$type" = "commit" ] && repo_url="$repo_url/commits/$(git rev-parse "$target")"
            [ "$type" = "pr"     ] && repo_url="$repo_url/pull-requests/new?source=$target"
            [ "$type" = "tag"    ] && repo_url="$repo_url/src/$target"
            [ "$type" = "branch" ] && repo_url="$repo_url/src/$target"
            ;;
        *gitlab*)
            [ "$type" = "commit" ] && repo_url="$repo_url/-/commit/$(git rev-parse "$target")"
            [ "$type" = "pr"     ] && repo_url="$repo_url/-/merge_requests/new?merge_request[source_branch]=$target"
            [ "$type" = "tag"    ] && repo_url="$repo_url/-/tags/$target"
            [ "$type" = "branch" ] && repo_url="$repo_url/-/tree/$target"
            ;;
        *)
            echo "Cannot open: not a GitHub, GitLab, or Bitbucket repository" >&2
            return 1
            ;;
    esac

    open "$repo_url"
}; f'

sublime_text's People

Contributors

onlyhavecans avatar

Stargazers

Anne Thorpe avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.