Comments (7)
On second thought, I'm afraid we would end up with a very complex solution for little demand. Shelling out seems like the most practical solution for now. Now that the result
event is fixed, one can use transform-border-label
or transform-header
to display more information on screen, but yeah, it's not an exact substitute for the info
panel.
How about adding something like --info-command='echo "[$FZF_POS/$FZF_MATCH_COUNT] ($FZF_SELECT_COUNT)"'
, and exposing more information? An alternative would be transform-info
action. In either way, we can pass the default info line as $FZF_INFO
so that the user can extract information from it.
from fzf.
Added --info-command
. It supports ANSI color codes in the output and $FZF_INFO
is exported to the command. I've tested it with all info layouts (default, inline, right, inline-right) and everything seems to work as expected. Please test it and let me know if there's a problem.
from fzf.
everything seems to work as expected.
Works well. Thank you for your effort in implementing it.
It allows for some custom info commands, as described in the issue, and even some less common ones, such as transforming numbers into Roman numerals.
![](https://private-user-images.githubusercontent.com/92653266/341178672-7b1db224-11cb-4d53-ae0b-9152c27f21ad.gif?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk2Njg5NTIsIm5iZiI6MTcxOTY2ODY1MiwicGF0aCI6Ii85MjY1MzI2Ni8zNDExNzg2NzItN2IxZGIyMjQtMTFjYi00ZDUzLWFlMGItOTE1MmMyN2YyMWFkLmdpZj9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MjklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjI5VDEzNDQxMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTk3Nzk4MTQ1MDgyOGMyYWViODM0M2FmYTczYjIxMGI2MjllMGQyOWQ0NjEwMDcyNTZhMjQwY2RjZDU2YTY5YTYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.HSGZB4aquN_MRuPUPd6d4btZFwkVahaghsUmO6zAdkA)
Please test it
Should there be an additional sentence in the man
page under the --info-command
option? This sentence could direct the user to another section containing a list of variables. For instance:
For additional environment variables available to the command, see the section ENVIRONMENT VARIABLES EXPORTED TO CHILD PROCESSES.
If a user hasn't read the man
page and assigns a loop to it, the typical β Control + C keybind has no effect to cancel it. One has to close the tab. An issue or user fault ?
fzf --info-command='while : ;do echo "Time: $(date +%H:%M:%S), Matches: $FZF_MATCH_COUNT"; sleep 1;done'
from fzf.
matched count doesn't incrementally update itself in batches in the same way as the current info does on large inputs.
This made me realize that we're not firing result
event if the input stream is not complete.
Lines 1241 to 1259 in ed12925
But there's no reason that it should be this way. I can't remember why I made that decision. Maybe I was worried about ending up with too many events? Maybe it was just an oversight.
The name of the flag could be
--info2=STYLE
.
While I agree that an alternative representation is desirable in some cases, we should think through how to implement it and
not rush into a decision.
Something like --info-format="#{match_count}/#{total_count} #{sort} #{track} [#{multi}] (#{progress})"
(similar to git format and tmux format) would give the maximum flexibility, but obviously, it isn't simple to get it right.
e.g. How to hide surrounding parentheses and brackets when the inner element evaluates to an empty string? We don't want to see ()
or []
. And how to handle leading and trailing spaces around an empty element, etc.
from fzf.
junegunn added the feature label yesterday
Thanks for considering this a feature.
How to hide surrounding parentheses and brackets when the inner element evaluates to an empty string?
So, some kind of conditional syntax would be needed? Below are some syntax examples for conditionals:
zsh: ternary expression
In zsh
, the syntax for a conditional string would be %(x.true-text.false-text)
. For example:
# Display a different string based on whether the hour is six
print -Pr -- "%(6T.Breakfast is ready.No Breakfast)"
# Print a Thumbs Up emoji or a Cross Mark emoji based on the exit status of the last command
print -Pr -- "%(?.π.β)"
go: ifβ¦end
Or maybe go
1 templates, but the syntax is a bit more uncommon, because of the double curly braces. The gh
tool has a --template
flag that allows writing go
templates, for example, to show me the stargazers_count
of a repo only when it is not private
.
gh api repos/junegunn/fzf \
--template '{{ if not .private }}Stars: {{ .stargazers_count }}{{ end }}'
(similar to git format and tmux format)
git
git
also has some ifβ¦end
construct
git for-each-ref --sort=-creatordate \
--format='%(if)%(HEAD)%(then)%(color:magenta)%(refname:short)%(color:reset)%(else)%(color:yellow)%(refname)%(color:reset)%(end)' 'refs/heads'
But a state for multi mode would be needed to check if it is enabled or not. However, the longer and more complex it becomes to write, the less likely anyone will actually use it. What do you think about some kind of conditional syntax for strings as seen above?
Footnotes
from fzf.
How about adding something like
--info-command='echo "[$FZF_POS/$FZF_MATCH_COUNT] ($FZF_SELECT_COUNT)"'
It would allow for customizing the info, and the syntax is straightforward and easy to use. I like it.
from fzf.
the typical β Control + C keybind has no effect to cancel it.
All transform actions have the same problem. To allow CTRL-C, we should restore the terminal state to receive user input, but immediately doing so would cause unwanted artifacts to be rendered on screen during the execution. For example, if you hold down CTRL-K or up arrow during a transform action, you would see:
> ^K^K^K^[[A^[[A^[[A
One idea is to receive user input when a certain amount of time has elapsed, e.g. 1 second, assuming that most transform commands finish within the period.
from fzf.
Related Issues (20)
- Significant prompt flick with fzf --expect HOT 4
- Replacing placeholder by the query when no match HOT 2
- Using bind with an echo output, the variable assignment no longer works HOT 2
- Question: What's the expected behavior with --nth and --with-nth together? HOT 2
- Manually triggering events HOT 1
- Allow pointer to be disabled HOT 4
- FZF_DEFAULT_OPTS is broken on OSX, installing via brew or git clone HOT 1
- [BUG] Multi-line commands surrounded by parentheses not showing up in history HOT 2
- Allow CTRL-C to cancel transform actions
- fzf-completion doesn't work on fresh archlinux install HOT 8
- --marker 'β' --marker-multi-line 'βββ' does not take effect? HOT 1
- "panic: runtime error" if tty is 1 line high HOT 1
- panic: runtime error: invalid memory address or nil pointer dereference HOT 21
- fzf `CTRL+R` only working in zsh `vicmd` mode HOT 1
- Crash when piping output from node/nodemon web server HOT 6
- Running `fzf -f whatever` with an `i3` keybinding fails HOT 1
- Re-evaluate --bind each time bindkey pressed HOT 1
- Select candidate if it's multi lines? HOT 1
- Option to show --marker and --marker-multi-line if it's multi lines? HOT 1
- Select after reload?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fzf.