diff --git a/.bin/.t b/.bin/.t index 8abea12..2542bfc 100755 --- a/.bin/.t +++ b/.bin/.t @@ -2,6 +2,7 @@ declare -A mapper=( ["nix"]="nix" + ["sh"]="sh" ) declare -A edit_file=( @@ -20,28 +21,36 @@ then exit fi -target="${mapper["$1"]}" -if [ -z "$target" ] +dest="." +if [ -n "$2" ] +then + dest="$2" +fi + +source="${mapper["$1"]}" +if [ -z "$source" ] then echo "Template not found. Use --list (-l) to show all options." exit 1 fi -target="$XDG_CONFIG_HOME/templates/$target" -if [ -f "$target" ] +source="$XDG_CONFIG_HOME/templates/$source" +if [ -f "$source" ] then - cp -i "$target" . + cp -i "$source" "$dest" echo "Template copied." -elif [ -d "$target" ] + source_edit=$dest +elif [ -d "$source" ] then - cp -irT "$target" . + cp -irT "$source" "$dest" echo "Template copied." + source_edit=$dest/${edit_file["$1"]} else echo "Error copying template." exit 1 fi -if [ -n "${edit_file["$1"]}" ] +if [ -n "$source_edit" ] then - $EDITOR "${edit_file["$1"]}" + $EDITOR "$source_edit" fi diff --git a/.config/completionsrc b/.config/completionsrc index f15f542..f208638 100644 --- a/.config/completionsrc +++ b/.config/completionsrc @@ -16,17 +16,19 @@ complete -F _dote_completions ".e" _dott_completions() { - if [ "${#COMP_WORDS[@]}" == "1" ]; then - return + if [ "${#COMP_WORDS[@]}" == "2" ]; then + COMPREPLY=() + while IFS='' read -r line + do + COMPREPLY+=("$line") + done < <(compgen -W "$(.t -l)" "${COMP_WORDS[1]}") fi - COMPREPLY=() - while IFS='' read -r line - do - COMPREPLY+=("$line") - done < <(compgen -W "$(.t -l)" "${COMP_WORDS[1]}") + if [ "${#COMP_WORDS[@]}" == "3" ]; then + compgen -f "${COMP_WORDS[2]}" + fi } -complete -F _dott_completions ".t" +complete -o filenames -F _dott_completions ".t" _autostart_manage_completions() { diff --git a/.config/templates/nix/.envrc b/.config/templates/nix/.envrc new file mode 100644 index 0000000..1d953f4 --- /dev/null +++ b/.config/templates/nix/.envrc @@ -0,0 +1 @@ +use nix diff --git a/.config/templates/nix/shell.nix b/.config/templates/nix/shell.nix new file mode 100644 index 0000000..e11ba4b --- /dev/null +++ b/.config/templates/nix/shell.nix @@ -0,0 +1,5 @@ +with import {}; +mkShell { + nativeBuildInputs = [ + ]; +} diff --git a/.config/templates/sh b/.config/templates/sh new file mode 100755 index 0000000..b1a6f50 --- /dev/null +++ b/.config/templates/sh @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +