Skip to content

Instantly share code, notes, and snippets.

@salarmehr
Created February 4, 2020 06:48
Show Gist options
  • Save salarmehr/4d88ddd439654d6e669005914a47f21c to your computer and use it in GitHub Desktop.
Save salarmehr/4d88ddd439654d6e669005914a47f21c to your computer and use it in GitHub Desktop.
// run in in console or create a brower bookmark prefixing it with `javascript:` and copy this gist as url.
// now you can click on the bookmakr button ot copy the git command to clipboard.
function copy(text) {
var input = document.createElement('input');
input.setAttribute('value', text);
document.body.appendChild(input);
input.select();
var result = document.execCommand('copy');
document.body.removeChild(input);
return result;
}
var type = $('.view-header .tau-entity-icon-full').eq(1).text();
var number = $('.entity-id').eq(1).text();
var title = $('.view-header__entity-title').eq(1).text();
var branchTitle = title.replace(/[ ~\^:]/g, '_').replace(/['"]/g, '\\$&');
var commit = `${number} ${title}`;
var checkout = 'git checkout -b ' + type + '/' + number + '-' + branchTitle;
copy(commit);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment