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)
|
drb = !git diff $(git rb)
|
||||||
ds = diff --staged
|
ds = diff --staged
|
||||||
f = fetch
|
f = fetch
|
||||||
fixom = rebase -i --autosquash origin/master
|
fixom = !sh -c 'git fetch && git rebase -i --autosquash origin/master'
|
||||||
fixup = rebase -i --autosquash
|
fixup = rebase -i --autosquash
|
||||||
l = log
|
l = log
|
||||||
ll = log --oneline -n 5
|
ll = log --oneline -n 5
|
||||||
|
@ -47,7 +47,7 @@
|
||||||
rc = rebase --continue
|
rc = rebase --continue
|
||||||
re = rebase
|
re = rebase
|
||||||
rh = reset --hard
|
rh = reset --hard
|
||||||
rom = rebase origin/master
|
rom = !sh -c 'git fetch && git rebase origin/master'
|
||||||
rr = !git reset --hard $(git rb)
|
rr = !git reset --hard $(git rb)
|
||||||
s = status
|
s = status
|
||||||
shp = show -p
|
shp = show -p
|
||||||
|
|
30
nvimrc
30
nvimrc
|
@ -140,6 +140,7 @@ nnoremap <leader>m :marks<cr>
|
||||||
nnoremap <leader>v :vsplit<cr>
|
nnoremap <leader>v :vsplit<cr>
|
||||||
nnoremap <leader>s :split<cr>
|
nnoremap <leader>s :split<cr>
|
||||||
nnoremap <leader>rp "_dd<bar>P
|
nnoremap <leader>rp "_dd<bar>P
|
||||||
|
nnoremap <leader>dq ggVG"_d:wq<cr>
|
||||||
|
|
||||||
lua <<EOF
|
lua <<EOF
|
||||||
function _G.dump(...)
|
function _G.dump(...)
|
||||||
|
@ -150,6 +151,12 @@ end
|
||||||
|
|
||||||
function _G.insert_uuid()
|
function _G.insert_uuid()
|
||||||
local uuid = vim.call("system", "uuidprint")
|
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.call("setreg", "u", uuid)
|
||||||
vim.api.nvim_command([[normal! "up]])
|
vim.api.nvim_command([[normal! "up]])
|
||||||
end
|
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("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})
|
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._test_cmd_to_wins = {}
|
||||||
|
|
||||||
_G._build_test_cmd = function()
|
_G._build_test_cmd = function()
|
||||||
|
@ -677,10 +699,10 @@ require 'compe'.setup {
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
inoremap <silent><expr> <C-y> compe#confirm('<C-y>')
|
inoremap <silent><expr> <C-y> compe#confirm('<C-y>')
|
||||||
inoremap <silent><expr> <C-e> compe#close('<C-e>')
|
inoremap <silent><expr> <C-e> compe#close('<C-e>')
|
||||||
inoremap <silent><expr> <C-f> compe#scroll({ 'delta': +4 })
|
inoremap <silent><expr> <C-f> compe#scroll({ 'delta': +4 })
|
||||||
inoremap <silent><expr> <C-d> compe#scroll({ 'delta': -4 })
|
inoremap <silent><expr> <C-d> compe#scroll({ 'delta': -4 })
|
||||||
|
|
||||||
" TAB navigation support:
|
" TAB navigation support:
|
||||||
lua <<EOF
|
lua <<EOF
|
||||||
|
|
|
@ -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
|
set -e
|
||||||
|
|
||||||
if [ "$1" == "-s" ]; then
|
if [ "$1" = "-s" ]; then
|
||||||
args="--short"
|
args="--short"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
24
script/jira
24
script/jira
|
@ -9,7 +9,12 @@ if [ -z "$JIRADOMAIN" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
branchname="$(git bn)"
|
branchname="$(branchname)"
|
||||||
|
if [ ! $? -eq 0 ]; then
|
||||||
|
echo "branchname returned exit code: $?"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
if ! echo "$branchname" | grep -q "/"; then
|
if ! echo "$branchname" | grep -q "/"; then
|
||||||
echo "no ticket number found in branch name: $branchname"
|
echo "no ticket number found in branch name: $branchname"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -17,10 +22,17 @@ fi
|
||||||
|
|
||||||
ticket=$(echo "$branchname" | cut -d "/" -f1 | tr '[:lower:]' '[:upper:]')
|
ticket=$(echo "$branchname" | cut -d "/" -f1 | tr '[:lower:]' '[:upper:]')
|
||||||
|
|
||||||
if [ $(uname -s) = "Linux" ]; then
|
url="$JIRADOMAIN/browse/$ticket"
|
||||||
progname="xdg-open"
|
|
||||||
else
|
if [ "$1" == "-b" ]; then
|
||||||
progname="open" # macOS
|
if [ $(uname -s) = "Linux" ]; then
|
||||||
|
progname="xdg-open"
|
||||||
|
else
|
||||||
|
progname="open" # macOS
|
||||||
|
fi
|
||||||
|
|
||||||
|
eval "$progname $url"
|
||||||
|
exit $?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
eval "$progname $JIRADOMAIN/browse/$ticket"
|
printf $url
|
||||||
|
|
Loading…
Reference in New Issue