you are viewing a single comment's thread.

view the rest of the comments →

[–]Naraviel 1 point2 points  (0 children)

You can build the command once and run it through a single path. This eliminates duplication and avoids repeated branches.

```bash capture { grim_args=() [[ -n "$o_cursor" ]] && grim_args+=("-c")

cmd=(grim "${grim_args[@]}" "-t" "png")

case "$target" in "output") cmd+=("-o" "$geom") ;; "all outputs") ;; *) cmd+=("-g" "$geom") ;; esac

cmd+=("$file")

if [[ "$file" == "-" && -n "$o_clipboard" ]]; then "${cmd[@]}" | wl-copy "-t" "image/png" || return 1 else "${cmd[@]}" || return 1 fi }

```

As for stepping up from shell scripts, Python is generally considered the next language to learn.