spenibus.net
2016-10-23 01:32:41 GMT

git bash function gitnew version 20161023-0057, with less redundancy

gitnew ------ gitnew() { # token path tokenPath='P:/' # name of the remote in the config remoteName='all' # order of remote repos # first is main, others are secondary # the values here are keys for remoteUrl and remoteUser remoteOrder=( 'github' 'gitlab' 'bitbucket' ) # remote urls (where to push) declare -A remoteUrl=( ['github']='git@github.com:user' ['gitlab']='git@gitlab.com:user' ['bitbucket']='git@bitbucket.org:user' ) # remote users (who is pushing) declare -A remoteUser=( ['github']='user' ['gitlab']='user' ['bitbucket']='user' ) ##### no config edits below this point # token folder does not exist if [ ! -d "$tokenPath" ]; then echo 'error: token folder not available' # .git subfolder does not exist elif [ ! -d ".git" ]; then echo 'error: .git folder is missing' # we got everything we need else # repo name repoName="$(basename "$PWD")" for i in "${!remoteOrder[@]}" do # get key key=${remoteOrder[$i]} # build full url urlFull="${remoteUrl[$key]}"'/'"$repoName"'.git' echo 'Adding remote url' echo " $key" echo " $urlFull" # add main url if [ "$i" = "0" ]; then echo ' [main]' git remote add "$remoteName" "$urlFull" # add secondary url else echo ' [secondary]' # avoid duplicate git remote set-url "$remoteName" --delete "$urlFull" # add git remote set-url "$remoteName" --add "$urlFull" fi done echo $'\nQuerying github\n--------------------' curl \ -u "${remoteUser[github]}":"$(cat "$tokenPath"'github.token.txt')" \ -d '{"name":"'"$repoName"'"}' \ 'https://api.github.com/user/repos' echo $'\nQuerying gitlab\n--------------------' curl \ -H 'PRIVATE-TOKEN: '"$(cat "$tokenPath"'gitlab.token.txt')" \ --data-urlencode 'name='"$repoName" \ --data-urlencode 'public=true' \ 'https://gitlab.com/api/v3/projects' echo $'\nQuerying bitbucket\n--------------------' curl \ -X POST \ -H 'Content-Type: application/json' \ -u "${remoteUser[bitbucket]}":"$(cat "$tokenPath"'bitbucket.token.txt')" \ -d '{"scm":"git", "has_issues":true, "has_wiki":true}' \ 'https://api.bitbucket.org/2.0/repositories/'"${remoteUser[bitbucket]}"'/'"$repoName" fi } >&2 # http://stackoverflow.com/a/31656923/3512867 # http://stackoverflow.com/a/1500592/3512867 export -f gitnew Bonus ----- Updating multiple subfolders to add another remote storage. for i in * do if [ -d $i ]; then # enter subdir cd $i dir=$(basename "$PWD") # user feedback echo $'\n--------------------\nprocessing: '$dir $(gitnew) $(git paa) # alias of "push --all all" # exit subdir cd '..' fi done
2016-10-21 21:17:43 GMT

git bash function gitnew version 20161021-2045, now with BitBucket

See here for an introduction to this topic: [Git bash - Create remote repositories quickly on github and gitlab][1] Updated function to include bitbucket: ```` function gitnew() { # token path tokenPath='P:/' # name of remote remoteName='all' # github user user_github='username' # gitlab user user_gitlab='username' # bitbucket user user_bitbucket='username' ##### no config edits below this point # repo name repoName="$(basename "$PWD")" # check if path exists if [ ! -d "$tokenPath" ] # no path then echo 'error: token path not available' # path available else echo $'\nconfig: github\n--------------------' git remote add "$remoteName" 'git@github.com:'"$user_github"'/'"$repoName"'.git' echo $'\nconfig: gitlab\n--------------------' git remote set-url "$remoteName" --add 'git@gitlab.com:'"$user_gitlab"'/'"$repoName"'.git' echo $'\nconfig: bitbucket\n--------------------' git remote set-url "$remoteName" --add 'git@bitbucket.org:'"$user_bitbucket"'/'"$repoName"'.git' echo $'\nquerying github\n--------------------' curl \ -u "$user_github":"$(cat "$tokenPath"'github.token.txt')" \ 'https://api.github.com/user/repos' \ -d '{"name":"'"$repoName"'"}' echo $'\nquerying gitlab\n--------------------' curl \ -H 'PRIVATE-TOKEN: '"$(cat "$tokenPath"'gitlab.token.txt')" \ 'https://gitlab.com/api/v3/projects' \ --data-urlencode 'name='"$repoName" \ --data-urlencode 'public=true' echo $'\nquerying bitbucket\n--------------------' curl \ -X POST \ -H 'Content-Type: application/json' \ -u "$user_bitbucket":"$(cat "$tokenPath"'bitbucket.token.txt')" \ 'https://api.bitbucket.org/2.0/repositories/'"$user_bitbucket"'/'"$repoName" \ -d '{"scm":"git"}' fi } ```` [1]: http://spenibus.net/b/p/r/Git-bash-Create-remote-repositories-quickly-on-github-and-gitlab
2016-09-02 21:48:45 GMT

Corsair Utility Engine v2 (CUE) - mapping a macro G key to launch a program

Here's what happened -------------------- Having just today come into possession of a Corsair K95 RGB Cherry MX red keyboard, I tried to replicate the setup I had on my Logitech G11 by remapping the macro keys to run various programs, except I could not find how to do so. I even downgraded to CUE v1 at some point because I thought it was simply not possible in v2. Then went I back to v2 on principle and somehow found the solution. Exact version of CUE is `2.4.66`. The solution ------------ >actions > create action > remap key > key function > shortcut Sounds simple when you read it but not exactly intuitive when going through the UI. See the following screenshot for illustration. [![1]][1] Guess we're done here. [1]: http://spenibus.net/f/g/bK/screenshot-20160902-223947-005116.png