diff --git a/.gitignore b/.gitignore index 25bc181..f5d8912 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ zsh/* !tmux tmux/* !tmux/tmux.conf +!tmux/tmux-new-project !tmux/tmux-sessionizer !tmux/tmux-ggclone !tmux/tmux-ssher diff --git a/tmux/tmux-ggclone b/tmux/tmux-ggclone index ca202b3..0bc6569 100755 --- a/tmux/tmux-ggclone +++ b/tmux/tmux-ggclone @@ -1,5 +1,7 @@ #!/usr/bin/env bash +source "$XDG_CONFIG_HOME/zsh/scripts.zsh" + if [[ $# -eq 1 ]]; then selected=$1 else @@ -11,5 +13,4 @@ if [[ -z $selected ]]; then fi ggman clone "$selected" -find -L $GGROOT -mindepth 1 -maxdepth 5 -type d -name .git -prune | xargs -n 1 dirname > "$GGROOT/compiled" - +ggcompile diff --git a/tmux/tmux-new-project b/tmux/tmux-new-project new file mode 100755 index 0000000..e44dd03 --- /dev/null +++ b/tmux/tmux-new-project @@ -0,0 +1,50 @@ +#!/usr/bin/env bash + +if [[ -z ${NAME:+x} ]]; then + echo "missing name" + sleep 2 + exit 1 +fi + +source "$XDG_CONFIG_HOME/zsh/scripts.zsh" + +read -p "name: " project_name + +if [[ -z $project_name ]]; then + exit 0 +fi + +if [[ -d "$GGROOT/no-remote/$project_name" ]]; then + exit 0 +fi + +project="$GGROOT/no-remote/$project_name" +git init $project +echo "# $project_name" >>"$project/README.md" + +gitignore_template=$( + find "$GGROOT"/github.com/github/gitignore/*.gitignore -exec basename {} \; \ + | sed 's/\(.*\)\.gitignore/\1/' \ + | fzf --cycle --bind 'tab:toggle-up,btab:toggle-down' +) + +if ! [[ -z $gitignore_template ]]; then + gitignore="$GGROOT/github.com/github/gitignore/$gitignore_template.gitignore" + echo "$gitignore" + echo "$project/.gitignore" + cat "$gitignore" >>"$project/.gitignore" +fi + +license_template=$( + find "$GGROOT"/git.janezic.dev/janezicmatej/license/*.license -exec basename {} \; \ + | sed 's/\(.*\)\.license/\1/' \ + | fzf --cycle --bind 'tab:toggle-up,btab:toggle-down' +) + +if ! [[ -z $license_template ]]; then + license="$GGROOT/git.janezic.dev/janezicmatej/license/$license_template.license" + export YEAR="$(date '+%Y')" + envsubst <"$license" >"$project/LICENSE" +fi + +ggcompile diff --git a/tmux/tmux.conf b/tmux/tmux.conf index c342fe2..144dc45 100644 --- a/tmux/tmux.conf +++ b/tmux/tmux.conf @@ -37,4 +37,4 @@ bind-key F run-shell "tmux neww ~/.config/tmux/tmux-ssher" bind-key T run-shell "tmux neww ~/.config/tmux/tmux-sessionizer ~/temp" bind-key R run-shell "tmux neww ~/.config/tmux/tmux-sessionizer ~" bind-key G run-shell "tmux neww ~/.config/tmux/tmux-ggclone" - +bind-key N run-shell "tmux neww ~/.config/tmux/tmux-new-project"