Giter VIP home page Giter VIP logo

hl's People

Contributors

mbornet-hl avatar ottok 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar

hl's Issues

Issue: Cannot compile on macOS

The source does not compile on macOS. Errors attached in the log file here.
Compiling it on macOS 13.2.1 on a M2 MacBook

However, as suggested by j16sdiz I was able to compile on macOS by
removing the #define _POSIX_C_SOURCE from cr_main.c ...

Now, The utility works but it does not have any of the included configurations:

Running hl -H returns:

...........
...........
-P  : display configuration(s) matching regexp
-x  : display options count for each config (with -vH options)
Configurations :

Could you please update the code so that it compiles on macOS?
Many thanks...

Or is it that I am using the configurations incorrectly?
Are these compiled into the hl binary file itself or do I need to place the hl_bin folder in a specific location to get the configurations to work?

hl binary is compiled with profiling enabled

Every time I launch tools/hl/bin/1.62/amd/debian/7.8/hl, a file called "gmon.out" is generated in the current directory.
Please provide binaries which are NOT compiled with profiling enabled (i.e. without the -pg compile flag, iirc)

add fucntions

You can add a parameter file hl.hlrc with functions (in replacement of the specfic tree in the PATH.
For exemple the command netstat

netstat(){
if [ $# -gt 0 ]
then
param=$*
else
param=" "
fi
exec=which netstat
$exec $param | hl --netstat
}

Show difference from previous line

I'm starting to become more than a basic hl user and the config I have in mind is to highlight what is different from the line above. The idea is to compare from delimiter to delimiter a line with the line above it, and when a diff is detected, that "cell" is colored as well as the rest of the line, even if later cells are the same as previous. Here's an example I mocked up in an RTF editor:

image

OSX port

This looks very useful. Do you plan to port it to OSX?

Khard - Supporting a command using user input and escape sequences

Introduction

I use khard to search and edit my vcard contacts.

The main issue was that it was designed for the console, so I wrote a config for hl and a function to call it with khard.

For a simple listing, there is no issue:

  • khard | hl --khard
    image

But a more useful command in khard is show to get details for one contact, it filters the list with options or by asking the user to provide an index number manually:

  • khard show
    image

  • 2
    image

Issues

When khard show is piped to hl the user prompt Enter Index (0 for None, q to quit): is not visible before user input.

  • khard show | hl --khard
    image

After the user input, there is an issue with the escaping sequence and the prompt appears on the first line of the output, with the name of the contact.

  • 2
    image

Question

This kind of command (khard show) is probably not designed to be piped so I don't want to open an issue with khard at first.
Is there a way to solved that on hl side?

Reproduce

  • khard can be installed with most package managers or pipx.
  • My configuration for khard:

~/.config/khard/khard.conf

[addressbooks]
[[principal]]
path = ~/.contacts/fake/

[general]
debug = no
default_action = list
editor = vim, -i, NONE
merge_editor = vimdiff

[contact table]
display = first_name
group_by_addressbook = no
reverse = no
show_nicknames = yes
show_uids = yes
sort = last_name
localize_dates = yes
preferred_phone_number_type = pref, cell, home
preferred_email_address_type = pref, work, home

[vcard]
private_objects = Telegram, Matrix, XMPP, Tox
preferred_version = 4.0
search_in_source_files = yes
skip_unparsable = yes
  • 2 fake vcard contacts:

~/.contacts/fake/Jane_Doe.vcf

BEGIN:VCARD
UID:02446dd0-6eb1-4d54-a9d5-387af78d0a6d
VERSION:4.0
PRODID:-//BBros.us llc//bvCard.com//EN
N:Doe;Jane;;;
FN:Jane Doe
EMAIL:[email protected]
ORG:Google
TEL:123-123-123
URL;type=pref:http://google.com
ADR:;;;;;;France
END:VCARD

~/.contacts/fake/John_Doe.vcf

BEGIN:VCARD
UID:bf675293-0b61-47ac-ad4a-4966bd7aacff
VERSION:3.0
PRODID:-//BBros.us llc//bvCard.com//EN
N:Doe;John;;;
FN:John Doe
EMAIL;TYPE=home:[email protected]
NOTE:Fake ID
ORG:Microsoft
TEL;TYPE=cell:+33600000000
URL;type=pref:http://microsoft.com
ADR:;;;;;;France
END:VCARD
  • My hl conf for khard:
khard            :
     -e
     -3w '^[ ]{4}?[a-zA-Z][a-zA-Z -]{1,12}:'
     -3g '^Address book: (.*)$'
     -3y '^Index.*$'
     -1y '^[0-9]+'
     -2c 'Nickname:'
     -1w '[ ]{4}([a-zA-Z]+:)'
     -3r ': (\+?\(?[0-9]{1,3}\)?[0-9 -]{8,13}[0-9])'
     -3b '([^ ]+)@[^ ]+\.[^ ]+'
     -2b '[^ ]+(@[^ ]+\.[^ ]+)'

compilation failed

Hi,
I have an issue with the compilation process. After clone the repo, and go to /src and made "make" there is a kind of references problem. I saw the code but I did not find any problem. So I don't know what its going wrong.
I have this message in my terminal

cc -c -o cr_main.o cr_main.c
cc -c -o cr_gpri.o cr_gpri.c
lex -t cr_lex.l > cr_lex.c
cc -c -o cr_lex.o cr_lex.c
cr_main.o: In function cr_add_regexp': cr_main.c:(.text+0x125f): undefined reference tocr_clear_marker_flags'
cr_main.o: In function main': cr_main.c:(.text+0x1401): undefined reference tocr_clear_marker_flags'
cr_main.o: In function cr_disp_line': cr_main.c:(.text+0x2c1d): undefined reference tocr_same_colors'
collect2: error: ld returned 1 exit status
Makefile:8: recipe for target 'hl' failed
make: *** [hl] Error 1
rm cr_lex.c

Thanks..

how to start

hi, i know it is useful, but i really don't know how to begin, can you give a simple tutor step by step。thank you。

hl script removes itself from PATH and then calls hl...

How is this supposed to work?

$ cd /d/more/src/tools/hl/hl_bin
$ export PATH=$PWD:$PATH
$ df
/d/more/src/tools/hl/hl_bin/df: line 48: hl: command not found
$ which hl
/d/more/src/tools/hl/hl_bin/hl

The hl script does:

PATH="$(echo "$PATH" | sed "s|^$dirname:||;s|:$dirname:|:|g")"
export PATH

man no longer uses a pager

hl/hl_bin/man colorizes the output of man, but loses the use of a pager. So the full man page gets printed out, while standard man would use a pager like less to make it possible to read it page by page, go up, etc.
Of course one can work around it by piping hl_bin/man to less, but it would be more convenient if the use of hl was fully transparent.

In fact, this appears to fix it:

--- i/hl_bin/man
+++ w/hl_bin/man
@@ -45,8 +45,9 @@ if [ "$USE_HL" = "no" ]; then
 else
        # Default behaviour : colorization
        # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-       hl -u --"$progname" < "$ERR" & hl --"$progname" < "$OUT" & \
-               "$progname" "$@" > "$OUT" 2> "$ERR"
+       hl -u --"$progname" < "$ERR" &
+       ( hl --"$progname" < "$OUT" | less ) &
+       "$progname" "$@" > "$OUT" 2> "$ERR"
 
        rc=$?

I'm not sure why the original syntax is a & b & c when the & means "detach", not "and". So it would be equivalent and more readable to do this on three lines anyway.

I guess my patch needs to be improved to not hardcode less and instead do like man does:
$MANPAGER, defaulting to $PAGER, defaulting to ... no idea, more, I guess?
In my case $PAGER is less.

[Feature request] color=auto mode

I would like to include hl in aliases to provide an output like color=auto in some binutils which lack colors.

But, it needs to detect that the output is in a pipe or not in a terminal and disable the coloration.

Manualy, I do it like that:

hlauto () {
  if [ -t 1 ]; then
    hl $1
  else
    cat -
  fi
}

alias df='df -Tha --total | hlauto --df'

It works great. The new alias df ouput in color, but df | less output without hl.

Would it be easy to include this feature in hl? Maybe like this?

alias df='df -Tha --total | color=auto hl --df'

parameter order

Hello,

i really like your hl tool, but the parameter seams to be given in a definded order: e.g. works
ls | ./hl -2 -b Make
cr_cpri.h
cr_epri.h
...

but switching b and 2 does not work.

ls | ./hl -b -2 ak
./hl: missing argument for "-b" !
ARGS :
opts = "hHuVvEr:g:y:b:m:c:w:R:G:Y:B:M:C:W:n:DLdei1234%.:"
optarg = "(null)"
curr_ptrs = 0x21f1040
PTRS :
curr_arg = "-b"
curr_idx = 2
next_arg = "(null)"
prev = (nil)
config = (nil)

I would also suggest to add a default color so hl directly works without parameters.

best regards, Johannes

input in flex scanner failed when using configs

When using the predefined configs, I get:

sami@pad:~ $ hl -V
hl: version 1.93
sami@pad:~ $ hl --du
input in flex scanner failed
sami@pad:~ $ hl --log_d
input in flex scanner failed
sami@pad:~ $ cat /var/log/auth.log | hl --log
input in flex scanner failed
sami@pad:~ $

Version number is visible above.

I'm on Ubuntu 20.04. Feel free to ask if you need to know other package versions. I am eager to help!

[Bug] Error with Config Files in /etc/default and instructions

  1. To set up the configuration files included in the project globally the current documentation indicates to make the following copy:
cp config_files/hl /etc/default

But, the config_files/hl file does not exist, there are several hl_*.cfg files in that folder. So we assume that there is an error in the writing.

  1. On the other hand, if we copy the whole folder:
sudo cp -R config_files/ /etc/default/hl/
  • And then test a configuration:
df -h | hl --df
  • We get an error:
hl: cr_read_config_file() : "/etc/default/hl" is not a regular file !
  1. Finally, if we copy the whole folder and then export the variable, it works.
sudo cp -R config_files/ /etc/default/hl/
export HL_CONF=/etc/default/hl

I think that maybe the default location is badly encoded in the source.

And I have one more weird issue at this point:

  • If the folder /etc/default/hl exists
  • then I have this same error (hl: cr_read_config_file() : "/etc/default/hl" is not a regular file!) every time I open a new bash session in, even though I don't run hl to my knowledge.

Comparison with supercat?

Hi, I use supercat for doing the highlighting: http://supercat.nosredna.net/

It is also written in C (& uses regcomp) etc.

Have you compared your tool against it, and if so, what are the benefits? (if any)

Knowing this will be helpful for people (who don't know much C) but want to decide which tool to use.

Thanks!

hl_bin issue

What is the hl_bin/hl. It makes my system (Ubuntu 16.04) break. I think it calls it forever... maybe hl binary should be renamed to hl_prog (or something) while this script should be the real hl. What you think?

Undefined reference to yyin and yylex but flex is installed

Hi, thanks for your great tool!

I am having some errors compiling on Ubuntu server. Hope you can have a look:

OS version

uname -a
Linux  4.15.0-109-generic #110-Ubuntu SMP Tue Jun 23 02:39:32 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

I have installed flex package version 2.6.4

lex -V
flex 2.6.4

But I get the following errors when running make:

make[1]: Entering directory '/usr/src/hl/src'
cr_main.o: In function `cr_read_config_file':
cr_main.c:(.text+0x182): undefined reference to `yyin'
cr_main.c:(.text+0x189): undefined reference to `yyin'
cr_main.c:(.text+0x1e2): undefined reference to `yylex'
collect2: error: ld returned 1 exit status
Makefile:18: recipe for target 'hl' failed
make[1]: *** [hl] Error 1
make[1]: Leaving directory '/usr/src/hl/src'
Makefile:6: recipe for target 'hl' failed
make: *** [hl] Error 2

Thanks

hl for AIX

hl can be used on aix.
you must add a line in the makefile
CC=gxlc
and in the cr_cpri.h can you add the

ifdef FALSE

undef FALSE

endif

before

define FALSE (0)

and

ifdef TRUE

undef TRUE

endif

before

define TRUE (0)

the include file getopt.h don't exist on the aix but you can copy it from linux and it work

Easier installation

Please provide a toplevel Makefile which recurses to the src dir, a "make install" rule which copies hl into PREFIX/bin, and copies the default config file into a default location where it will be picked up. It could also suggest to add hl/hl_bin to the PATH by adding one line to .bashrc or .zshrc. This would make it easier to get started with hl.

input in flex scanner failed

# hl -V
hl: version 1.107

# hl -H
input in flex scanner failed

# hl/hl_bin/cal
input in flex scanner failed
input in flex scanner failed

# lsb_release -d
Description:    Ubuntu 21.04

# dpkg -l flex
ii  flex           2.6.4-8      amd64        fast lexical analyzer generator

# dpkg -l bison
ii  bison          2:3.7.5+dfsg-1 amd64        YACC-compatible parser generator

How to use it?

Hi, can you help me with the setup?
I am trying some of your commands like, but I am having input in flex scanner failed error.

$> df -h | hl --df
input in flex scanner failed

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.