Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nyabkun/bash-to-powershell-converter
Converts bash script to powershell script.
https://github.com/nyabkun/bash-to-powershell-converter
bash bash-profile bash-script bashrc nodejs powershell powershell-profile
Last synced: 2 months ago
JSON representation
Converts bash script to powershell script.
- Host: GitHub
- URL: https://github.com/nyabkun/bash-to-powershell-converter
- Owner: nyabkun
- License: mit
- Created: 2021-02-22T11:43:11.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-05-06T13:29:52.000Z (over 1 year ago)
- Last Synced: 2024-08-03T01:20:01.789Z (5 months ago)
- Topics: bash, bash-profile, bash-script, bashrc, nodejs, powershell, powershell-profile
- Language: JavaScript
- Homepage:
- Size: 27.3 KB
- Stars: 56
- Watchers: 2
- Forks: 18
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-rainmana - nyabkun/bash-to-powershell-converter - Converts bash script to powershell script. (JavaScript)
README
# Bash to Powershell Converter
A [node.js](https://en.wikipedia.org/wiki/Node.js) script that converts [bash](https://en.wikipedia.org/wiki/Bash_(Unix_shell)) to [powershell](https://en.wikipedia.org/wiki/PowerShell).
Only simple things like imports and aliases are supported.
It is a simple script using regular expressions, so feel free to fork it and modify it as you wish.
```powershell
node bash2pwsh.js ./You-can-test-with-this-bash-script/.bash_profile bash_profile.ps1
```## .bash_profile [Before]
```bash
## Utilfunction pipe() {
local outfile=~/pipe.md
$@ >& $outfile
code $outfile
}## App
alias play_mpc_be='C:/App/MediaPlayerClassic-BE/mpc-be64.exe'
alias code='C:/Dev/VSCode/Code.exe'## Dir
export d_diary='C:/Ws/diary'
export d_ws='C:/Ws'
export d_App='C:/App'
export d_AppInst='C:/AppInst'
export d_Dev='C:/Dev'alias cd_diary="cd $d_diary"
alias cd_ws="cd $d_ws"
alias cd_App="cd $d_App"
alias cd_AppInst="cd $d_AppInst"
alias cd_Dev="cd $d_Dev"## Util Alias
alias la='ls -a'
alias ll='ls -al'
alias exp_open_here='explorer .'## Git Alias
alias git_hist='git log --oneline --graph --decorate --all'
alias git_com='git commit --allow-empty-message --no-edit'
alias git_conf_global='git config --global --edit'
alias git_conf_local='git config --edit'
function git_add_com_push() {
git add -A
git commit --allow-empty-message --no-edit
git push
}## Edit
function edit_alias(){
code ~/.alias.zsh
}
function edit_alias_sh_only(){
code ~/.alias-sh.zsh
}
function edit_zshrc() {
code ~/.zshrc
}
function edit_pwsh_profile(){
code C:/Users/owner/Documents/PowerShell/Microsoft.PowerShell_profile.ps1
}## Env
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfg
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/share/pkgconfig
````>>>`
## bash_profile.ps1 [After]
```powershell
## Utilfunction pipe() {
local outfile=C:/msys64/home/owner/pipe.md
$args | Out-File -FilePath $outfile
code $outfile
}## App
Set-Alias -Name play_mpc_be -Value 'C:/App/MediaPlayerClassic-BE/mpc-be64.exe'
Set-Alias -Name code -Value 'C:/Dev/VSCode/Code.exe'## Dir
$d_diary='C:/Ws/diary'
$d_ws='C:/Ws'
$d_App='C:/App'
$d_AppInst='C:/AppInst'
$d_Dev='C:/Dev'function cd_diary() { cd $d_diary }
function cd_ws() { cd $d_ws }
function cd_App() { cd $d_App }
function cd_AppInst() { cd $d_AppInst }
function cd_Dev() { cd $d_Dev }## Util Alias
function la() { ls -a }
function ll() { ls -al }
function exp_open_here() { explorer . }## Git Alias
function git_hist() { git log --oneline --graph --decorate --all }
function git_com() { git commit --allow-empty-message --no-edit }
function git_conf_global() { git config --global --edit }
function git_conf_local() { git config --edit }
function git_add_com_push() {
git add -A
git commit --allow-empty-message --no-edit
git push
}## Edit
function edit_alias(){
code C:/msys64/home/owner/.alias.zsh
}
function edit_alias_sh_only(){
code C:/msys64/home/owner/.alias-sh.zsh
}
function edit_zshrc() {
code C:/msys64/home/owner/.zshrc
}
function edit_pwsh_profile(){
code C:/Users/owner/Documents/PowerShell/Microsoft.PowerShell_profile.ps1
}## Env
$env:PKG_CONFIG_PATH += ";C:/msys64/usr/local/lib/pkgconfg"
$env:PKG_CONFIG_PATH += ";C:/msys64/usr/local/share/pkgconfig"
echo "Loaded : $PSCommandPath"
```