qb: use long option name !
This commit is contained in:
parent
cc67a57ee5
commit
e19ea4e5c4
34
qb
34
qb
@ -47,9 +47,9 @@ define_vars() { # {{{
|
|||||||
|
|
||||||
## Variables to get Qutebrowser currents buffers
|
## Variables to get Qutebrowser currents buffers
|
||||||
QUTEBROWSER_SESSION_FILE="/tmp/qutebrowser_buffers_zsbd"
|
QUTEBROWSER_SESSION_FILE="/tmp/qutebrowser_buffers_zsbd"
|
||||||
QUTEBROWSER_SOCKET_FILE="${XDG_RUNTIME_DIR}/qutebrowser/ipc-$(echo -n "$USER" | md5sum | cut -d' ' -f1)"
|
QUTEBROWSER_SOCKET_FILE="${XDG_RUNTIME_DIR}/qutebrowser/ipc-$(echo -n "$USER" | md5sum | cut --delimiter=' ' --fields=1)"
|
||||||
QUTEBROWSER_GLOBAL_CONTENT="/tmp/qutebrowser_global_content"
|
QUTEBROWSER_GLOBAL_CONTENT="/tmp/qutebrowser_global_content"
|
||||||
rm -f -- "${QUTEBROWSER_GLOBAL_CONTENT}" ; touch "${QUTEBROWSER_GLOBAL_CONTENT}"
|
rm --force -- "${QUTEBROWSER_GLOBAL_CONTENT}" ; touch "${QUTEBROWSER_GLOBAL_CONTENT}"
|
||||||
|
|
||||||
## Variables to get Qutebrowser *marks from current user
|
## Variables to get Qutebrowser *marks from current user
|
||||||
QUTEBROWSER_QUICKMARK_FILE="${HOME}/.config/qutebrowser/quickmarks"
|
QUTEBROWSER_QUICKMARK_FILE="${HOME}/.config/qutebrowser/quickmarks"
|
||||||
@ -58,7 +58,7 @@ define_vars() { # {{{
|
|||||||
## Qutebrowser search engines from current user configuration
|
## Qutebrowser search engines from current user configuration
|
||||||
QUTEBROWSER_SEARCHENGINE_FILE="${HOME}/.config/qutebrowser/config.py"
|
QUTEBROWSER_SEARCHENGINE_FILE="${HOME}/.config/qutebrowser/config.py"
|
||||||
QUTEBROWSER_SEARCHENGINE_LIST="/tmp/qutebrowser_searchengine.list"
|
QUTEBROWSER_SEARCHENGINE_LIST="/tmp/qutebrowser_searchengine.list"
|
||||||
rm -f -- "${QUTEBROWSER_SEARCHENGINE_LIST}" ; touch "${QUTEBROWSER_SEARCHENGINE_LIST}"
|
rm --force -- "${QUTEBROWSER_SEARCHENGINE_LIST}" ; touch "${QUTEBROWSER_SEARCHENGINE_LIST}"
|
||||||
|
|
||||||
## Default window pattern to search
|
## Default window pattern to search
|
||||||
QUTEBROWSER_WINDOW_TITLE="qutebrowser"
|
QUTEBROWSER_WINDOW_TITLE="qutebrowser"
|
||||||
@ -89,7 +89,7 @@ is_proc_running() { # {{{
|
|||||||
|
|
||||||
local_proc_pattern="${1}"
|
local_proc_pattern="${1}"
|
||||||
|
|
||||||
local_count_proc_pattern="$(pgrep -f -- "${local_proc_pattern}" | wc -l)"
|
local_count_proc_pattern="$(pgrep --full -- "${local_proc_pattern}" | wc --lines)"
|
||||||
|
|
||||||
case "${local_count_proc_pattern}" in
|
case "${local_count_proc_pattern}" in
|
||||||
0 ) ## No procs related to this pattern are running
|
0 ) ## No procs related to this pattern are running
|
||||||
@ -159,7 +159,7 @@ Focus with wmctrl."
|
|||||||
get_qutebrowser_buffers() { # {{{
|
get_qutebrowser_buffers() { # {{{
|
||||||
|
|
||||||
## Clear previous buffers list
|
## Clear previous buffers list
|
||||||
[ -f "${QUTEBROWSER_SESSION_FILE}" ] && rm -f -- "${QUTEBROWSER_SESSION_FILE}"
|
[ -f "${QUTEBROWSER_SESSION_FILE}" ] && rm --force -- "${QUTEBROWSER_SESSION_FILE}"
|
||||||
|
|
||||||
## Run save_buffers.py in Qutebrowser
|
## Run save_buffers.py in Qutebrowser
|
||||||
echo '{"args":[":save-window-and-buffers"], "target_arg":"", "protocol_version":1}' |\
|
echo '{"args":[":save-window-and-buffers"], "target_arg":"", "protocol_version":1}' |\
|
||||||
@ -202,9 +202,9 @@ get_qutebrowser_searchengine() { # {{{
|
|||||||
|
|
||||||
if [ -f "${QUTEBROWSER_SEARCHENGINE_FILE}" ]; then
|
if [ -f "${QUTEBROWSER_SEARCHENGINE_FILE}" ]; then
|
||||||
### Store search engine in global list (for display)
|
### Store search engine in global list (for display)
|
||||||
sed -n "s/c.url.searchengines\['\(.*\)'\] = '\(.*\)'$/\1 − \2/p" "${QUTEBROWSER_SEARCHENGINE_FILE}" >> "${QUTEBROWSER_GLOBAL_CONTENT}"
|
sed --silent "s/c.url.searchengines\['\(.*\)'\] = '\(.*\)'$/\1 − \2/p" "${QUTEBROWSER_SEARCHENGINE_FILE}" >> "${QUTEBROWSER_GLOBAL_CONTENT}"
|
||||||
### And in specific list to verify is an engine was used
|
### And in specific list to verify is an engine was used
|
||||||
sed -n "s/c.url.searchengines\['\(.*\)'\] = '\(.*\)'$/\1 − \2/p" "${QUTEBROWSER_SEARCHENGINE_FILE}" >> "${QUTEBROWSER_SEARCHENGINE_LIST}"
|
sed --silent "s/c.url.searchengines\['\(.*\)'\] = '\(.*\)'$/\1 − \2/p" "${QUTEBROWSER_SEARCHENGINE_FILE}" >> "${QUTEBROWSER_SEARCHENGINE_LIST}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -s "${QUTEBROWSER_SEARCHENGINE_LIST}" ]; then
|
if [ -s "${QUTEBROWSER_SEARCHENGINE_LIST}" ]; then
|
||||||
@ -260,12 +260,12 @@ Try to open ${RED}${url}${COLOR_DEBUG}"
|
|||||||
# }}}
|
# }}}
|
||||||
is_url_in_buffer() { # {{{
|
is_url_in_buffer() { # {{{
|
||||||
|
|
||||||
if grep -q -E -- "${url}" "${QUTEBROWSER_SESSION_FILE}"; then
|
if grep --quiet --extended-regexp -- "${url}" "${QUTEBROWSER_SESSION_FILE}"; then
|
||||||
debug_message "is_url_in_buffer − \
|
debug_message "is_url_in_buffer − \
|
||||||
A buffer is already opened with this URL."
|
A buffer is already opened with this URL."
|
||||||
return_is_url_in_buffer="0"
|
return_is_url_in_buffer="0"
|
||||||
buffer_id=$(grep -E -- "${url}" "${QUTEBROWSER_SESSION_FILE}" | cut -d" " -f1)
|
buffer_id=$(grep --extended-regexp -- "${url}" "${QUTEBROWSER_SESSION_FILE}" | cut --delimiter=" " --fields=1)
|
||||||
buffer_title=$(grep -E -- "${url}" "${QUTEBROWSER_SESSION_FILE}" | sed "s;${buffer_id} \(.*\) PyQt5.QtCore.QUrl.*;\1;")
|
buffer_title=$(grep --extended-regexp -- "${url}" "${QUTEBROWSER_SESSION_FILE}" | sed "s;${buffer_id} \(.*\) PyQt5.QtCore.QUrl.*;\1;")
|
||||||
|
|
||||||
switch_qutebrowser_buffer
|
switch_qutebrowser_buffer
|
||||||
else
|
else
|
||||||
@ -311,7 +311,7 @@ use_searchengine() { # {{{
|
|||||||
return_use_searchengine="0"
|
return_use_searchengine="0"
|
||||||
|
|
||||||
## If the search engine can't be found
|
## If the search engine can't be found
|
||||||
if ! grep --quiet -E "^${search_engine}" -- "${QUTEBROWSER_SEARCHENGINE_LIST}"; then
|
if ! grep --quiet --extended-regexp "^${search_engine}" -- "${QUTEBROWSER_SEARCHENGINE_LIST}"; then
|
||||||
### Set search engine to DEFAULT
|
### Set search engine to DEFAULT
|
||||||
search_engine="DEFAULT"
|
search_engine="DEFAULT"
|
||||||
### Be sure to take the complete request
|
### Be sure to take the complete request
|
||||||
@ -321,7 +321,7 @@ use_searchengine() { # {{{
|
|||||||
debug_message "use_searchengine − \
|
debug_message "use_searchengine − \
|
||||||
Use ${RED}${search_engine}${COLOR_DEBUG} search engine."
|
Use ${RED}${search_engine}${COLOR_DEBUG} search engine."
|
||||||
|
|
||||||
search_url=$(grep -E "^${search_engine}" -- ${QUTEBROWSER_SEARCHENGINE_LIST} | cut --delimiter=" " --field=3)
|
search_url=$(grep --extended-regexp "^${search_engine}" -- ${QUTEBROWSER_SEARCHENGINE_LIST} | cut --delimiter=" " --field=3)
|
||||||
debug_message "use_searchengine − \
|
debug_message "use_searchengine − \
|
||||||
Use URL ${RED}${search_url}${COLOR_DEBUG}"
|
Use URL ${RED}${search_url}${COLOR_DEBUG}"
|
||||||
|
|
||||||
@ -344,21 +344,21 @@ Try to manage ${RED}$(cat "${choice_temp_file}")${COLOR_DEBUG}."
|
|||||||
|
|
||||||
case "${local_content}" in
|
case "${local_content}" in
|
||||||
bb*http* ) ## Classic bookmark
|
bb*http* ) ## Classic bookmark
|
||||||
url=$(printf "%s" "${local_content}" | cut -d" " -f2)
|
url=$(printf "%s" "${local_content}" | cut --delimiter=" " --fields=2)
|
||||||
return_get_url="0"
|
return_get_url="0"
|
||||||
debug_message "get_url − \
|
debug_message "get_url − \
|
||||||
URL from classic bookmark ${RED}${url}${COLOR_DEBUG}."
|
URL from classic bookmark ${RED}${url}${COLOR_DEBUG}."
|
||||||
goto_url
|
goto_url
|
||||||
;;
|
;;
|
||||||
qq*http* ) ## Quickmark
|
qq*http* ) ## Quickmark
|
||||||
url=$(printf "%s" "${local_content}" | cut -d" " -f3)
|
url=$(printf "%s" "${local_content}" | cut --delimiter=" " --fields=3)
|
||||||
return_get_url="0"
|
return_get_url="0"
|
||||||
debug_message "get_url − \
|
debug_message "get_url − \
|
||||||
URL from quickmark ${RED}${url}${COLOR_DEBUG}."
|
URL from quickmark ${RED}${url}${COLOR_DEBUG}."
|
||||||
goto_url
|
goto_url
|
||||||
;;
|
;;
|
||||||
ff* ) ## Buffer
|
ff* ) ## Buffer
|
||||||
buffer_id=$(printf "%s" "${local_content}" | cut -d" " -f2)
|
buffer_id=$(printf "%s" "${local_content}" | cut --delimiter=" " --fields=2)
|
||||||
buffer_title=$(printf "%s" "${local_content}" | sed "s;ff ${buffer_id} \(.*\) PyQt5.QtCore.QUrl.*;\1;")
|
buffer_title=$(printf "%s" "${local_content}" | sed "s;ff ${buffer_id} \(.*\) PyQt5.QtCore.QUrl.*;\1;")
|
||||||
return_get_url="0"
|
return_get_url="0"
|
||||||
debug_message "get_url − \
|
debug_message "get_url − \
|
||||||
@ -366,7 +366,7 @@ Buffer title from Qutebrowser: ${RED}${buffer_title}${COLOR_DEBUG}."
|
|||||||
switch_qutebrowser_buffer
|
switch_qutebrowser_buffer
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
search_engine=$(printf "%s" "${local_content}" | cut -d" " -f1)
|
search_engine=$(printf "%s" "${local_content}" | cut --delimiter=" " --fields=1)
|
||||||
search_request=$(printf "%s" "${local_content}" | cut --complement --delimiter=" " --field=1)
|
search_request=$(printf "%s" "${local_content}" | cut --complement --delimiter=" " --field=1)
|
||||||
debug_message "get_url − \
|
debug_message "get_url − \
|
||||||
Try to search the content."
|
Try to search the content."
|
||||||
@ -420,7 +420,7 @@ if [ ! "${NBARGS}" -eq "0" ]; then
|
|||||||
manage_arg="0"
|
manage_arg="0"
|
||||||
|
|
||||||
# Parse all options (start with a "-") one by one
|
# Parse all options (start with a "-") one by one
|
||||||
while printf -- '%s' "${1}" | grep -q -E -- "^-+"; do
|
while printf -- '%s' "${1}" | grep --quiet --extended-regexp -- "^-+"; do
|
||||||
|
|
||||||
case "${1}" in
|
case "${1}" in
|
||||||
-d|--debug ) ## Enable debug mode
|
-d|--debug ) ## Enable debug mode
|
||||||
|
Loading…
Reference in New Issue
Block a user