Skip to content

Commit 66a8b83

Browse files
authored
Merge pull request #119 from legendu-net/dev
Merge dev into main
2 parents 4fedae0 + 5dbb56d commit 66a8b83

File tree

4 files changed

+34
-24
lines changed

4 files changed

+34
-24
lines changed

.idx/dev.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{pkgs, ...}: {
22
channel = "stable-24.11";
33
packages = with pkgs; [
4+
moreutils
45
bash-completion
56
gitui
67
neovim

cmd/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88

99
// Update icon.
1010
func version(cmd *cobra.Command, args []string) {
11-
fmt.Println("0.26.0")
11+
fmt.Println("0.26.1")
1212
}
1313

1414
var versionCmd = &cobra.Command{

utils/data/bash-it/plugins/custom.plugins.bash

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ function fzf.cs {
4747
alias fcs=fzf.cs
4848
alias fcd=fzf.cs
4949

50+
5051
function _fzf.bat.usage {
5152
cat << EOF
5253
Search for files using fzf and preview it using bat.
@@ -65,13 +66,14 @@ function fzf.bat {
6566
if [[ $# > 0 ]]; then
6667
dir="$@"
6768
fi
68-
o="$(find $dir -type f -print0 2> /dev/null | \
69-
fzf --read0 --preview 'bat --color=always {}')"
69+
o="$(find $dir -type f -print0 2> /dev/null | fzf --read0 --preview 'bat --color=always {}')"
7070
echo $o
71+
nvim $o
7172
}
7273

7374
alias fbat=fzf.bat
7475

76+
7577
function _fzf.ripgrep.nvim.usage {
7678
cat << EOF
7779
Leverage fzf as the UI to search for files by content using ripgrep, \
@@ -108,3 +110,27 @@ function fzf.ripgrep.nvim (
108110
)
109111

110112
alias frgvim=fzf.ripgrep.nvim
113+
114+
115+
function _fzf.history.usage {
116+
cat << EOF
117+
Search for files using fzf and preview it using bat.
118+
Syntax: fzf.bat [-h] [dir]
119+
Args:
120+
dir: The directory (default to .) under which to search for files.
121+
EOF
122+
}
123+
124+
function fzf.history {
125+
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
126+
_fzf.history.usage
127+
return 0
128+
fi
129+
local command=$(fc -ln 1 | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' | fzf | vipe)
130+
echo $command
131+
eval "$command"
132+
}
133+
134+
alias fhist=fzf.history
135+
alias fh=fzf.history
136+

utils/utils.go

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,36 +1043,19 @@ func GetBashConfigFile() string {
10431043
// ConfigBash configures the Bash shell environment.
10441044
//
10451045
// This function performs the following configurations to the Bash shell:
1046-
//
1047-
// - Retrieves the appropriate Bash configuration file path using GetBashConfigFile().
1048-
// - Calls ConfigShellPath() to configure the shell's PATH environment variable.
1049-
// - Appends a block of code to the Bash configuration file to set the default
1050-
// editor to either `nvim` (if available) or `vim` (as a fallback).
1051-
// - If the operating system is Linux, it also appends a block of code to
1052-
// ~/.bash_profile to source in ~/.bashrc, ensuring that any configurations
1053-
// in ~/.bashrc are loaded.
1054-
//
1055-
// The function uses AppendToTextFile() to add the code blocks to the respective
1056-
// files, with the `checkExistence` flag set to true to avoid adding duplicate
1057-
// content. If any errors occur during file operations, the function will
1058-
// terminate with a fatal log message.
1059-
//
1060-
// @example
1061-
//
1062-
// ConfigBash() // Configures the Bash shell environment by setting the editor
1063-
// // and sourcing in ~/.bashrc on Linux.
1064-
//
1065-
// @remarks
1066-
// The function does nothing if it fail to retreive the bash config file.
1046+
// - configure the shell's PATH environment variable smartly
1047+
// - set the environment variables VISUAL and EDITOR to nvim with a fallback to vim.
10671048
func ConfigBash() {
10681049
bashConfigFile := GetBashConfigFile()
10691050
ConfigShellPath(bashConfigFile)
10701051
AppendToTextFile(
10711052
bashConfigFile,
10721053
`
10731054
if which nvim > /dev/null; then
1055+
export VISUAL=nvim
10741056
export EDITOR=nvim
10751057
else
1058+
export VISUAL=vim
10761059
export EDITOR=vim
10771060
fi
10781061
`,

0 commit comments

Comments
 (0)