highlightjs / highlight.js

JavaScript syntax highlighter with language auto-detection and zero dependencies.
https://highlightjs.org/
BSD 3-Clause "New" or "Revised" License
23.52k stars 3.57k forks source link

(powershell) Add v5.0 aliases as builtins #1338

Closed hmmwhatsthisdo closed 4 years ago

hmmwhatsthisdo commented 7 years ago

Powershell v5.0 has, out of the box, about 150 different aliases for commonly used commands. It would be handy if these were recognized as builtins by HLJS.

The list: %, ?, ac, asnp, cat, cd, CFS, chdir, clc, clear, clhy, cli, clp, cls, clv, cnsn, compare, copy, cp, cpi, cpp, curl, cvpa, dbp, del, diff, dir, dnsn, ebp, echo, epal, epcsv, epsn, erase, etsn, exsn, fc, fhx, fl, foreach, ft, fw, gal, gbp, gc, gci, gcm, gcs, gdr, ghy, gi, gjb, gl, gm, gmo, gp, gps, gpv, group, gsn, gsnp, gsv, gu, gv, gwmi, h, history, icm, iex, ihy, ii, ipal, ipcsv, ipmo, ipsn, irm, ise, iwmi, iwr, kill, lp, ls, man, md, measure, mi, mount, move, mp, mv, nal, ndr, ni, nmo, npssc, nsn, nv, ogv, oh, popd, ps, pushd, pwd, r, rbp, rcjb, rcsn, rd, rdr, ren, ri, rjb, rm, rmdir, rmo, rni, rnp, rp, rsn, rsnp, rujb, rv, rvpa, rwmi, sajb, sal, saps, sasv, sbp, sc, select, set, shcm, si, sl, sleep, sls, sort, sp, spjb, spps, spsv, start, sujb, sv, swmi, tee, trcm, type, wget, where, wjb, write

The only potential sticking point I could see is that foreach is both an alias to ForEach-Object and a language statement.

joshgoebel commented 4 years ago

The only potential sticking point I could see is that foreach is both an alias to ForEach-Object and a language statement.

Well, it can either be a built_in or a keyword but not both. :-)

I think you're suggesting we add these to built_in, yes? Could you make a PR and update the tests to check a few?

joshgoebel commented 4 years ago

I dunno about "%" and "?" though since we don't usually highlight punctuation/operators. How are those commands?

joshgoebel commented 4 years ago

Is this list of new aliases pushed anywhere?

hmmwhatsthisdo commented 4 years ago

PS Core defines the list of in-box variables in [System.Management.Automation.Runspaces.InitialSessionState]::BuiltInAliases.

joshgoebel commented 4 years ago

@hmmwhatsthisdo Want to try your hand at a PR? I think we'd just add these as built-in keywords, and that should get the job done. I'd exclude the single character ones.

hmmwhatsthisdo commented 4 years ago

Hey, sorry for sleeping on this one - I filed #2423 with a combined set of PowerShell aliases from Windows PowerShell v5.1 and PowerShell Core 7.

I'm not quite sure whether I'm using the proper syntax (the error thrown by Travis makes me think that's not the case), but that can be discussed on the PR if you'd like.