Comments (10)
@blaineventurine sets an alias for
cat
1
Thank you for doing what I should have done and giving a fully reproducible config.
from fzf.
Looks like your ps commmand is producing ANSI color codes when it shouldn't. You see colored output when you do ps -ef | cat
? And what is the output of command -v ps
?
from fzf.
Looks like your ps commmand is producing ANSI color codes when it shouldn't. You see colored output when you do
ps -ef | cat
? And what is the output ofcommand -v ps
?
No color output, and /bin/ps
from fzf.
@blaineventurine sets an alias for cat
1 and has a config file for bat
with the --color=always
flag. 2
alias cat='bat'
Additionally, there is no --ansi
flag in the FZF_DEFAULT_OPTS
3.
Minimal setup to reproduce the issue:
export FZF_DEFAULT_OPTS=""
export FZF_COMPLETION_TRIGGER=',,'
alias cat='bat --color=always --number'
source /Users/paria/Developer/fzf/shell/completion.zsh
It seems to have come from commit 152988c.
Prepending command
to the cat
command in the function below seems to fix the issue. However,
this does not explain why the issue only became apparent after commit 152988c. Anyone understands this?
Lines 183 to 187 in f97d275
Another cat
command in that file already has been prefixed with command
4, lets just follow suit ?
Lines 231 to 236 in f97d275
Footnotes
from fzf.
Prepending
command
to thecat
command in the function below seems to fix the issue.
Confirmed.
But I have to mention that aliasing cat to bat with --color=always
is a bad idea and should be discouraged. It will break existing scripts that expect the normal cat behavior. alias cat='bat --number'
should be enough. You'll get pretty output when you cat something
, and it will not break scripts as bat will not print color codes when the standard output is not a TTY device.
alias cat='bat --number'
# Colors
cat README.md
# No colors
cat README.md | command cat
from fzf.
Commit 152988c wrapped the emulate
part in an if statement. With that change, the alias expansion no longer worked as expected.
Moving the interactive check after the emulate
command seems to have solved the issue and prevents us from prepending every single command with command
, as was described in #1944.
The movement of the interactive check to the top came with #3449, but it was just a simple one-line check, compared with the commit mentioned prior which wrapped everything in an if statement.
Note
I am not confident that the explanation is correct; it was derived only through testing. The documentation about emulate
did not provide clear instructions, and searching through the Zsh community posts did not offer much further assistance, other than the frequently mentioned advice of placing emulate
at the top of the script.
from fzf.
@LangLangBart Thanks for the investigation. Should we do it like this then?
diff --git a/shell/completion.zsh b/shell/completion.zsh
index 7067b06..8cd9737 100644
--- a/shell/completion.zsh
+++ b/shell/completion.zsh
@@ -9,9 +9,6 @@
# - $FZF_COMPLETION_TRIGGER (default: '**')
# - $FZF_COMPLETION_OPTS (default: empty)
-if [[ -o interactive ]]; then
-
-
# Both branches of the following `if` do the same thing -- define
# __fzf_completion_options such that `eval $__fzf_completion_options` sets
# all options to the same values they currently have. We'll do just that at
@@ -76,6 +73,8 @@ fi
# `finally` in lesser languages. We use it to *always* restore user options.
{
+if [[ -o interactive ]]; then
+
# To use custom commands instead of find, override _fzf_compgen_{path,dir}
#
# _fzf_compgen_path() {
@@ -346,10 +345,10 @@ fzf-completion() {
zle -N fzf-completion
bindkey '^I' fzf-completion
+fi
+
} always {
# Restore the original options.
eval $__fzf_completion_options
'unset' '__fzf_completion_options'
}
-
-fi
from fzf.
@LangLangBart Thanks for the investigation. Should we do it like this then?
Yes, key-bindings.zsh
may require similar modifications, and maybe in one file a hint ?
# The 'emulate' command should not be placed inside the interactive check,
# as doing so fails to disable alias expansion.
if [[ -o interactive ]]; then
from fzf.
@LangLangBart Sounds good. Can you open a pull request?
from fzf.
But I have to mention that aliasing cat to bat with
--color=always
is a bad idea and should be discouraged. It will break existing scripts that expect the normal cat behavior.alias cat='bat --number'
should be enough. You'll get pretty output when youcat something
, and it will not break scripts as bat will not print color codes when the standard output is not a TTY device.
Thanks for this - I believe I copied it out of the bat
documentation at some point. Removing --color=always
fix the issue I was having.
from fzf.
Related Issues (20)
- Background color for prompt only? HOT 4
- Tarball extraction in install.sh — improvement suggestion HOT 6
- Calling fzf#run with a list as source fail (n)vim is used from git bash HOT 25
- FZF_COMPLETION_OPTS to not follow symbolic link on **<TAB> completion being ignored HOT 5
- Preserve fzf fuzzy list view? HOT 11
- Preserve color output of `kubecolor get pods -A | fzf --ansi`? HOT 1
- Is it possible to create new bind on action from transform HOT 2
- Unknown command fzf_key_bindings error when invoking read in a Fish shell script HOT 3
- Header line at bottom? HOT 1
- `{q}` isn't escaped properly on Windows HOT 12
- last good fzf for fzf.vim on Windows 10 HOT 4
- FZF ignores nested files from $FZF_DEFAULT_COMMAND='fd' but not when piping fd into FZF HOT 3
- Can't input non ascii characters HOT 6
- Hang on SIGSTP when session leader
- simplify cygwin handling in Git Bash
- Action to clear selections if there are any else exit fzf. (Feature request) HOT 1
- Feature request: no-clear option that affects execute action (no clear before executing)
- On fzf.vim opening in new cmd Window in Git Bash HOT 37
- [Feature Request] Combining `--expect` and `--bind` HOT 4
- left-align preview window to the right of the finder HOT 1
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.