Add ability to read search string from stdin
[khome.git] / home / lib / login_functions.sh
index 185fb26..3ea0e1d 100644 (file)
@@ -1,5 +1,22 @@
 #
 
+## ws: web search
+ws() {
+    local line search_string0 search_string
+
+    search_string0="$*"
+    case "$search_string0" in
+        '')
+            while read -r line; do
+                search_string="${search_string} ${line}"
+            done;;
+         *)
+            search_string="$search_string0";;
+    esac
+
+    firefox --search "$search_string"
+}
+
 d() {
     local -r word=$(fzf < /usr/share/dict/words)
     dict "$word"
@@ -256,7 +273,7 @@ _yt() {
     local -r opts="$3"
 
     local -r id=$(youtube-dlc --get-id "$uri")
-    local -r title=$(youtube-dlc --get-title "$uri" | sed 's/[^A-Za-z0-9._-]/_/g')
+    local -r title=$(youtube-dlc --get-title "$uri" | sed 's/[^А-Яа-яA-Za-z0-9._-]/_/g')
     local -r dir="${base_dir}/${title}--${id}"
 
     mkdir -p "$dir"
@@ -536,13 +553,11 @@ status() {
     echo
 
     printf '%smem by proc\n' "$indent_unit"
-    ps -eo rss,cmd \
+    ps -eo rss,comm \
     | awk -v total="$(free | awk '$1 == "Mem:" {print $2; exit}')" '
         NR > 1 {
             rss = $1
-            cmd = $2
-            n = split(cmd, path, "/")  # _may_ be a path
-            proc = path[n]
+            proc = $2
             by_proc[proc] += rss
         }
 
@@ -667,10 +682,10 @@ status() {
 
     echo "${indent_unit}<->"
 
-    printf '%sTCP' "${indent_unit}${indent_unit}"
+    printf '%sTCP\t' "${indent_unit}${indent_unit}"
     sudo -n netstat -tnp \
     | awk 'NR > 2 && $6 == "ESTABLISHED" {print $7}' \
-    | awk -F/ '{print $2}' \
+    | awk '{sub("^[0-9]+/", ""); print}' \
     | sort -u \
     | xargs \
     | column -t
This page took 0.027705 seconds and 4 git commands to generate.