Skip to content

Commit 8b8028e

Browse files
committed
Add: fzflist opt for compatibility with fzf
1 parent ba54fd8 commit 8b8028e

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,17 @@ setproxy
5151
setproxy unset
5252
```
5353

54+
## Plus Tip: Use setproxy with [fzf](https://github.com/junegunn/fzf) for an even smoother experience.
55+
56+
##### Put this in your `$PROFILE` (Powershell 7)
57+
58+
```ps1
59+
function fpx{
60+
$selection=$(setproxy fzflist | fzf --height 40% --pointer=' ' --border --info=inline --prompt='▶ ' --color=fg+:#FFFFFF,bg+:#FF0000,gutter:-1 --exact) -split '\s+' | Select-Object -First 1;
61+
setproxy $selection
62+
}
63+
```
64+
65+
And run `fpx` to witness sorcery.
66+
5467
### Inspired from [proxyman](https://github.com/himanshub16/ProxyMan) and [nits-proxy](https://github.com/resyfer/nits_proxy)

install.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ echo "Creating Directory: $pastedir" &&
1010
New-Item -Path "$env:LOCALAPPDATA" -Name "$dirname" -ItemType "directory" -Force 1>nul &&
1111

1212
echo "Copying Scripts..." &&
13-
Copy-Item "$currendir/*" -Destination $pastedir -Force
13+
Copy-Item "$currendir/setproxy.ps1" -Destination $pastedir -Force
1414

1515
if (!$update){
1616
echo "Setting Environment Vars..."

setproxy.ps1

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,18 @@ function unsetproxy{
4040
Write-Output 'Done...';
4141
}
4242

43+
function fzflist($JsonProfiles){
44+
$output=""
45+
forEach($profile in $JsonProfiles.profiles){
46+
$output+=$profile.nickname + " " + ($profile.name).Substring(1) + " " + $profile.proxyserver+":"+$profile.proxyport + "`n"
47+
}
48+
$output+="unset" + " " + "Remove all proxy configs"
49+
Write-Output $output
50+
}
51+
4352
function create{
4453
$name = Read-Host "Enter a Name for Profile"
45-
if ($name -in ("create", "list", "unset")){
54+
if ($name -in ("create", "list", "unset", "fzflist")){
4655
Write-Output "Cannot use reserved keywords for profile names"
4756
exit;
4857
}
@@ -101,6 +110,10 @@ elseif($argv -eq "list"){
101110
}
102111
exit;
103112
}
113+
elseif($argv -eq "fzflist"){
114+
fzflist($JsonProfiles);
115+
exit;
116+
}
104117
elseif($argv -eq "create"){
105118
create;
106119
exit;

0 commit comments

Comments
 (0)