You are not logged in.

#1 2018-05-18 12:45:58

misko_2083
Member
Registered: 2016-05-24
Posts: 93

Bash autocomplete and gui

I have next in my ~/.bashrc

# You must restart the terminal after changing .bashrc
select_files() {
OIFS=$IFS
IFS=$'\n' 
local files=" $(for line in $(yad --file-selection --multiple --title="Select a File" --separator='\n' --width=800 --height=650 2> /dev/null | tr '|' ' '); do printf "'%s' " "$line"; done)"
IFS=$OIFS
READLINE_LINE="${READLINE_LINE:0:READLINE_POINT}$files${READLINE_LINE:READLINE_POINT}"
READLINE_POINT=$((READLINE_POINT + ${#files}))
}

bind -x '"\C-g":select_files'

It binds ctrl+g with select_files function.
When ctrl+g is pressed a yad file-selection dialog appears and if file(s) or dir(s) are selected their paths will be printed in the terminal.

Is there a way to do something similar with the bash autocomplete?
Something like binding Tab key with autocomplete function (bind -x '"\t":autocomplete') and then using yad of jgmenu to select a string an then insert it back into terminal.

Offline

Board footer

Powered by FluxBB