Skip to content

Commit a541696

Browse files
committed
Added the Fish Shell Language
1 parent 00a8895 commit a541696

File tree

8 files changed

+89
-0
lines changed

8 files changed

+89
-0
lines changed

docs/resources/fish-logo-24.png

903 Bytes
Loading

docs/resources/fish-logo-240.png

15.8 KB
Loading

docs/resources/fish-logo-64.png

2.36 KB
Loading

fish/README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<img src="https://raw.githubusercontent.com/rtoal/polyglot/master/docs/resources/fish-logo-64.png">
2+
3+
# Fish Explorations:
4+
5+
To begin coding in Fish, you will need to install the shell Fish. Here are some of the options you can do to install
6+
7+
**MacOS/Linux Installation**:
8+
9+
Homebrew:
10+
11+
```sh
12+
brew install fish
13+
```
14+
15+
**Windows**:
16+
17+
In Msys2 Shell, type:
18+
19+
```sh
20+
pacman -S fish
21+
```
22+
23+
After downloading, go to the folder for Msys2 and navigate to usr then bin. There, you should see the `fish.exe` file inside the folder. Then, copy the path and add it to your environmental variables.
24+
25+
If you are struggling to install the shell, then you can go to the [Fish Homepage](https://fishshell.com/) for more options.
26+
27+
Once you have installed fish, you can run the example fish files using the following command:
28+
29+
```
30+
fish hello.fish
31+
```
32+
33+
## About Fish:
34+
35+
Fish, also known as the **F**riendly **I**nterface **SH**ell, and like the name sggests, it aims to be a smart and user-friendly command line shell for Linux and macOS. It claims to add more convenient features that other shells may not have built-in, such as type autosuggestion, syntax highlighting, abbreiations, and more, allowing users to be more productive within their command line terminal.
36+
37+
## Fish Resources:
38+
39+
Continue your study of Fish via:
40+
41+
- [Fish Homepage](https://fishshell.com/)
42+
- [Fish Documentation](https://fishshell.com/docs/current/index.html)
43+
- [Fish GitHub](https://github.com/fish-shell/fish-shell)

fish/clockhands.fish

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
for i in (seq 0 10)
2+
set t (math floor \(\(43200 x $i + 21600\) / 11\))
3+
set h (math floor $t / 3600 )
4+
set m (math floor $t / 60 % 60)
5+
set s (math $t % 60)
6+
if test $h -eq 0
7+
set h 12
8+
end
9+
printf "%02d:%02d:%02d\n" $h $m $s
10+
end

fish/hello.fish

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
echo Hello, World!

fish/test.ps1

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
function Assert-MatchTests {
2+
param (
3+
[Parameter(Mandatory = $true, ValueFromPipeline)] $TestResult
4+
)
5+
6+
if ($null -ne $TestResult) {
7+
Write-Error "Output does not match expected results."
8+
}
9+
}
10+
11+
$Error.clear()
12+
fish "$PSScriptRoot\clockhands.fish" |
13+
Compare-Object (Get-Content "$PSScriptRoot\..\test\clockhands_expected") |
14+
Assert-MatchTests &&
15+
fish "$PSScriptRoot\hello.fish" &&
16+
fish "$PSScriptRoot\triple.fish" |
17+
Compare-Object (Get-Content "$PSScriptRoot\..\test\triple_expected") |
18+
Assert-MatchTests &&
19+
ForEach-Object 'foo';
20+
21+
if ($Error -or !$?) {
22+
"*** FISH TESTS FAILED ***"
23+
}
24+
else {
25+
"FISH TESTS PASSED"
26+
}

fish/triple.fish

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
for c in (seq 40)
2+
for b in (seq (math $c - 1))
3+
for a in (seq (math $b - 1))
4+
if test (math $a ^ 2 + $b ^ 2) -eq (math $c ^ 2)
5+
echo $a, $b, $c
6+
end
7+
end
8+
end
9+
end

0 commit comments

Comments
 (0)