This is a provides Bash alias-like to Windows.
It supports Bash-like arguments $1, "$@", etc
, nested command $( ... )
, and mruby as a unique feature.
Download from releases
Finally, add directories(C:/path/to/alias-exe
(For alias.exe) and C:/path/to/alias-exe/list
(For created alias list) to PATH.
Support scoop.sh, you can install alias-exe from wordijp/scoop-bucket.
> scoop bucket add wordijp https://github.com/wordijp/scoop-bucket
> scoop install wordijp/alias-exe
simple
When you execute alias.exe
directly, it manage command the alias list.
Please check the help for details.
> alias help
When executed a symbolic link created by alias edit <alias_name>
, it executes the command and mruby code.
The execution contents are saved as a txt file in the %USERPROFILE%/.alias-exe/list
directory.
> alias edit hello
Launch editor is vim
or notepad
.
# hello.txt
echo hello $(echo world)
.
├── alias.exe
└── list
└── hello.exe -> ../alias.exe
%USERPROFILE%/.alias-exe
└── list
└── hello.txt
See document for details.
offline file is docs/index.html
There is some Support for
- run command
- nested command
$( ... )
- arguments
- bash-like arguments
$0
- alias name
$1
,$2
,$3
, ...,$9
$#
"$@"
- unique arguments
"$+"
- Expands arguments on a single line, like
"$*"
, but keeps asterisks it. - ex)
echo "$+"
, run> test_alias "ab cd" fo* bar
, expands arguments is"ab cd fo* bar"
- Expands arguments on a single line, like
- bash-like arguments
- built-in commands
- @set <key>=<value>
- Set environment variable(command prompt-like)
- @pushd <path>
- Save and then change the current directory(bash-like)
- @popd
- Restore the top entry from the directory stack(bash-like)
- @set <key>=<value>
- mruby as glue code
```ruby
code
```
- nested mruby(ERB-like)
<%= ... %>
Create hello
alias:
> alias edit hello
edit:
# hello.txt
echo hello $(echo world)
run:
> hello
hello world
mruby example
> alias edit mruby-example
# mruby-example.txt
```ruby
puts 'from mruby'
def say
"hello world"
end
ary = [1, 'mruby array', 2, 'to', 'cmd', 3.14]
```
echo <%= say %>
echo <%= ary.to_cmd %>
> mruby-example
from mruby
"hello world"
1 "mruby array" 2 to cmd 3.14
Nested commmand example
> alias edit nested-command-example
# nested-command-example.txt
```ruby
underscore = "_"
hello_world = "success!"
```
# $1: hello, $2: world
# need sed command installed, for example, msys2
echo <%= $(echo $(echo $1)<%= underscore %>XXX | sed 's/XXX/$(echo $2)/g') %>
> nested-command-example hello world
success!
FizzBuzz example
Implement it in a weird way :)
> alias edit rng
# rng.txt
```ruby
for i in $1..$2 do
puts i
end
```
> alias edit fizzbuzz
# fizzbuzz.txt
```ruby
while s = STDIN.gets
n = s.to_i
if n > 0 && n % 15 == 0
puts "FizzBuzz"
else
puts s.chomp
end
end
```
> alias edit fizz
# fizz.txt
```ruby
while s = STDIN.gets
n = s.to_i
if n > 0 && n % 3 == 0
puts "Fizz"
else
puts s.chomp
end
end
```
> alias edit buzz
# buzz.txt
```ruby
while s = STDIN.gets
n = s.to_i
if n > 0 && n % 5 == 0
puts "Buzz"
else
puts s.chomp
end
end
```
Finally, run
> rng 1 100 | fizzbuzz | fizz | buzz
1
2
Fizz
4
Buzz
Fizz
...
97
98
Fizz
Buzz
MIT