Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

shell function for choosing from vi(m) background jobs the preferred job or start a new vim process

View foreground vi(m)
1 2 3 4 5 6 7 8 9
function vi() {
local job_id
job_id=$(jobs|sed -rn "s/\[([0-9])\] *([-+]?) *([Ss]topped|[Ss]uspended).*vim?.*/\1 \2/p"|awk "{if(\$2==\"+\"){id=\$1;exit}else if(\$2==\"-\"){id=\$1;m=\$2}else if(m!=\"-\"){id=\$1}}END{print id}")
if [ ${job_id} ]; then
fg %${job_id}
else
vim
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.