From 68344d6643c07ce3b74e74e56c80625c0fbbde17 Mon Sep 17 00:00:00 2001 From: BarbUk Date: Mon, 9 Mar 2020 17:09:50 +0400 Subject: [PATCH] Check if snippet dir exists and create first snippet --- snippy | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/snippy b/snippy index cccdda7..f8a717c 100755 --- a/snippy +++ b/snippy @@ -136,6 +136,15 @@ move_cursor() { fi } +init() { + # Check + if [[ ! -d "$snippets_directory" ]]; then + mkdir -p "$snippets_directory" + echo "$snippets_directory created" + echo "hi it is \$(date)" > "$snippets_directory/test" + fi +} + run() { cd "${snippets_directory}" || exit @@ -267,4 +276,4 @@ run() { echo -ne "$current_clipboard" | xsel --clipboard --input } -run +init && run