Git Product home page Git Product logo

get-childitemcolor's Introduction

Get-ChildItemColor

  • This adds colors to the output of Get-ChildItem Cmdlet of PowerShell. It is based on Tim Johnson’s script and another script by the PowerShell Guy.
  • Before version 1.0.0, the script actually had used Write-Host to write colored items on console. Now it just changes $Host.UI.RawUI.ForegroundColor and keep the item object intact. Hence, now one can use pipeline. (e.g., ~Get-ChildItemColor | grep “.git”~).
  • Get-ChildItemColorFormatWide still uses Write-Host for output however. This is because Get-ChildItemColor | Format-Wide does not allow multiple colors in one line. Hence, pipeline does not work with Get-ChildItemColorFormatWide.

Screenshot:

Get-ChildItemColor

./screenshots/Get-ChildItemColor.png

Get-ChildItemColorFormatWide (ls equivalent)

./screenshots/Get-ChildItemColorFormatWide.png

Notes on the code

  • It uses a hash table instead of regular expressions to specify colors
  • Recognize the DictionaryEntry case (e.g., Get-ChildItemColor env:)
  • Color support for | Format-Wide format (ls equivalent) with custom script

Install

Install from PowerShellGallery

PowerShellGet is required, which is included in Windows 10 and WMF5. If you are using PowerShell V3 or V4, you will need to install PowerShellGet.

Then, you can simply run Install-Module Get-ChildItemColor (or Install-Module Get-ChildItemColor -Scope CurrentUser).

Install from GitHub

Clone the repo in your PowerShell Module folder ($ENV:UserProfile\Documents\WindowsPowerShell\Modules).

git clone https://github.com/joonro/Get-ChildItemColor.git

Usage

When you import the module:

Import-Module Get-ChildItemColor

it exposes two functions, Get-ChildItemColor and Get-ChildItemColorFormatWide.

You can add aliases to these functions for convenience. For example, I have the following in my $PROFILE$ [fn:PathProfile]:

Import-Module Get-ChildItemColor
 
Set-Alias l Get-ChildItemColor -option AllScope
Set-Alias ls Get-ChildItemColorFormatWide -option AllScope

So l yields colored output of Get-ChildItem and ls yields colored output of Get-ChildItem | Format-Wide equivalent.

[fn:PathProfile] $ENV:UserProfile\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

Authors

Changelog

v1.2.0

  • Robust to non-file entries (Issue #10)

v1.1.0

  • Revert back to previous implementation of Get-ChildItemColorFormatWide

v1.0.0

  • The script changes $Host.UI.RawUI.ForegroundColor only and keep the item object intact
  • Get-ChildItemColorFormatWide is basically Get-ChildItemColor | Format-Wide

v0.5.3

  • Better performance by reducing if’s
  • Proper printing of DirectoryEntry for FormatWide case

v0.5.2

  • Published on PowerShellGallery
  • Refactoring; separate out two functions

v0.4.2

  • Make it a PowerShell module

v0.4.1

  • Returns vanila Get-Childitem results for DictionaryEntry cases.

v0.4.0

  • Make function names consistent to the PowerShell naming convention (#8)
  • Use parameters more consistently, -Path works with paths with spaces (#3), and -Force works (#9)

get-childitemcolor's People

Contributors

joonro avatar nitin88 avatar

Watchers

 avatar  avatar

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.