-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Embed shell integration scripts in fzf binary (
--bash
/ --zsh
/ `…
…--fish`) (#3675) This simplifies the distribution, and the users are less likely to have problems caused by using incompatible scripts and binaries. # Set up fzf key bindings and fuzzy completion eval "$(fzf --bash)" # Set up fzf key bindings and fuzzy completion eval "$(fzf --zsh)" # Set up fzf key bindings fzf --fish | source
- Loading branch information
Showing
7 changed files
with
197 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,55 @@ | ||
package main | ||
|
||
import ( | ||
_ "embed" | ||
"fmt" | ||
"strings" | ||
|
||
fzf "github.com/junegunn/fzf/src" | ||
"github.com/junegunn/fzf/src/protector" | ||
) | ||
|
||
var version string = "0.47" | ||
var revision string = "devel" | ||
|
||
//go:embed shell/key-bindings.bash | ||
var bashKeyBindings []byte | ||
|
||
//go:embed shell/completion.bash | ||
var bashCompletion []byte | ||
|
||
//go:embed shell/key-bindings.zsh | ||
var zshKeyBindings []byte | ||
|
||
//go:embed shell/completion.zsh | ||
var zshCompletion []byte | ||
|
||
//go:embed shell/key-bindings.fish | ||
var fishKeyBindings []byte | ||
|
||
func printScript(label string, content []byte) { | ||
fmt.Println("### " + label + " ###") | ||
fmt.Println(strings.TrimSpace(string(content))) | ||
fmt.Println("### end: " + label + " ###") | ||
} | ||
|
||
func main() { | ||
protector.Protect() | ||
fzf.Run(fzf.ParseOptions(), version, revision) | ||
options := fzf.ParseOptions() | ||
if options.Bash { | ||
printScript("key-bindings.bash", bashKeyBindings) | ||
printScript("completion.bash", bashCompletion) | ||
return | ||
} | ||
if options.Zsh { | ||
printScript("key-bindings.zsh", zshKeyBindings) | ||
printScript("completion.zsh", zshCompletion) | ||
return | ||
} | ||
if options.Fish { | ||
printScript("key-bindings.fish", fishKeyBindings) | ||
fmt.Println("fzf_key_bindings") | ||
return | ||
} | ||
fzf.Run(options, version, revision) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.