Add branchname and jira scripts, update nvimrc
This commit is contained in:
parent
c76f2ca656
commit
1aad7008c7
|
@ -25,7 +25,7 @@
|
|||
drb = !git diff $(git rb)
|
||||
ds = diff --staged
|
||||
f = fetch
|
||||
fixom = rebase -i --autosquash origin/master
|
||||
fixom = !sh -c 'git fetch && git rebase -i --autosquash origin/master'
|
||||
fixup = rebase -i --autosquash
|
||||
l = log
|
||||
ll = log --oneline -n 5
|
||||
|
@ -47,7 +47,7 @@
|
|||
rc = rebase --continue
|
||||
re = rebase
|
||||
rh = reset --hard
|
||||
rom = rebase origin/master
|
||||
rom = !sh -c 'git fetch && git rebase origin/master'
|
||||
rr = !git reset --hard $(git rb)
|
||||
s = status
|
||||
shp = show -p
|
||||
|
|
22
nvimrc
22
nvimrc
|
@ -140,6 +140,7 @@ nnoremap <leader>m :marks<cr>
|
|||
nnoremap <leader>v :vsplit<cr>
|
||||
nnoremap <leader>s :split<cr>
|
||||
nnoremap <leader>rp "_dd<bar>P
|
||||
nnoremap <leader>dq ggVG"_d:wq<cr>
|
||||
|
||||
lua <<EOF
|
||||
function _G.dump(...)
|
||||
|
@ -150,6 +151,12 @@ end
|
|||
|
||||
function _G.insert_uuid()
|
||||
local uuid = vim.call("system", "uuidprint")
|
||||
local errcode = vim.v.shell_error
|
||||
if errcode ~= 0 then
|
||||
vim.api.nvim_err_writeln("uuidprint returned error code: " .. errcode)
|
||||
return
|
||||
end
|
||||
|
||||
vim.call("setreg", "u", uuid)
|
||||
vim.api.nvim_command([[normal! "up]])
|
||||
end
|
||||
|
@ -157,6 +164,21 @@ end
|
|||
vim.api.nvim_set_keymap("n", "<leader>uu", [[:lua _G.insert_uuid()<cr>]], {noremap = true, silent = true})
|
||||
vim.api.nvim_set_keymap("i", "<c-d><c-u>", [[<esc>:lua _G.insert_uuid()<cr>a]], {noremap = true, silent = true})
|
||||
|
||||
function _G.insert_jira_url()
|
||||
local url = vim.call("system", "jira")
|
||||
local errcode = vim.v.shell_error
|
||||
if errcode ~= 0 then
|
||||
vim.api.nvim_err_writeln("jira returned error code: " .. errcode)
|
||||
return
|
||||
end
|
||||
|
||||
vim.call("setreg", "u", url)
|
||||
vim.api.nvim_command([[normal! "up]])
|
||||
end
|
||||
|
||||
vim.api.nvim_set_keymap("n", "<leader>ji", [[:lua _G.insert_jira_url()<cr>]], {noremap = true, silent = true})
|
||||
vim.api.nvim_set_keymap("i", "<c-d><c-j>", [[<esc>:lua _G.insert_jira_url()<cr>a]], {noremap = true, silent = true})
|
||||
|
||||
_G._test_cmd_to_wins = {}
|
||||
|
||||
_G._build_test_cmd = function()
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# branchname - print current branchname, including during rebase
|
||||
#
|
||||
# https://stackoverflow.com/questions/34213120/find-branch-name-during-git-rebase
|
||||
|
||||
set -e
|
||||
|
||||
branchname=$(git bn)
|
||||
if [ "$branchname" = "HEAD" ]; then
|
||||
branchoutput=$(git branch --list | grep rebasing)
|
||||
if [ ! $? -eq 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
regex="rebasing ([^)]+)\)"
|
||||
if [[ $branchoutput =~ $regex ]]; then
|
||||
branchname="${BASH_REMATCH[1]}"
|
||||
else
|
||||
exit 2
|
||||
fi
|
||||
fi
|
||||
|
||||
printf $branchname
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
set -e
|
||||
|
||||
if [ "$1" == "-s" ]; then
|
||||
if [ "$1" = "-s" ]; then
|
||||
args="--short"
|
||||
fi
|
||||
|
||||
|
|
16
script/jira
16
script/jira
|
@ -9,7 +9,12 @@ if [ -z "$JIRADOMAIN" ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
branchname="$(git bn)"
|
||||
branchname="$(branchname)"
|
||||
if [ ! $? -eq 0 ]; then
|
||||
echo "branchname returned exit code: $?"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! echo "$branchname" | grep -q "/"; then
|
||||
echo "no ticket number found in branch name: $branchname"
|
||||
exit 1
|
||||
|
@ -17,10 +22,17 @@ fi
|
|||
|
||||
ticket=$(echo "$branchname" | cut -d "/" -f1 | tr '[:lower:]' '[:upper:]')
|
||||
|
||||
url="$JIRADOMAIN/browse/$ticket"
|
||||
|
||||
if [ "$1" == "-b" ]; then
|
||||
if [ $(uname -s) = "Linux" ]; then
|
||||
progname="xdg-open"
|
||||
else
|
||||
progname="open" # macOS
|
||||
fi
|
||||
|
||||
eval "$progname $JIRADOMAIN/browse/$ticket"
|
||||
eval "$progname $url"
|
||||
exit $?
|
||||
fi
|
||||
|
||||
printf $url
|
||||
|
|
Loading…
Reference in New Issue