From 70c80c9d0e8559986c63c0b0d2130313311e0967 Mon Sep 17 00:00:00 2001 From: Wilke Schwiedop Date: Sun, 15 Apr 2018 20:08:59 +0200 Subject: [PATCH] fix and remove sed from __fish_print_xrandr_modes.fish --- .../functions/__fish_print_xrandr_modes.fish | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/share/functions/__fish_print_xrandr_modes.fish b/share/functions/__fish_print_xrandr_modes.fish index dd5ebb70b..0023abe54 100644 --- a/share/functions/__fish_print_xrandr_modes.fish +++ b/share/functions/__fish_print_xrandr_modes.fish @@ -1,13 +1,11 @@ function __fish_print_xrandr_modes --description 'Print xrandr modes' - set -l out - xrandr | sed '/^Screen/d; s/^ \+/mode: /' | while read -l output mode misc - switch $output - case mode: - echo $mode\t(echo $misc | sed 's/\(^ \+\)\|\( *$\)//') [$out] - case '*' - set out $output - end - end - - + set -l output + xrandr | string match -v -r '^(Screen|\s{4,})' | while read line + switch $line + case ' *' + string trim $line | string replace -r '^(\S+)\s+(.*)$' "\$1\t\$2 [$output]" + case '*' + set output (string match -r '^\S+' $line) + end + end end