feat: Add support to gui based editor (--wait flag)
This commit is contained in:
parent
7a90bcf45b
commit
32e8874c91
3 changed files with 63 additions and 2 deletions
43
Justfile
Normal file
43
Justfile
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
|
||||||
|
# Build for all supported platforms and architectures
|
||||||
|
build-all:
|
||||||
|
@echo "Building for all platforms and architectures..."
|
||||||
|
just build-linux-amd64
|
||||||
|
just build-linux-arm64
|
||||||
|
just build-darwin-amd64
|
||||||
|
just build-darwin-arm64
|
||||||
|
just build-windows-amd64
|
||||||
|
just build-windows-arm64
|
||||||
|
@echo "All builds completed"
|
||||||
|
|
||||||
|
# Linux builds
|
||||||
|
build-linux-amd64:
|
||||||
|
@echo "Building for Linux/amd64..."
|
||||||
|
GOOS=linux GOARCH=amd64 go build -o bin/renamedit-linux-amd64
|
||||||
|
|
||||||
|
build-linux-arm64:
|
||||||
|
@echo "Building for Linux/arm64..."
|
||||||
|
GOOS=linux GOARCH=arm64 go build -o bin/renamedit-linux-arm64
|
||||||
|
|
||||||
|
# macOS builds
|
||||||
|
build-darwin-amd64:
|
||||||
|
@echo "Building for macOS/amd64..."
|
||||||
|
GOOS=darwin GOARCH=amd64 go build -o bin/renamedit-darwin-amd64
|
||||||
|
|
||||||
|
build-darwin-arm64:
|
||||||
|
@echo "Building for macOS/arm64..."
|
||||||
|
GOOS=darwin GOARCH=arm64 go build -o bin/renamedit-darwin-arm64
|
||||||
|
|
||||||
|
# Windows builds
|
||||||
|
build-windows-amd64:
|
||||||
|
@echo "Building for Windows/amd64..."
|
||||||
|
GOOS=windows GOARCH=amd64 go build -o bin/renamedit-windows-amd64.exe
|
||||||
|
|
||||||
|
build-windows-arm64:
|
||||||
|
@echo "Building for Windows/arm64..."
|
||||||
|
GOOS=windows GOARCH=arm64 go build -o bin/renamedit-windows-arm64.exe
|
||||||
|
|
||||||
|
# Clean build artifacts
|
||||||
|
clean:
|
||||||
|
@echo "Cleaning build artifacts..."
|
||||||
|
rm -rf bin/*
|
||||||
19
main.go
19
main.go
|
|
@ -58,10 +58,25 @@ func main() {
|
||||||
// Open temporary file with editor
|
// Open temporary file with editor
|
||||||
editor := os.Getenv("EDITOR")
|
editor := os.Getenv("EDITOR")
|
||||||
if editor == "" {
|
if editor == "" {
|
||||||
editor = "vim" // Default editor
|
editor = "vim"
|
||||||
|
}
|
||||||
|
|
||||||
|
editorFlags := map[string]string{
|
||||||
|
"code": "--wait",
|
||||||
|
"subl": "--wait",
|
||||||
|
"zeditor": "--wait",
|
||||||
|
"atom": "--wait",
|
||||||
|
"gedit": "--standalone",
|
||||||
|
}
|
||||||
|
|
||||||
|
var cmd *exec.Cmd
|
||||||
|
if flag, exists := editorFlags[editor]; exists {
|
||||||
|
cmd = exec.Command(editor, flag, tmpFile.Name())
|
||||||
|
} else {
|
||||||
|
// Default case for vim, nano, emacs, etc. that wait by default
|
||||||
|
cmd = exec.Command(editor, tmpFile.Name())
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := exec.Command(editor, tmpFile.Name())
|
|
||||||
cmd.Stdin = os.Stdin
|
cmd.Stdin = os.Stdin
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
|
|
|
||||||
3
readme.md
Normal file
3
readme.md
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# `renamedit`
|
||||||
|
|
||||||
|
Rename files with your favourite editor
|
||||||
Loading…
Add table
Add a link
Reference in a new issue