Skip to content

devel0/shu

Repository files navigation

shu

NuGet Badge

SHell Utilities



Quickstart

dotnet tool update -g shu
  • if ~/.dotnet/tools dotnet global tool isn't in path it can be added to your ~/.bashrc
echo 'export PATH=$PATH:~/.dotnet/tools' >> ~/.bashrc

enable completion

to enable completion edit /etc/bash_completion.d/shu

_fn() {  
        COMPREPLY=($(SHOW_COMPLETIONS=1 shu ${COMP_LINE:2}))
}
complete -F _fn shu

command line

devel0@main:~$ shu
missing command

Usage: shu COMMAND FLAGS

shell utils

Commands:
  replace-token   replace token from given standard input (not optimized for huge files)

Global flags:
  -h              show usage

match regex

Usage: shu match-regex FLAGS regex fmt

match regex groups

Global flags:
  -h,--help   show usage

Parameters
  regex       c# regex
  fmt         format string ( use \N to print Nth group in place )

example

devel0@tuf:/opensource/shu$ acpi -b
Battery 0: Unknown, 97%
devel0@tuf:/opensource/shu$ acpi -b | shu match-regex '[,\s]*(\d+)%' 'battery percent is [\\1]'
battery percent is [97]

replace token

Usage: shu replace-token FLAGS token replacement

replace token from given standard input (not optimized for huge files)

Optional flags:
  -csregex      token will treated as csharp regex

Global flags:
  -h,--help     show usage

Parameters
  token         token to search for
  replacement   text to replace where token was found

example

How this project was built

mkdir shu
cd shu

dotnet new sln
dotnet new console -n shu

cd shu
dotnet add package netcore-util
dotnet add package netcore-cmdline
cd ..

dotnet sln shu.sln add shu
dotnet build

old version w/analyzer tool

You can find old version 0.6.0 with analyzer tool here

to install that version use

dotnet tool install --global shu --version 0.6.0