Giter Site home page Giter Site logo

colorize's People

Contributors

alexozwald avatar builder555 avatar freed-wu avatar grigorii-horos avatar jrwrigh avatar muniftanjim avatar rywng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

colorize's Issues

[question] Change function diff

if (( $+commands[diff-so-fancy] )); then
  function diff() {
    command diff "$@" | diff-so-fancy
  }
elif (( $+commands[delta] )); then
  function diff() {
    command diff "$@" | delta
  }
else
  function diff() {
    command diff --color "$@"
  }
fi

In fact, if user installed delta,

❯ echo a > a
❯ echo b > b
❯ command diff a b
1c1
< a
---
> b
❯ command diff a b | delta
1c1
< a
---
> b
❯ command diff -u a b
--- a   2021-08-30 17:24:50.801599241 +0800
+++ b   2021-08-30 17:24:53.541625220 +0800
@@ -1 +1 @@
-a
+b
❯ command diff -u a b|delta
comparing: a ⟶   b
─────────────────────────────────────────

──────┐
Δ :1: │
──────┘
│ 1  │a             │    │
│    │              │ 1  │b
❯ delta a b
comparing: a ⟶   b
─────────────────────────────────────────

──────┐
Δ :1: │
──────┘
│ 1  │a             │    │
│    │              │ 1  │b

command diff a b|delta is same as command diff a b.
So it is unnecessary to add this function.

For

function diff() {
  command diff -u "$@" | delta
}

I think it is unnecessary, too. Because delta a b is same, it just like

alias diff=delta

So, I think

    function diff() {
      command diff --color "$@"
    }

is enough for everyone.

PS: in man diff

       --color[=WHEN]
              color output; WHEN is 'never', 'always', or 'auto'; plain --color means --color='auto'

[bug] the command option of ip

❯ ip a
Option "-color=auto" is unknown, try "ip -help".
❯ declare -f ip

ip () {
        command ip --color=auto "$@"
}
❯ command ip -help
Usage: ip [ OPTIONS ] OBJECT { COMMAND | help }
       ip [ -force ] -batch filename
where  OBJECT := { link | address | addrlabel | route | rule | neigh | ntable |
                   tunnel | tuntap | maddress | mroute | mrule | monitor | xfrm |
                   netns | l2tp | fou | macsec | tcp_metrics | token | netconf | ila |
                   vrf | sr }
       OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] |
                    -h[uman-readable] | -iec |
                    -f[amily] { inet | inet6 | ipx | dnet | mpls | bridge | link } |
                    -4 | -6 | -I | -D | -B | -0 |
                    -l[oops] { maximum-addr-flush-attempts } | -br[ief] |
                    -o[neline] | -t[imestamp] | -ts[hort] | -b[atch] [filename] |
                    -rc[vbuf] [size] | -n[etns] name | -a[ll] | -c[olor]}
❯ command ip -c a
# output with colorcommand ip -V
ip utility, iproute2-ss171113

Another device:

❯ ip a
# output with colorcommand ip -c a
# output with color
❯ ip -V
ip utility, iproute2-5.13.0
❯ ip -h

Usage: ip [ OPTIONS ] OBJECT { COMMAND | help }
       ip [ -force ] -batch filename
where  OBJECT := { address | addrlabel | fou | help | ila | l2tp | link |
                   macsec | maddress | monitor | mptcp | mroute | mrule |
                   neighbor | neighbour | netconf | netns | nexthop | ntable |
                   ntbl | route | rule | sr | tap | tcpmetrics |
                   token | tunnel | tuntap | vrf | xfrm }
       OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] |
                    -h[uman-readable] | -iec | -j[son] | -p[retty] |
                    -f[amily] { inet | inet6 | mpls | bridge | link } |
                    -4 | -6 | -I | -D | -M | -B | -0 |
                    -l[oops] { maximum-addr-flush-attempts } | -br[ief] |
                    -o[neline] | -t[imestamp] | -ts[hort] | -b[atch] [filename] |
                    -rc[vbuf] [size] | -n[etns] name | -N[umeric] | -a[ll] |
                    -c[olor]}

How about

diff --git a/colorize.plugin.zsh b/colorize.plugin.zsh
index 85fa38b..289511a 100644
--- a/colorize.plugin.zsh
+++ b/colorize.plugin.zsh
@@ -14,7 +14,7 @@ DEPENDENCES_DEBIAN+=( grc )
 export LESS="$LESS -R -M"

 function ip() {
-  command ip --color=auto "$@"
+  command ip -color "$@"
 }

 function grep() {

I test it can solve this bug.

Thanks!

maximum nested function level reached

Since the last update, various commands (eg du) fail and abort with this message: maximum nested function level reached using macos 10.14.6, zsh 5.8 (x86_64-apple-darwin18.7.0) and zinit. How can I solve this? Thanks!

Overwrites previous LESS environment variable

When LESS environment is already set, it gets overwritten by this plugin. This can potentially lead to undesired behavior on other applications.

Example: if user has already set LESS environment variable to avoid git command from paging when it's not necessary:

❯ echo $LESS
-F -X -R

after invoking this plugin, LESS environment becomes:

❯ echo $LESS
-R -M

Now git behavior is to page even when not needed.

diff does not work on mac

Steps to reproduce:

  • Install colorize on MacOS
  • run diff . /

Expected results:
a list of files

Actual results:
An error message:

diff: unrecognized option `--color'
diff: Try `diff --help' for more information.

env -h not a valid option

I keep getting an error from env saying

➜ env                                      
env: invalid option -- 'h'
Try 'env --help' for more information.

I'm not sure why the -h flag is invoked in this plugin. Perhaps you could shed some light on that? Otherwise I'm pretty sure it doesn't need to be there.

Edit: I can confirm that removing the -h flag doesn't appear to change anything. Output is still colorized.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.