Skip to content
This repository was archived by the owner on Jul 16, 2024. It is now read-only.

Commit 0ac2244

Browse files
committedOct 5, 2023
Fish shell support
·
0.3.10.2.0
1 parent 465adf0 commit 0ac2244

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed
 

‎README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,13 @@ $ curl -# -L https://github.com/svandragt/php-activate/tarball/main | tar -xz --
2424
Add the following line to your shell rc script:
2525

2626
```
27-
source $HOME/opt/php-activate/php-activate.sh # or your place of choice
27+
# Fish
28+
source $HOME/opt/php-activate/php-activate.fish
29+
# Bash or ZSH:
30+
source $HOME/opt/php-activate/php-activate.sh
2831
```
2932

33+
3034
## Run examples
3135

3236
```shell

‎php-activate.fish

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env fish
2+
3+
function php-activate
4+
if not test -z $argv[1]
5+
set php_versions (update-alternatives --query php | grep Alternative | cut -d ' ' -f2)
6+
if string match "*$argv[1]" $php_versions
7+
set -xg PHP_PICKED (string match "*$argv[1]" $php_versions | head -n 1)
8+
function php
9+
$PHP_PICKED $argv
10+
end
11+
echo "Activated: $PHP_PICKED"
12+
php --version | grep built
13+
else
14+
echo "Error: No matching PHP version found. Use one of the following:"
15+
echo "$php_versions"
16+
end
17+
return
18+
end
19+
20+
if not test -z $PHP_PICKED
21+
echo "Deactivated: $PHP_PICKED"
22+
set -e PHP_PICKED
23+
functions -e php
24+
php --version | grep built
25+
return
26+
end
27+
end

0 commit comments

Comments
 (0)
This repository has been archived.