Skip to content
Myr

main.go

This file

Path

main.go

115 lines · 2.3 KiB · Go

Last changed by

0.74.0Junegunn Choibefore adoption6765f46

History of this file

Take it

The walk stopped after 200 commits: lines older than 76efddd point at it.

bash: shift-delete to delete history entries during CTRL-RJunegunn Choibefore adoption76efddd

lines 1–13why, one step back
1package main
23import (4 _ "embed"5 "fmt"6 "os"7 "os/exec"8 "strings"910 fzf "github.com/junegunn/fzf/src"11 "github.com/junegunn/fzf/src/protector"12)13

0.74.0Junegunn Choibefore adoption6765f46

line 14why, one step back
14var version = "0.74"

bash: shift-delete to delete history entries during CTRL-RJunegunn Choibefore adoption76efddd

lines 15–31why, one step back
15var revision = "devel"
1617//go:embed shell/key-bindings.bash18var bashKeyBindings []byte1920//go:embed shell/completion.bash21var bashCompletion []byte2223//go:embed shell/key-bindings.zsh24var zshKeyBindings []byte2526//go:embed shell/completion.zsh27var zshCompletion []byte2829//go:embed shell/key-bindings.fish30var fishKeyBindings []byte31

shell: nushell integration scripts (#4630)Simon Désaulniersbefore adoption290b18d

lines 32–37why, one step back
32//go:embed shell/key-bindings.nu
33var nushellKeyBindings []byte3435//go:embed shell/completion.nu36var nushellCompletion []byte37

bash: shift-delete to delete history entries during CTRL-RJunegunn Choibefore adoption76efddd

lines 38–77why, one step back
38//go:embed shell/completion.fish
39var fishCompletion []byte4041//go:embed man/man1/fzf.142var manPage []byte4344func printScript(label string, content []byte) {45 fmt.Println("### " + label + " ###")46 fmt.Println(strings.TrimSpace(string(content)))47 fmt.Println("### end: " + label + " ###")48}4950func exit(code int, err error) {51 if code == fzf.ExitError && err != nil {52 fmt.Fprintln(os.Stderr, err.Error())53 }54 os.Exit(code)55}5657func main() {58 protector.Protect()5960 options, err := fzf.ParseOptions(true, os.Args[1:])61 if err != nil {62 exit(fzf.ExitError, err)63 return64 }65 if options.Bash {66 printScript("key-bindings.bash", bashKeyBindings)67 printScript("completion.bash", bashCompletion)68 return69 }70 if options.Zsh {71 printScript("key-bindings.zsh", zshKeyBindings)72 printScript("completion.zsh", zshCompletion)73 return74 }75 if options.Fish {76 printScript("key-bindings.fish", fishKeyBindings)77 printScript("completion.fish", fishCompletion)

shell: nushell integration scripts (#4630)Simon Désaulniersbefore adoption290b18d

lines 78–82why, one step back
78 return
79 }80 if options.Nushell {81 printScript("key-bindings.nu", nushellKeyBindings)82 printScript("completion.nu", nushellCompletion)

bash: shift-delete to delete history entries during CTRL-RJunegunn Choibefore adoption76efddd

lines 83–115why, one step back
83 return
84 }85 if options.Help {86 fmt.Print(fzf.Usage)87 return88 }89 if options.Version {90 if len(revision) > 0 {91 fmt.Printf("%s (%s)\n", version, revision)92 } else {93 fmt.Println(version)94 }95 return96 }97 if options.Man {98 file := fzf.WriteTemporaryFile([]string{string(manPage)}, "\n")99 if len(file) == 0 {100 fmt.Print(string(manPage))101 return102 }103 defer os.Remove(file)104 cmd := exec.Command("man", file)105 cmd.Stdin = os.Stdin106 cmd.Stdout = os.Stdout107 if err := cmd.Run(); err != nil {108 fmt.Print(string(manPage))109 }110 return111 }112113 code, err := fzf.Run(options)114 exit(code, err)115}