Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessing shell functions inside preview window #1337

Closed
Bmsandoval opened this issue Jul 21, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@Bmsandoval
Copy link

commented Jul 21, 2018

  • Category
    • [ x] fzf binary
    • fzf-tmux script
    • Key bindings
    • Completion
    • Vim
    • Neovim
    • Etc.
  • OS
    • [x ] Linux
    • Mac OS X
    • Windows
    • Windows Subsystem for Linux
    • Etc.
  • Shell
    • [ x] bash
    • zsh
    • fish
Admittedly the usecase is minimal... but "--preview 'declare -f {}'" gives undesired results if it is passed a bash function that is not in the bashrc (even if the bashrc sources the other file). It seems to be because fzf runs these in a non-login shell. This would be convenient for editing bash functions by allowing you to search for all your bash functions and then display the bash code in the preview window.
@junegunn

This comment has been minimized.

Copy link
Owner

commented Jul 25, 2018

Bash functions are not visible to child processes if you don't explicitly export them.

> foo() { echo foo; }
> declare -f foo
foo ()
{
    echo foo
}
> bash -c 'declare -f foo'
> export -f foo
> bash -c 'declare -f foo'
foo ()
{
    echo foo
}

@junegunn junegunn closed this Jul 25, 2018

@junegunn junegunn changed the title Preview window Accessing shell functions inside preview window Jul 25, 2018

@junegunn junegunn added the question label Jul 25, 2018

@junegunn

This comment has been minimized.

Copy link
Owner

commented Jul 25, 2018

Or you can load your configuration files in preview command

fzf --preview 'source ~/.bashrc; declare -f {}'

@segeljakt segeljakt referenced this issue Aug 2, 2018

Closed

Accessing zsh functions inside preview window #1348

3 of 15 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.