pyratelog

personal blog
git clone git://git.pyratebeard.net/pyratelog.git
Log | Files | Refs | README

commit 6cd69e0f5847ff94be0dc609f6b0197ca01c0414
parent 78a0ef1c5decbceac73c2d73d4365e8b3f71c24d
Author: pyratebeard <root@pyratebeard.net>
Date:   Thu, 20 Oct 2022 22:54:17 +0100

Merge branch 'main' into as_a_matter_of_course

Diffstat:
MMakefile | 10++++++++++
Aentry/20221020-shell_shocked.md | 28++++++++++++++++++++++++++++
Mscripts/draft | 6++++--
3 files changed, 42 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile @@ -18,6 +18,16 @@ endif endif endif +ifeq ($(DRAFT_ARGS), ) + DRAFT_ARGS := $(shell git branch --show-current) +endif +ifeq ($(VIEW_ARGS), ) + VIEW_ARGS := $(shell git branch --show-current) +endif +ifeq ($(PUB_ARGS), ) + PUB_ARGS := $(shell git branch --show-current) +endif + prog: # ... # ... diff --git a/entry/20221020-shell_shocked.md b/entry/20221020-shell_shocked.md @@ -0,0 +1,28 @@ +I didn't know that [vim](TK){target="_blank" rel="noreferrer"} could open a terminal in a window split. + +Usually I have vim in a [tmux](TK){target="_blank" rel="noreferrer"} session so can split the tmux window to get a terminal. Occasionally I would use `:shell`, which opens a shell in the current terminal but backgrounds vim so you have to exit the shell to return. This is useful but it can be beneficial to keep your buffer open while running a command, and vim may not be in a tmux session. + +As of vim 8 the terminal feature is natively supported. Neovim also has this feature natively. To see if your vim has this feature incant the following +``` +:echo has('terminal') +``` + +If the output is `1` then you have it. + +To simply open a terminal in a split incant +``` +:terminal +``` +or +``` +:term +``` + +You can append a command, which once completed will open the output in a buffer ready for editing. + +This is a cool feature, and I will probably use it quite a bit. It is great fun to be constantly learning vim, even finding features that have been around for a while. + +For more information on the terminal feature check out the help page +``` +:help terminal +``` diff --git a/scripts/draft b/scripts/draft @@ -6,8 +6,8 @@ POST="entry/${TITLE}.md" # checkout the correct branch git branch | grep ${TITLE} && \ - git checkout ${TITLE} || \ - git checkout -b ${TITLE} + git checkout -q ${TITLE} || \ + $(git checkout -q main && git checkout -q -b ${TITLE}) || exit 1 # if post file does not exist yet touch it [ -f "${POST}" ] || touch "${POST}" @@ -16,5 +16,7 @@ git branch | grep ${TITLE} && \ vim "${POST}" # when vim closes add and commit the changes +# if there are any +git status | grep "${POST}" || exit 0 git add "${POST}" git commit -S -m "${TITLE}"