made remove scripts dir (symlinked to ~/.local/)
This commit is contained in:
parent
38bb697154
commit
487aab4fb7
@ -1,25 +0,0 @@
|
|||||||
# bash completion for hugctl
|
|
||||||
|
|
||||||
_hugctl_completions() {
|
|
||||||
local cur
|
|
||||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
|
||||||
|
|
||||||
local blog_dir="$HOME/src/blog"
|
|
||||||
case ${COMP_CWORD} in
|
|
||||||
1)
|
|
||||||
OPTS="new list edit serve kill deploy"
|
|
||||||
compopt -o bashdefault -o default
|
|
||||||
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
|
|
||||||
;;
|
|
||||||
2)
|
|
||||||
case ${COMP_CWORD[2]} in
|
|
||||||
*)
|
|
||||||
COMPREPLY=($(compgen -W "$(find $blog_dir/content/posts/ -iname '*.md' -type f | xargs -I@ basename @)" -- $cur));
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
complete -F _hugctl_completions hugctl
|
|
||||||
@ -1,125 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# hugoctl -- hugo wrapper script to help manage a hugo blog
|
|
||||||
|
|
||||||
# hugo variables (local machine)
|
|
||||||
scriptname=$(basename "$0")
|
|
||||||
blog_dir="$HOME/src/blog" # or the path to your blog
|
|
||||||
local_url="http://localhost:1313/"
|
|
||||||
post_filename=""
|
|
||||||
postname=""
|
|
||||||
full_post_dir=""
|
|
||||||
full_post_url="$local_url"
|
|
||||||
|
|
||||||
|
|
||||||
set_vars() {
|
|
||||||
local arg="$1"
|
|
||||||
|
|
||||||
# handle no argument case
|
|
||||||
if [[ -z "$arg" ]]; then
|
|
||||||
echo -en "Please enter a post title: "
|
|
||||||
read -r arg
|
|
||||||
fi
|
|
||||||
|
|
||||||
# handle extraneous .md file extension
|
|
||||||
if [[ ! "$arg" =~ .md$ ]]; then
|
|
||||||
postname="$arg"
|
|
||||||
else
|
|
||||||
postname="${arg%???}"
|
|
||||||
fi
|
|
||||||
post_filename="$postname.md"
|
|
||||||
|
|
||||||
# hugo post location for server
|
|
||||||
full_post_dir="$blog_dir/content/posts/$post_filename"
|
|
||||||
|
|
||||||
# url for browser
|
|
||||||
full_post_url="$local_url/posts/$postname"
|
|
||||||
}
|
|
||||||
|
|
||||||
hugo_serve() {
|
|
||||||
xdg-open "$full_post_url" &> /dev/null
|
|
||||||
hugo serve -s "$blog_dir"
|
|
||||||
}
|
|
||||||
|
|
||||||
edit_post() {
|
|
||||||
$EDITOR "$full_post_dir"
|
|
||||||
}
|
|
||||||
|
|
||||||
new_post() {
|
|
||||||
hugo new -s "$blog_dir" "posts/$post_filename"
|
|
||||||
edit_post
|
|
||||||
}
|
|
||||||
|
|
||||||
deploy_blog() {
|
|
||||||
if [ -z "$blog_remote_host" ]; then echo "Please set \$blog_remote_host variable"; exit 1; fi
|
|
||||||
if [ -z "$blog_remote_user" ]; then echo "Please set \$blog_remote_user variable"; exit 1; fi
|
|
||||||
if [ -z "$blog_remote_dir" ]; then echo "Please set \$blog_remote_dir variable (relative to \$HOME)"; exit 1; fi
|
|
||||||
|
|
||||||
green="$(tput setaf 2)"
|
|
||||||
reset="$(tput sgr0)"
|
|
||||||
|
|
||||||
printf "%s\n%s\n" "${green}[Deploying]${reset}" "Running \"git pull && hugo\" at \"$blog_remote_user@$blog_remote_host:~/$blog_remote_dir\"..."
|
|
||||||
|
|
||||||
ssh "$blog_remote_user@$blog_remote_host" "(cd \$HOME/$blog_remote_dir && git pull && hugo)"
|
|
||||||
}
|
|
||||||
|
|
||||||
print_help() {
|
|
||||||
printf "%s\n" "Usage: "
|
|
||||||
printf "%s\n\n" "$scriptname [args]"
|
|
||||||
|
|
||||||
printf "%s\n" "Options: "
|
|
||||||
printf "\t%s:\n\t\t%s\n\n" "new-post (aliases: newpost,np,new,n) [post-name]" "create a new post, open editor and live server"
|
|
||||||
printf "\t%s:\n\t\t%s\n\n" "edit-post (alises: edit,ep,e) [post-name]" "edit a post in the content directory"
|
|
||||||
printf "\t%s:\n\t\t%s\n\n" "list-posts (aliases: list,li,lp,ls,l)" "list all posts in content directory"
|
|
||||||
printf "\t%s:\n\t\t%s\n\n" "list-drafts (alises: listdraft,ld)" "list all posts in content directory"
|
|
||||||
printf "\t%s:\n\t\t%s\n\n" "server (alises: serve,s)" "serve blog from your blog directory"
|
|
||||||
printf "\t%s:\n\t\t%s\n\n" "deploy (aliases: dep,d)" "deploy to a remote server"
|
|
||||||
printf "\n"
|
|
||||||
}
|
|
||||||
|
|
||||||
if [[ "$#" -lt 1 ]]; then
|
|
||||||
print_help
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
while (($#)); do
|
|
||||||
case "$1" in
|
|
||||||
new-post|newpost|np|new|n)
|
|
||||||
shift
|
|
||||||
set_vars "$1"
|
|
||||||
new_post "$1"
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
edit-post|edit|ep|e)
|
|
||||||
shift
|
|
||||||
set_vars "$1"
|
|
||||||
edit_post "$1"
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
list-posts|list|li|lp|l|ls)
|
|
||||||
hugo list -s "$blog_dir" all | cut -d, -f1 | tail -n +2
|
|
||||||
# hugo list -s "$blog_dir" all | cut -f1,4 -d, | tail -n +2 | tr ',' ' ' | column -t | sort -hr
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
list-drafts|listdraft|ld)
|
|
||||||
hugo list drafts -s "$blog_dir"
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
server|serve|s)
|
|
||||||
hugo_serve
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
deploy|dep|d)
|
|
||||||
deploy_blog
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
help|-h|--help)
|
|
||||||
print_help
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
print_help
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
|
|
||||||
mkdir -p ~/.rbenv/plugins
|
|
||||||
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
export XMODIFIERS="@im=null" && minecraft-launcher &> /dev/null &
|
|
||||||
Loading…
x
Reference in New Issue
Block a user