Reflector with bash completion

Yesterday I added bash completion support for the reflector app.
As reflector is a great app, I think it deserves bash completion support.

Note that the support is not included in package reflector but in reflector-simple (because I’m not maintaining reflector).

So if anyone has issues with upgrading reflector-simple, this may be the reason. If so, please report! :sweat_smile:

1 Like
reflector-simple 
usage: reflector [-h] [--connection-timeout n] [--download-timeout n]
                 [--list-countries] [--cache-timeout n] [--url URL]
                 [--save <filepath>] [--sort {age,rate,country,score,delay}]
                 [--verbose] [--info] [-a n] [-c <country name or code>]
                 [-f n] [-i <regex>] [-x <regex>] [-l n] [--score n] [-n n]
                 [-p <protocol>] [--completion-percent [0-100]] [--isos]
                 [--ipv4] [--ipv6]
reflector: error: unrecognized arguments: https


I got this running reflector-simple from terminal

same for running it from welcome…

Could you show your config files /etc/reflector*

cat /etc/reflector*

### Default settings for reflector-simple
#
#
# Below you'll find the *default* values
# used by reflector-simple. The values below are shown as
# commented out since they are the defaults.
# These are simply options of the reflector app.
# Use command 'reflector --help' for more info about the options.
#
# Note:
# if your detected location (country) has Arch mirror(s),
# then (by default) it will be selected in reflector-simple.
#
# If your country has no Arch mirrors, then you must give
# one or more countries here or select in reflector-simple.
#
# Regardless of the above, you may give any selection
# of countries here.
############# Now the default values: ###############

## Save the resulting mirrorlist here:
#--save /etc/pacman.d/mirrorlist

## How recent mirrorlist should be (in hours:)
--age 2

## Which protocols should be supported (https preferred):
--protocol http https

## How many mirrors (at most) you want in the list:
--number 23

## How to sort the ranked mirrorlist
## (e.g. 'rate' for speed, 'age' for newest packages):
--sort rate

## Choose countries. By default your local country
## will likely be detected.
## To see supported countries, use command 'reflector --list-countries'.
## Examples (note the different syntaxes):
--country Germany,Netherlands,Poland
##    -cBR,FI,DE,NL
##    --country "United States"

Need a comma between http and https:
--protocol http,https

1 Like

two lines needed:
--protocol http
--protocol https

if i use --protocol http,https it only takes https ?

You can use either one, two lines, or one line with commas. So also
--protocol http,https should work.
I’m curious why you use http?

http only to see if option is working :wink:

1 Like

reflector --protocol https,http -cDE,NL,pl
should work too.

And:
reflector --protocol https,http -cDE,NL,pl --sort country

reflector --protocol https,http -c DE,NL,pl
################################################################################
################# Arch Linux mirrorlist generated by Reflector #################
################################################################################

# With:       reflector --protocol https,http -cDE,NL,pl
# When:       2020-12-27 10:41:53 UTC
# From:       https://www.archlinux.org/mirrors/status/json/
# Retrieved:  2020-12-27 10:37:30 UTC
# Last Check: 2020-12-27 08:59:22 UTC

only reflector-simple does not take it, may kinda issue sed it?

I see what you mean, reflector-simple does not initially show the http you might have in the config file. But it will use anyway it, as you can see in the resulting mirrorlist.

Not initially showing all values from the config file is a “known bug” in reflector-simple.
Hope I some day get to fix that too. :sweat_smile:

Fortunately reflector-simple still uses the values correctly, so one needs to remember (or check) what the values are in the config file.

Other reflector (not simple) difficulties:

┌23:29:56 WD= [~]
└───freebird@nest ─▶$ reflector --country Canada,US --age 3 --protocol https --sort country --save /etc/pacman.d/mirrorlist
sorting by None <function country_sort_key.<locals>.key_func at 0x7f31c3cc7ca0>
error: Permission denied


┌23:30:47 WD= [~]
└───freebird@nest ─▶$ reflector --country Canada,US --age 3 --protocol https --sort rate --save /etc/pacman.d/mirrorlist
[2020-12-26 23:31:37] WARNING: failed to rate http(s) download (https://mirror.mia11.us.leaseweb.net/archlinux/community/os/x86_64/community.db): Download timed out after 5 second(s).
[2020-12-26 23:32:03] WARNING: failed to rate http(s) download (https://mirror.sergal.org/archlinux/community/os/x86_64/community.db): Download timed out after 5 second(s).
[2020-12-26 23:32:28] WARNING: failed to rate http(s) download (https://mirror.ava.dev/archlinux/community/os/x86_64/community.db): HTTP Error 403: Forbidden
error: Permission denied

Strange things go bump in the night… :grin: No wonder I got slow results…


it will double the entries when have --protocol http,https in config and then tag it in yad screen again…
and the same if I do have only https in config.

Yeah… you’ll need sudo…

1 Like

I just added support for having --protocol https,http in the config file, so now one hurdle less. :wink:

1 Like

Is that the one already in my updates list? :grin: Anything else to check? (going to 1.11-1 according to checkupdatesext)

That’s the latest from today.

I wish it had a Changelog like Welcome to keep up-to-date with!

Well there is!
Just look at the web address of the welcome changelog, and change it to reflector-simple.

Yeah - I get there that way - but I have to keep opening Welcome! Maybe I can wmctrl it to open on my other monitor, so I can keep it around :grin: Or kpie…