From f167ebb4a12d8645c8a12d51c2ecbcbb0e982481 Mon Sep 17 00:00:00 2001 From: James Patrick Date: Wed, 20 Nov 2019 17:24:15 -0500 Subject: [PATCH 1/6] Grouped commands, plugins, and themes. Basically just relocated the command out of the middle of the plugins. --- zsh/zplug | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/zsh/zplug b/zsh/zplug index 16eb68a..f3e685b 100644 --- a/zsh/zplug +++ b/zsh/zplug @@ -2,6 +2,18 @@ source ${ZPLUG_HOME}/init.zsh +zplug "junegunn/fzf-bin", \ + from:gh-r, \ + as:command, \ + rename-to:fzf + +zplug "zdharma/zsh-diff-so-fancy", \ + as:command, \ + use:"bin/{git-dsf,diff-so-fancy}" + +zplug "${ZDIR}/modules/bin/", \ + as:command, \ + use:"*" zplug "zdharma/fast-syntax-highlighting", \ as:plugin, \ defer:2 @@ -24,17 +36,6 @@ zplug "junegunn/fzf", \ use:"shell/*.zsh", \ defer:2 -zplug "junegunn/fzf-bin", \ - from:gh-r, \ - as:command, \ - rename-to:fzf - -zplug "zdharma/zsh-diff-so-fancy", \ - as:command, \ - use:"bin/{git-dsf,diff-so-fancy}" - -zplug "${ZDIR}/modules/bin/", \ - as:command, \ use:"*" zplug "${ZDIR}/modules/history/", \ From 5f28729298601a3b2b2ae49efd3402f732f6a28b Mon Sep 17 00:00:00 2001 From: James Patrick Date: Fri, 22 Nov 2019 14:52:45 -0500 Subject: [PATCH 2/6] A push over script that doesn't hardcode tokens. --- zsh/modules/bin/tellme | 44 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 zsh/modules/bin/tellme diff --git a/zsh/modules/bin/tellme b/zsh/modules/bin/tellme new file mode 100755 index 0000000..e26734e --- /dev/null +++ b/zsh/modules/bin/tellme @@ -0,0 +1,44 @@ +#! /bin/bash + +# Load config file if it exist. +export CONFIG=${XDG_CONFIG_HOME:-~/.config}/tellme/creds +[ -f $CONFIG ] && export $(grep -v '^#' $CONFIG | xargs) + +usage(){ + echo "You have to tell me something" + exit -1 +} + +setup(){ + echo "It doesn't look like I've been setup yet. I will need the Application & User tokens." + read -r -p " Application Token: " APPLICATION_TOKEN + read -r -p " User Token: " USER_TOKEN + mkdir -p $(dirname $CONFIG) + cat <<-EOF > $CONFIG + application_token=$APPLICATION_TOKEN + user_token=$USER_TOKEN + EOF + chmod 600 $CONFIG + echo "Config setup at $CONFIG" + echo +} + +if [[ -z $application_token || -z $user_token ]] ; then + setup + export $(grep -v '^#' $CONFIG | xargs) +fi + +if [[ $# -eq 0 ]] ; then + usage +fi + +message=$@ +curl -s \ + --form-string "token=$application_token" \ + --form-string "user=$user_token" \ + --form-string "message=$message" \ + https://api.pushover.net/1/messages.json 1>/dev/null + +[[ $? -eq 0 ]] && echo "message sent" || echo "ERROR SENDING NOTIFICATION" + +printf '\a' #Rings bell From 569598683e198704cfb02b9832b5972df532ea4d Mon Sep 17 00:00:00 2001 From: James Patrick Date: Fri, 22 Nov 2019 14:53:31 -0500 Subject: [PATCH 3/6] Fixed bad XDG CONFIG value. Not sure why I thought it would be DIR instead of HOME but I blame poorly executed theft. --- lib/shared.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/shared.mk b/lib/shared.mk index 1dcdb98..a2459de 100644 --- a/lib/shared.mk +++ b/lib/shared.mk @@ -15,7 +15,7 @@ return_val_truthy := && echo true || echo false cmd_exist = $(shell (($$+commands[$1])) $(return_val_truthy) ) # Shortcut for the XDG dir if it exist. default to ~/.confg -XDG_DIR := $${XDG_CONFIG_DIR:-~/.config} +XDG_DIR := $${XDG_CONFIG_HOME:-~/.config} # Some things will OS specific. # With this you can use `$(IS_MAC) && echo "I'm a Mac" || echo "I'm not a Mac"` From a44bfd1a6e462be156442d22823442a4d7b03f27 Mon Sep 17 00:00:00 2001 From: James Patrick Date: Fri, 22 Nov 2019 14:55:05 -0500 Subject: [PATCH 4/6] Specified as and defer tags for autoenv. --- zsh/zplug | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/zsh/zplug b/zsh/zplug index f3e685b..666468f 100644 --- a/zsh/zplug +++ b/zsh/zplug @@ -26,7 +26,9 @@ zplug "zsh-users/zsh-history-substring-search", \ as:plugin, \ defer:2 -zplug "zpm-zsh/autoenv" +zplug "zpm-zsh/autoenv", \ + as:plugin, \ + defer:2 zplug "zsh-users/zsh-autosuggestions", \ as:plugin, \ From 73c40c8e4b4f00379f11f702a06c7f9047cfb0b4 Mon Sep 17 00:00:00 2001 From: James Patrick Date: Fri, 22 Nov 2019 14:56:38 -0500 Subject: [PATCH 5/6] Formatting --- zsh/modules/bin/tellme | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zsh/modules/bin/tellme b/zsh/modules/bin/tellme index e26734e..0de3437 100755 --- a/zsh/modules/bin/tellme +++ b/zsh/modules/bin/tellme @@ -1,7 +1,8 @@ #! /bin/bash -# Load config file if it exist. export CONFIG=${XDG_CONFIG_HOME:-~/.config}/tellme/creds + +# Load config file if it exist. [ -f $CONFIG ] && export $(grep -v '^#' $CONFIG | xargs) usage(){ From a1e365546beda35f9440dba79eda5372dcaf36e6 Mon Sep 17 00:00:00 2001 From: James Patrick Date: Fri, 22 Nov 2019 14:57:08 -0500 Subject: [PATCH 6/6] Tellme script can now tell if post failed. This is a very fragile implementation of this, but I didn't want to add any dependencies to this script since I want it to be able to portable above all else. If anyone has a better solution I would love to hear it. --- zsh/modules/bin/tellme | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zsh/modules/bin/tellme b/zsh/modules/bin/tellme index 0de3437..48fe3e2 100755 --- a/zsh/modules/bin/tellme +++ b/zsh/modules/bin/tellme @@ -38,7 +38,8 @@ curl -s \ --form-string "token=$application_token" \ --form-string "user=$user_token" \ --form-string "message=$message" \ - https://api.pushover.net/1/messages.json 1>/dev/null + https://api.pushover.net/1/messages.json \ + | grep "\"status\":1," 1>/dev/null [[ $? -eq 0 ]] && echo "message sent" || echo "ERROR SENDING NOTIFICATION"