How do i set-up shell auto complete? Is there a step-by-step tutorial available?
My shell is: bash. I have installed bash-completion. I have a script to install.
Where do i install the script to make this work?
[john@johnPC ~]$ which $SHELL
/bin/bash
System :
[john@johnPC ~]$ inxi -zv8
System:
Kernel: 6.6.47-1-MANJARO arch: x86_64 bits: 64 compiler: gcc v: 14.2.1
clocksource: tsc avail: hpet,acpi_pm
parameters: BOOT_IMAGE=/boot/vmlinuz-6.6-x86_64
root=UUID=006e2571-c404-468d-b0e3-99124c0e2644 rw quiet splash apparmor=1
security=apparmor resume=UUID=d7c4842e-f940-460f-9adf-3e788d0c882d
udev.log_priority=3
Desktop: Xfce v: 4.18.1 tk: Gtk v: 3.24.43 wm: xfwm4 v: 4.18.0
with: xfce4-panel tools: xfce4-screensaver vt: 7 dm: LightDM v: 1.32.0
Distro: Manjaro base: Arch Linux
Machine:
Type: Desktop System: Micro-Star product: MS-7C87 v: 1.0
serial: <superuser required>
Mobo: Micro-Star model: B450M BAZOOKA MAX WIFI (MS-7C87) v: 1.0
serial: <superuser required> uuid: <superuser required> UEFI: American
Megatrends LLC. v: 1.90 date: 05/24/2022
Battery:
Device-1: hidpp_battery_0 model: Logitech Wireless Keyboard K360
serial: <filter> charge: 55% (should be ignored) rechargeable: yes
status: discharging
Device-2: hidpp_battery_1 model: Logitech Wireless Mouse MX Master 2S
serial: <filter> charge: 55% (should be ignored) rechargeable: yes
status: discharging
Memory:
System RAM: total: 32 GiB available: 27.29 GiB used: 3.25 GiB (11.9%)
Message: For most reliable report, use superuser + dmidecode.
Array-1: capacity: 128 GiB slots: 4 modules: 4 EC: None
max-module-size: 32 GiB note: est.
Device-1: Channel-A DIMM 0 type: DDR4 detail: synchronous unbuffered
(unregistered) size: 8 GiB speed: 2133 MT/s volts: note: check curr: 1
min: 1 max: 1 width (bits): data: 64 total: 64
manufacturer: Micron Technology part-no: 16ATF1G64AZ-2G1B1
serial: <filter>
Device-2: Channel-A DIMM 1 type: DDR4 detail: synchronous unbuffered
(unregistered) size: 8 GiB speed: 2133 MT/s volts: note: check curr: 1
min: 1 max: 1 width (bits): data: 64 total: 64
manufacturer: Micron Technology part-no: 16ATF1G64AZ-2G1B1
serial: <filter>
Device-3: Channel-B DIMM 0 type: DDR4 detail: synchronous unbuffered
(unregistered) size: 8 GiB speed: 2133 MT/s volts: note: check curr: 1
min: 1 max: 1 width (bits): data: 64 total: 64
manufacturer: Micron Technology part-no: 16ATF1G64AZ-2G1B1
serial: <filter>
Device-4: Channel-B DIMM 1 type: DDR4 detail: synchronous unbuffered
(unregistered) size: 8 GiB speed: 2133 MT/s volts: note: check curr: 1
min: 1 max: 1 width (bits): data: 64 total: 64
manufacturer: Micron Technology part-no: 16ATF1G64AZ-2G1B1
serial: <filter>
PCI Slots:
Permissions: Unable to run dmidecode. Root privileges required.
CPU:
Info: model: AMD Ryzen 5 5600G with Radeon Graphics bits: 64 type: MT MCP
arch: Zen 3 gen: 3 level: v3 note: check built: 2021-22
process: TSMC n7 (7nm) family: 0x19 (25) model-id: 0x50 (80) stepping: 0
microcode: 0xA50000D
Topology: cpus: 1x dies: 1 clusters: 1 cores: 6 threads: 12 tpc: 2
smt: enabled cache: L1: 384 KiB desc: d-6x32 KiB; i-6x32 KiB L2: 3 MiB
desc: 6x512 KiB L3: 16 MiB desc: 1x16 MiB
Speed (MHz): avg: 400 min/max: 400/4464 scaling: driver: amd-pstate-epp
governor: powersave cores: 1: 400 2: 400 3: 400 4: 400 5: 400 6: 400 7: 400
8: 400 9: 400 10: 400 11: 400 12: 400 bogomips: 93456
Flags: 3dnowprefetch abm adx aes aperfmperf apic arat avic avx avx2 bmi1
bmi2 bpext cat_l3 cdp_l3 clflush clflushopt clwb clzero cmov cmp_legacy
constant_tsc cpb cppc cpuid cqm cqm_llc cqm_mbm_local cqm_mbm_total
cqm_occup_llc cr8_legacy cx16 cx8 de debug_swap decodeassists erms
extapic extd_apicid f16c flushbyasid fma fpu fsgsbase fsrm fxsr fxsr_opt
ht hw_pstate ibpb ibrs ibs invpcid irperf lahf_lm lbrv lm mba mca mce
misalignsse mmx mmxext monitor movbe msr mtrr mwaitx nonstop_tsc nopl npt
nrip_save nx ospke osvw overflow_recov pae pat pausefilter pclmulqdq
pdpe1gb perfctr_core perfctr_llc perfctr_nb pfthreshold pge pku pni
popcnt pse pse36 rapl rdpid rdpru rdrand rdseed rdt_a rdtscp rep_good sep
sha_ni skinit smap smca smep ssbd sse sse2 sse4_1 sse4_2 sse4a ssse3
stibp succor svm svm_lock syscall tce topoext tsc tsc_scale umip
user_shstk v_spec_ctrl v_vmsave_vmload vaes vgif vmcb_clean vme vmmcall
vpclmulqdq wbnoinvd wdt x2apic xgetbv1 xsave xsavec xsaveerptr xsaveopt
xsaves
Vulnerabilities:
Type: gather_data_sampling status: Not affected
Type: itlb_multihit status: Not affected
Type: l1tf status: Not affected
Type: mds status: Not affected
Type: meltdown status: Not affected
Type: mmio_stale_data status: Not affected
Type: reg_file_data_sampling status: Not affected
Type: retbleed status: Not affected
Type: spec_rstack_overflow status: Vulnerable: Safe RET, no microcode
Type: spec_store_bypass mitigation: Speculative Store Bypass disabled via
prctl
Type: spectre_v1 mitigation: usercopy/swapgs barriers and __user pointer
sanitization
Type: spectre_v2 mitigation: Retpolines; IBPB: conditional; IBRS_FW;
STIBP: always-on; RSB filling; PBRSB-eIBRS: Not affected; BHI: Not
affected
Type: srbds status: Not affected
Type: tsx_async_abort status: Not affected
Graphics:
Device-1: Advanced Micro Devices [AMD/ATI] Cezanne [Radeon Vega Series /
Radeon Mobile Series] driver: amdgpu v: kernel arch: GCN-5 code: Vega
process: GF 14nm built: 2017-20 pcie: gen: 3 speed: 8 GT/s lanes: 16
link-max: gen: 4 speed: 16 GT/s ports: active: HDMI-A-1
empty: HDMI-A-2,HDMI-A-3 bus-ID: 30:00.0 chip-ID: 1002:1638 class-ID: 0300
temp: 27.0 C
Device-2: HDR webcam driver: snd-usb-audio,uvcvideo type: USB rev: 2.0
speed: 480 Mb/s lanes: 1 mode: 2.0 bus-ID: 1-4:2 chip-ID: 1d6c:0103
class-ID: 0102
Display: x11 server: X.org v: 1.21.1.13 compositor: xfwm4 v: 4.18.0
driver: X: loaded: amdgpu unloaded: modesetting alternate: fbdev,vesa
dri: radeonsi gpu: amdgpu display-ID: :0.0 screens: 1
Screen-1: 0 s-res: 1920x1080 s-size: <missing: xdpyinfo>
Monitor-1: HDMI-A-1 mapped: HDMI-A-0 model: Samsung C32F39M
serial: <filter> built: 2019 res: 1920x1080 hz: 60 dpi: 70 gamma: 1.2
chroma: red: x: 0.647 y: 0.337 green: x: 0.325 y: 0.616 blue: x: 0.145
y: 0.055 white: x: 0.314 y: 0.329 size: 698x393mm (27.48x15.47")
diag: 801mm (31.5") ratio: 16:9 modes: 1920x1080, 1680x1050, 1600x900,
1280x1024, 1440x900, 1280x800, 1280x720, 1024x768, 800x600, 720x576,
720x480, 640x480
API: EGL v: 1.5 hw: drv: amd radeonsi platforms: device: 0 drv: radeonsi
device: 1 drv: swrast gbm: drv: kms_swrast surfaceless: drv: radeonsi x11:
drv: radeonsi inactive: wayland
API: OpenGL v: 4.6 compat-v: 4.5 vendor: amd mesa v: 24.1.6-arch1.1
glx-v: 1.4 direct-render: yes renderer: AMD Radeon Graphics (radeonsi
renoir LLVM 18.1.8 DRM 3.54 6.6.47-1-MANJARO) device-ID: 1002:1638
memory: 3.91 GiB unified: no
Audio:
Device-1: Advanced Micro Devices [AMD/ATI] Renoir Radeon High Definition
Audio vendor: Micro-Star MSI driver: snd_hda_intel v: kernel pcie: gen: 3
speed: 8 GT/s lanes: 16 link-max: gen: 4 speed: 16 GT/s bus-ID: 30:00.1
chip-ID: 1002:1637 class-ID: 0403
Device-2: Advanced Micro Devices [AMD] Family 17h/19h HD Audio
vendor: Micro-Star MSI driver: snd_hda_intel v: kernel pcie: gen: 3
speed: 8 GT/s lanes: 16 link-max: gen: 4 speed: 16 GT/s bus-ID: 30:00.6
chip-ID: 1022:15e3 class-ID: 0403
Device-3: HDR webcam driver: snd-usb-audio,uvcvideo type: USB rev: 2.0
speed: 480 Mb/s lanes: 1 mode: 2.0 bus-ID: 1-4:2 chip-ID: 1d6c:0103
class-ID: 0102
API: ALSA v: k6.6.47-1-MANJARO status: kernel-api with: aoss
type: oss-emulator tools: alsactl,alsamixer,amixer
Server-1: sndiod v: N/A status: off tools: aucat,midicat,sndioctl
Server-2: JACK v: 1.9.22 status: off tools: N/A
Server-3: PipeWire v: 1.2.3 status: active with: 1: pipewire-pulse
status: active 2: wireplumber status: active 3: pipewire-alsa type: plugin
tools: pactl,pw-cat,pw-cli,wpctl
Network:
Device-1: Realtek RTL8111/8168/8211/8411 PCI Express Gigabit Ethernet
vendor: Micro-Star MSI driver: r8169 v: kernel pcie: gen: 1 speed: 2.5 GT/s
lanes: 1 port: f000 bus-ID: 21:00.0 chip-ID: 10ec:8168 class-ID: 0200
IF: eno1 state: down mac: <filter>
Device-2: Intel Dual Band Wireless-AC 3168NGW [Stone Peak] driver: iwlwifi
v: kernel pcie: gen: 1 speed: 2.5 GT/s lanes: 1 bus-ID: 22:00.0
chip-ID: 8086:24fb class-ID: 0280
IF: wlp34s0 state: up mac: <filter>
IP v4: <filter> type: dynamic noprefixroute scope: global
broadcast: <filter>
IP v6: <filter> type: dynamic noprefixroute scope: global
IP v6: <filter> type: dynamic noprefixroute scope: global
IP v6: <filter> type: noprefixroute scope: link
IF-ID-1: docker0 state: down mac: <filter>
IP v4: <filter> scope: global broadcast: <filter>
IF-ID-2: ipv6leakintrf0 state: unknown speed: N/A duplex: N/A
mac: <filter>
IP v6: <filter> type: noprefixroute scope: global
IP v6: <filter> type: noprefixroute scope: link
IF-ID-3: tun0 state: unknown speed: 10000 Mbps duplex: full mac: N/A
IP v4: <filter> type: noprefixroute scope: global broadcast: <filter>
IP v6: <filter> virtual: stable-privacy proto kernel_ll scope: link
Info: services: NetworkManager,wpa_supplicant
WAN IP: <filter>
Bluetooth:
Device-1: Intel Wireless-AC 3168 Bluetooth driver: btusb v: 0.8 type: USB
rev: 2.0 speed: 12 Mb/s lanes: 1 mode: 1.1 bus-ID: 1-5:3 chip-ID: 8087:0aa7
class-ID: e001
Report: btmgmt ID: hci0 rfk-id: 0 state: up address: <filter> bt-v: 4.2
lmp-v: 8 status: discoverable: yes pairing: yes class-ID: 7c0104
Logical:
Message: No logical block device data found.
RAID:
Message: No RAID data found.
Drives:
Local Storage: total: 2.12 TiB used: 165.72 GiB (7.6%)
SMART Message: Required tool smartctl not installed. Check --recommends
ID-1: /dev/nvme0n1 maj-min: 259:0 vendor: Silicon Power
model: SPCC M.2 PCIe SSD size: 476.94 GiB block-size: physical: 512 B
logical: 512 B speed: 31.6 Gb/s lanes: 4 tech: SSD serial: <filter>
fw-rev: V0523B0 temp: 34.9 C scheme: GPT
ID-2: /dev/sda maj-min: 8:0 vendor: Western Digital
model: WD3200AVJS-63B6A0 size: 298.09 GiB block-size: physical: 512 B
logical: 512 B speed: 3.0 Gb/s tech: N/A serial: <filter> fw-rev: 3A02
scheme: GPT
ID-3: /dev/sdb maj-min: 8:16 vendor: Seagate model: ST31000528AS
size: 931.51 GiB block-size: physical: 512 B logical: 512 B speed: 3.0 Gb/s
tech: HDD rpm: 7200 serial: <filter> fw-rev: CC38 scheme: GPT
ID-4: /dev/sdc maj-min: 8:32 vendor: Samsung model: ST500LM012 HN-M500MBB
size: 465.76 GiB block-size: physical: 4096 B logical: 512 B speed: 3.0 Gb/s
tech: HDD rpm: 5400 serial: <filter> fw-rev: 0003 scheme: GPT
Message: No optical or floppy data found.
Partition:
ID-1: / raw-size: 467.84 GiB size: 459.43 GiB (98.20%)
used: 165.72 GiB (36.1%) fs: ext4 dev: /dev/nvme0n1p2 maj-min: 259:2
label: N/A uuid: 006e2571-c404-468d-b0e3-99124c0e2644
ID-2: /boot/efi raw-size: 300 MiB size: 299.4 MiB (99.80%)
used: 296 KiB (0.1%) fs: vfat dev: /dev/nvme0n1p1 maj-min: 259:1 label: N/A
uuid: 5924-F7F7
Swap:
Kernel: swappiness: 60 (default) cache-pressure: 100 (default) zswap: yes
compressor: zstd max-pool: 20%
ID-1: swap-1 type: partition size: 8.8 GiB used: 0 KiB (0.0%) priority: -2
dev: /dev/nvme0n1p3 maj-min: 259:3 label: swap
uuid: d7c4842e-f940-460f-9adf-3e788d0c882d
Unmounted:
ID-1: /dev/sda1 maj-min: 8:1 size: 100 MiB fs: vfat label: N/A
uuid: 8ED7-2DA2
ID-2: /dev/sda2 maj-min: 8:2 size: 16 MiB fs: ntfs label: h
uuid: 0FDF0C850FDF0C85
ID-3: /dev/sda3 maj-min: 8:3 size: 80.92 GiB fs: ntfs label: Boot Disc
uuid: 1612D8A212D887DF
ID-4: /dev/sda4 maj-min: 8:4 size: 216.57 GiB fs: ext4 label: John_223
uuid: 05c0fa63-faa2-4aa3-a13b-b6f35b52868d
ID-5: /dev/sda5 maj-min: 8:5 size: 499 MiB fs: ext4 label: N/A
uuid: 4a5f8f45-6f05-4c57-92ee-4703e22823d9
ID-6: /dev/sdb1 maj-min: 8:17 size: 95.45 GiB fs: ext4 label: John_102
uuid: 18c9ee3c-9d73-4262-96d8-05cb367223bf
ID-7: /dev/sdb3 maj-min: 8:19 size: 836.06 GiB fs: ext4 label: John_828
uuid: 9681ad2e-bbc3-4490-8f16-2bcc73e8cdc0
ID-8: /dev/sdc1 maj-min: 8:33 size: 465.76 GiB fs: ext4 label: John_500
uuid: fd1f35e4-77ef-4787-9efa-861696a65bfb
USB:
Hub-1: 1-0:1 info: hi-speed hub with single TT ports: 10 rev: 2.0
speed: 480 Mb/s (57.2 MiB/s) lanes: 1 mode: 2.0 chip-ID: 1d6b:0002
class-ID: 0900
Device-1: 1-4:2 info: HDR webcam type: video,audio
driver: snd-usb-audio,uvcvideo interfaces: 4 rev: 2.0
speed: 480 Mb/s (57.2 MiB/s) lanes: 1 mode: 2.0 power: 4mA
chip-ID: 1d6c:0103 class-ID: 0102
Device-2: 1-5:3 info: Intel Wireless-AC 3168 Bluetooth type: bluetooth
driver: btusb interfaces: 2 rev: 2.0 speed: 12 Mb/s (1.4 MiB/s) lanes: 1
mode: 1.1 power: 100mA chip-ID: 8087:0aa7 class-ID: e001
Hub-2: 1-8:4 info: Genesys Logic Hub ports: 4 rev: 2.0
speed: 480 Mb/s (57.2 MiB/s) lanes: 1 mode: 2.0 power: 100mA
chip-ID: 05e3:0608 class-ID: 0900
Device-1: 1-8.2:6 info: Logitech Unifying Receiver
type: keyboard,mouse,HID driver: logitech-djreceiver,usbhid interfaces: 3
rev: 2.0 speed: 12 Mb/s (1.4 MiB/s) lanes: 1 mode: 1.1 power: 98mA
chip-ID: 046d:c52b class-ID: 0300
Device-2: 1-8.3:7 info: Alcor Micro 8-in-1 Media Card Reader
type: mass storage driver: usb-storage interfaces: 1 rev: 1.1
speed: 12 Mb/s (1.4 MiB/s) lanes: 1 mode: 1.1 power: 100mA
chip-ID: 058f:9360 class-ID: 0806 serial: <filter>
Device-3: 1-9:5 info: Micro Star MYSTIC LIGHT type: HID
driver: hid-generic,usbhid interfaces: 1 rev: 1.1 speed: 12 Mb/s (1.4 MiB/s)
lanes: 1 mode: 1.1 power: 500mA chip-ID: 1462:7c87 class-ID: 0300
serial: <filter>
Hub-3: 2-0:1 info: super-speed hub ports: 4 rev: 3.1
speed: 10 Gb/s (1.16 GiB/s) lanes: 1 mode: 3.2 gen-2x1 chip-ID: 1d6b:0003
class-ID: 0900
Hub-4: 3-0:1 info: hi-speed hub with single TT ports: 4 rev: 2.0
speed: 480 Mb/s (57.2 MiB/s) lanes: 1 mode: 2.0 chip-ID: 1d6b:0002
class-ID: 0900
Hub-5: 4-0:1 info: super-speed hub ports: 2 rev: 3.1
speed: 10 Gb/s (1.16 GiB/s) lanes: 1 mode: 3.2 gen-2x1 chip-ID: 1d6b:0003
class-ID: 0900
Hub-6: 5-0:1 info: hi-speed hub with single TT ports: 4 rev: 2.0
speed: 480 Mb/s (57.2 MiB/s) lanes: 1 mode: 2.0 chip-ID: 1d6b:0002
class-ID: 0900
Hub-7: 6-0:1 info: super-speed hub ports: 2 rev: 3.1
speed: 10 Gb/s (1.16 GiB/s) lanes: 1 mode: 3.2 gen-2x1 chip-ID: 1d6b:0003
class-ID: 0900
Sensors:
System Temperatures: cpu: 32.4 C mobo: N/A gpu: amdgpu temp: 27.0 C
Fan Speeds (rpm): N/A
Repos:
Packages: 1822 pm: dpkg pkgs: 0 pm: pacman pkgs: 1781 libs: 404
tools: pamac,yay pm: flatpak pkgs: 25 pm: snap pkgs: 16
Active pacman repo servers in: /etc/pacman.d/mirrorlist
1: https://ziply.mm.fcix.net/manjaro/stable/$repo/$arch
2: https://volico.mm.fcix.net/manjaro/stable/$repo/$arch
3: https://nnenix.mm.fcix.net/manjaro/stable/$repo/$arch
4: https://edgeuno-bog2.mm.fcix.net/manjaro/stable/$repo/$arch
5: https://ask4.mm.fcix.net/manjaro/stable/$repo/$arch
6: https://mirror.archlinux.tw/Manjaro/stable/$repo/$arch
7: https://mirrors.gigenet.com/manjaro/stable/$repo/$arch
Processes:
CPU top: 5 of 337
1: cpu: 8.5% command: firefox pid: 3248 mem: 572.9 MiB (2.0%)
2: cpu: 5.0% command: firefox pid: 10850 mem: 287.9 MiB (1.0%)
3: cpu: 2.5% command: xfce4-terminal pid: 12023 mem: 46.6 MiB (0.1%)
4: cpu: 2.3% command: Xorg pid: 1307 mem: 169.5 MiB (0.6%)
5: cpu: 0.8% command: firefox pid: 10892 mem: 226.0 MiB (0.8%)
Memory top: 5 of 337
1: mem: 572.9 MiB (2.0%) command: firefox pid: 3248 cpu: 8.5%
2: mem: 456.9 MiB (1.6%) command: protonvpn-app started-by: python
pid: 2092 cpu: 0.5%
3: mem: 287.9 MiB (1.0%) command: firefox pid: 10850 cpu: 5.0%
4: mem: 226.0 MiB (0.8%) command: firefox pid: 10892 cpu: 0.8%
5: mem: 208.5 MiB (0.7%) command: firefox pid: 10591 cpu: 0.7%
Info:
Processes: 337 Power: uptime: 53m states: freeze,mem,disk suspend: deep
avail: s2idle wakeups: 0 hibernate: platform avail: shutdown, reboot,
suspend, test_resume image: 10.9 GiB services: upowerd,xfce4-power-manager
Init: systemd v: 256 default: graphical tool: systemctl
Compilers: clang: 18.1.8 gcc: 14.2.1 Shell: Bash v: 5.2.32
running-in: xfce4-terminal inxi: 3.3.36
[john@johnPC ~]$
The script:
#
# Bash completion definition for buku.
#
# Author:
# Arun Prakash Jana <engineerarun@gmail.com>
#
_buku () {
COMPREPLY=()
local IFS=$' \n'
local cur=$2 prev=$3
local -a opts opts_with_args
opts=(
-a --add
--ai
-c --comment
--cached
--colors
-d --delete
--deep
-e --export
--expand
-f --format
-h --help
-i --import
--immutable
-j --json
-k --unlock
-l --lock
-n --count
--nc
--np
-o --open
--oa
-p --print
-r --sreg
--replace
-s --sany
-S --sall
--url-redirect
--tag-redirect
--tag-error
--del-error
--export-on
--shorten
--offline
--suggest
-t --stag
--tacit
--tag
--threads
--title
-u --update
--url
-V
-v --version
-w --write
-x --exclude
-g --debug
)
opts_with_arg=(
-a --add
--cached
--colors
-e --export
--expand
-f --format
-i --import
--immutable
-n --count
-r --sreg
--replace
-s --sany
-S --sall
--shorten
--threads
--url
-x --exclude
)
# Do not complete non option names
[[ $cur == -* ]] || return 1
# Do not complete when the previous arg is an option expecting an argument
for opt in "${opts_with_arg[@]}"; do
[[ $opt == $prev ]] && return 1
done
# Complete option names
COMPREPLY=( $(compgen -W "${opts[*]}" -- "$cur") )
return 0
}
complete -F _buku buku