Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/ps-sh-helpersPublic template

Lib template for creating PowerShell and Bash helpers.

NotificationsYou must be signed in to change notification settings

alanlivio/ps-sh-helpers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ps-sh-helpers is a template for creating your library PowerShell and Bash helpers. It is very useful for Windows users that wants take the best of WSL Bash and integrate it with PowerShell.

ps-sh-helpers organize helpers in OS-dependent fromos/<os>.* files and loads program-dependent fromprograms/<program>.* files. It is initialized at.bashrc by loadinginit.sh or atPowerShell_profile.ps1 by loadinginit.ps1 (see diagram below).

from bash:

%%{init: {'theme':'dark'}}%%flowchart LR    bashrc[".bashrc"]    %% ps-init["init.ps1"]    sh-init["init.sh"]    program-dependent["        programs/[program].bash        ...    "]    OS-dependent["        os/any.bash        os/win.bash        os/ubu.bash        ...    "]        bashrc --> |"loads"| sh-init    sh-init --> |"1: loads if running at OS"| OS-dependent    sh-init --> |"2: loads if [program].bash exists"| program-dependent    %% sh-init --> |"3: create bash alias functions at"| ps-init
Loading

from powershell:

%%{init: {'theme':'dark'}}%%flowchart LR    psprofile["profile.ps1"]    ps-init["init.ps1"]    %% sh-init["init.sh"]    program-dependent["        programs/[program].ps1        ...    "]    OS-dependent["        os/any.ps1        os/win.ps1        os/ubu.ps1        ...    "]    psprofile--> |"loads"| ps-init    ps-init --> |"1: loads if running at OS"| OS-dependent    ps-init --> |"2: loads if [program].ps1 exists"| program-dependent    %%ps-init --> |"3: create ps1 alias to functions at"| sh-init
Loading

How to install

You can use the Bash commands below to fetch, install, and setupps-sh-helpers to be loaded in your.bashrc:

git clone https://github.com/alanlivio/ps-sh-helpers~/.ps1-sh-helpersecho"source ~/.ps-sh-helpers/init.sh">>~/.bashrc

You can use the PowerShell commands below to fetch, install, and setupps-sh-helpers to be loaded in yourprofile.ps1:

git clone https://github.com/alanlivio/ps-sh-helpers${env:userprofile}\.ps1-sh-helpers$contentAdd='. "${env:userprofile}\.ps-sh-helpers\init.ps1""'Set-Content"${env:userprofile}/Documents/WindowsPowerShell/Microsoft.PowerShell_profile.ps1"$contentAdd

Pay attention that to setup a PowerShell >= 6, the last line should be:Set-Content "${env:userprofile}/Documents/PowerShell/profile.ps1" $contentAdd

References

This project takes inspiration from:


[8]ページ先頭

©2009-2025 Movatter.jp