Skip to content

Commit 93c49f1

Browse files
committed
feat: improve install experience
1 parent ba3beb3 commit 93c49f1

File tree

7 files changed

+93
-6
lines changed

7 files changed

+93
-6
lines changed

.envrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
eval $(gimme 1.18.3)
1+
eval $(gimme 1.20)
2+
PATH_add dist

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
.idea
22
.vscode
3-
goprompt
3+
dist

.goreleaser.yaml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
before:
2+
hooks:
3+
- go mod tidy
4+
builds:
5+
- main: ./cmd/goprompt
6+
binary: frk
7+
env:
8+
- CGO_ENABLED=0
9+
goos:
10+
- linux
11+
- darwin
12+
archives:
13+
- replacements:
14+
darwin: Darwin
15+
linux: Linux
16+
windows: Windows
17+
386: i386
18+
amd64: x86_64
19+
format: binary
20+
wrap_in_directory: false
21+
22+
checksum:
23+
name_template: 'checksums.txt'
24+
snapshot:
25+
name_template: "{{ incpatch .Version }}-next"
26+
27+
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
28+
# vim: set ts=2 sw=2 tw=0 fo=cnqoj

Makefile

+18-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
export prefix?=$(HOME)/.local
2+
export bindir?=$(prefix)/bin
3+
14
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
25
CURRENT_DIR := $(patsubst %/,%,$(dir $(MKFILE_PATH)))
36

@@ -6,13 +9,22 @@ ZSH_PROMPT_SETUP_SCRIPT := $(CURRENT_DIR)/plugin/zsh/prompt_asynczle_setup.zsh
69
USR_BIN_DIR := $(HOME)/bin
710
USR_ZSH_DIR := $(HOME)/.local/share/zsh-funcs
811

12+
.PHONY: publish
13+
publish:
14+
goreleaser release --rm-dist
15+
16+
.PHONY: release
17+
release:
18+
goreleaser release --rm-dist --snapshot --skip-publish
19+
20+
.PHONY: build
921
build:
10-
go build -o "goprompt" ./cmd/goprompt
22+
goreleaser build --rm-dist --snapshot --single-target --output dist/goprompt
1123

1224
.PHONY: install
13-
install:
25+
install: build
1426
mkdir -p "$(USR_BIN_DIR)"
15-
go build -o "$(USR_BIN_DIR)/goprompt" ./cmd/goprompt
27+
cp dist/goprompt "$(USR_BIN_DIR)/goprompt"
1628
mkdir -p "$(USR_ZSH_DIR)"
1729
cp "$(ZSH_PROMPT_SETUP_SCRIPT)" "$(USR_ZSH_DIR)/prompt_asynczle_setup"
1830
$(MAKE) setup
@@ -42,3 +54,6 @@ try: install
4254
@echo '>> FOR DEVELOPMENT ONLY <<'
4355
ZSH_DISABLE_PROMPT=Y ZSH_EXTRA_SOURCE="$(ZSH_PROMPT_SETUP_SCRIPT)" zsh
4456

57+
.PHONY: clean
58+
clean:
59+
rm -rf dist

cmd/goprompt/cmdInstall.go

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"github.com/spf13/cobra"
6+
)
7+
8+
var (
9+
cmdInstall = &cobra.Command{
10+
Use: "install",
11+
Short: "install the integration",
12+
}
13+
)
14+
15+
func init() {
16+
cmdInstall.RunE = cmdInstallRun
17+
}
18+
19+
// TODO: bundle in the plugin directory, and provide a way to extract it into users directory of choice.
20+
21+
func cmdInstallRun(command *cobra.Command, args []string) error {
22+
fmt.Println(`
23+
# SETUP:
24+
# ------------------------------------------------------------------------------
25+
# Assuming GoPrompt is installed in $(USR_BIN_DIR)
26+
# and zsh func in $(USR_ZSH_DIR)
27+
# ------------------------------------------------------------------------------
28+
# $$ make setup >> ~/.zshrc"
29+
# ------------------------------------------------------------------------------
30+
# Add this to your ~/.zshenv
31+
# ------------------------------------------------------------------------------
32+
33+
# PROMPT_ASYNC_ZLE: ------------------------------------------------------------
34+
path+=( "$(USR_BIN_DIR)" )
35+
fpath+=( "$(USR_ZSH_DIR)" )
36+
autoload -Uz promptinit
37+
promptinit && prompt_asynczle_setup
38+
# ------------------------------------------------------------------------------
39+
`)
40+
return nil
41+
}

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/NonLogicalDev/shell.async-goprompt
22

3-
go 1.18
3+
go 1.20
44

55
require (
66
github.com/gookit/color v1.5.1

plugin/zsh/prompt_asynczle_setup.zsh

+2
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ __zle_async_dispatch() {
126126
__zle_async_detach "$OLD_ZLE_FD" 2>/dev/null
127127
fi
128128

129+
local ZLE_FD
130+
129131
# Create File Descriptor and attach to async command
130132
exec {ZLE_FD}< <( "${command[@]}" )
131133

0 commit comments

Comments
 (0)