# How to use pjcolor in a more proper way

**URL:** <https://discourse.pijul.org/t/how-to-use-pjcolor-in-a-more-proper-way/1154>\
**Category:** Community\
**Created:** [November 28, 2023, 5:31pm UTC](https://discourse.pijul.org/t/how-to-use-pjcolor-in-a-more-proper-way/1154 "2023-11-28T17:31:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![levi](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/levi/32/565_2.png) [@levi](https://discourse.pijul.org/u/levi)\
**Post date:** [November 28, 2023, 5:31pm UTC](https://discourse.pijul.org/t/how-to-use-pjcolor-in-a-more-proper-way/1154/1 "2023-11-28T17:31:14Z")

</div>

It took me more than an hour to do this right. At first it seems like a simple problem. But the naive solutions didn’t quite work out. So I’m sharing the way, how to use `pjcolor` in transparent way for _ **zsh** _. The method is for _ **zsh** _, but I think any shell can achieve the same thing.

1. edit your `.zshrc` file add  
`fpath=( ~/.zfunc "${fpath[@]}" )` somewhere at the top of the file.  
`.zfunc` will be the directory to put our new shell script. So do create it.
2. In your `.zshrc` fille add also a line `autoload -Uz pj`
3. In your `.zshrc` file put also `alias pijul="pj"`
4. Put this code in `pj` file, inside your `.zfunc` directory.

```auto
pj() {
  case "$1" in
  change)
    if ["$2" = ""]; then
      pijul change | pjcolor
    else
      shift
      pijul change "$@" | pjcolor
    fi
    ;;
  diff)
    if ["$2" = ""]; then
      pijul diff | pjcolor
    else
      shift
      pijul diff "$@" | pjcolor
    fi
    ;;
  *)
    pijul "$@"
    ;;
  esac
}

```

1. Source your `.zshrc` file `source ~/.zshrc` You may need to invoke another instance of your terminal to changes take effects.

Now you should have pijul command that colors the output by default, as a bonus you also get `pj` alias that do the same thing. Script should respect all the additional flags and options. Just keep in mind to keep `pjcolor` in your `$PATH`

I think its good place to share it. I will also add this the `README.md` file in my repository.
