From e7a91dd8838f58601e9be38530bc9f43ac516961 Mon Sep 17 00:00:00 2001 From: Lucas Budde Mior Date: Mon, 1 Jun 2020 00:43:46 +0000 Subject: [PATCH 1/7] Use only awk in shortcuts script --- .local/bin/shortcuts | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/.local/bin/shortcuts b/.local/bin/shortcuts index 19d3ffd..c0b7d07 100755 --- a/.local/bin/shortcuts +++ b/.local/bin/shortcuts @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Output locations. Unactivated progs should go to /dev/null. +Output locations. Unactivated progs should go to /dev/null. shell_shortcuts="${XDG_CONFIG_HOME:-$HOME/.config}/shortcutrc" zsh_named_dirs="${XDG_CONFIG_HOME:-$HOME/.config}/zshnameddirrc" ranger_shortcuts="${XDG_CONFIG_HOME:-$HOME/.config}/ranger/shortcuts.conf" @@ -15,15 +15,17 @@ printf "# vim: filetype=sh\\nalias " > "$shell_shortcuts" printf "\" vim: filetype=vim\\n" > "$vifm_shortcuts" # Format the `directories` file in the correct syntax and sent it to all three configs. -sed "s/\s*#.*$//;/^\s*$/d" "${XDG_CONFIG_HOME:-$HOME/.config}/directories" | tee >(awk '{print $1"=\"cd "$2" && ls -a\" \\"}' >> "$shell_shortcuts") \ - >(awk '{print "hash -d "$1"="$2}' >> "$zsh_named_dirs") \ - >(awk '{print "abbr", $1, "\"cd " $2 "; and ls -a\""}' >> "$fish_shortcuts") \ - >(awk '{print "map g" $1, ":cd", $2 "\nmap t" $1, ":cd", $2 "\nmap M" $1, ":cd", $2 ":mo\nmap Y" $1, ":cd", $2 ":co" }' >> "$vifm_shortcuts") \ - >(awk '{print "config.bind(\";"$1"\", \"set downloads.location.directory "$2" ;; hint links download\")"}' >> "$qute_shortcuts") \ - | awk '{print "map g"$1" cd "$2"\nmap t"$1" tab_new "$2"\nmap m"$1" shell mv -v %s "$2"\nmap Y"$1" shell cp -rv %s "$2}' >> "$ranger_shortcuts" +awk "!/^\s*$/{gsub(\"\\\s*#.*$\",\"\"); + printf(\"%s=\42cd %s && ls -a\42 \\\ \n\",\$1,\$2) >> \"$shell_shortcuts\" ; + printf(\"hash -d %s=%s \n\",\$1,\$2) >> \"$zsh_named_dirs\" ; + printf(\"abbr %s \42cd %s; and ls -a\42\n\",\$1,\$2) >> \"$fish_shortcuts\" ; + printf(\"map g%s :cd %s\nmap t%s :cd %s\nmap M%s :cd %s:mo\nmap Y%s :cd %s:co \n\",\$1,\$2, \$1, \$2, \$1, \$2, \$1, \$2) >> \"$vifm_shortcuts\" ; + printf(\"config.bind(';%s', \42set downloads.location.directory %s ;; hint links download\42) \n\",\$1,\$2) >> \"$qute_shortcuts\" ; + printf(\"map g%s cd %s\nmap t%s tab_new %s\nmap m%s shell mv -v %%s %s\nmap Y%s shell cp -rv %%s %s \n\",\$1,\$2,\$1,\$2, \$1, \$2, \$1, \$2) >> \"$ranger_shortcuts\" }" "${XDG_CONFIG_HOME:-$HOME/.config}/directories" # Format the `files` file in the correct syntax and sent it to both configs. -sed "s/\s*#.*$//;/^\s*$/d" "${XDG_CONFIG_HOME:-$HOME/.config}/files" | tee >(awk '{print $1"=\"$EDITOR "$2"\" \\"}' >> "$shell_shortcuts") \ - >(awk '{print "abbr", $1, "\"$EDITOR "$2"\""}' >> "$fish_shortcuts") \ - >(awk '{print "map", $1, ":e", $2 "" }' >> "$vifm_shortcuts") \ - | awk '{print "map "$1" shell $EDITOR "$2}' >> "$ranger_shortcuts" +awk "!/^\s*$/{gsub(\"\\\s*#.*$\",\"\"); + printf(\"%s=\42\$EDITOR %s\42 \\\ \n\",\$1,\$2) >> \"$shell_shortcuts\" ; + printf(\"abbr %s \42\$EDITOR %s\42 \n\",\$1,\$2) >> \"$fish_shortcuts\" ; + printf(\"map %s :e %s \n\",\$1,\$2) >> \"$vifm_shortcuts\" ; + printf(\"map %s shell \$EDITOR %s \n\",\$1,\$2) >> \"$ranger_shortcuts\" }" "${XDG_CONFIG_HOME:-$HOME/.config}/files" From 49084aa9f02b5790905fbfc84d2c8ca568ed9141 Mon Sep 17 00:00:00 2001 From: Lucas Budde Mior Date: Mon, 1 Jun 2020 00:51:12 +0000 Subject: [PATCH 2/7] Comment on shortcuts properly commented --- .local/bin/shortcuts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.local/bin/shortcuts b/.local/bin/shortcuts index c0b7d07..cc52d7a 100755 --- a/.local/bin/shortcuts +++ b/.local/bin/shortcuts @@ -1,6 +1,6 @@ #!/usr/bin/env bash -Output locations. Unactivated progs should go to /dev/null. +# Output locations. Unactivated progs should go to /dev/null. shell_shortcuts="${XDG_CONFIG_HOME:-$HOME/.config}/shortcutrc" zsh_named_dirs="${XDG_CONFIG_HOME:-$HOME/.config}/zshnameddirrc" ranger_shortcuts="${XDG_CONFIG_HOME:-$HOME/.config}/ranger/shortcuts.conf" From 4e683c6fdc5abbf869d60b6dd6162fc3785b46d3 Mon Sep 17 00:00:00 2001 From: Lucas Budde Mior Date: Sun, 31 May 2020 22:16:50 -0300 Subject: [PATCH 3/7] now shortcuts is posix compliant, so #!/bin/sh --- .local/bin/shortcuts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.local/bin/shortcuts b/.local/bin/shortcuts index cc52d7a..15ef298 100755 --- a/.local/bin/shortcuts +++ b/.local/bin/shortcuts @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/sh # Output locations. Unactivated progs should go to /dev/null. shell_shortcuts="${XDG_CONFIG_HOME:-$HOME/.config}/shortcutrc" @@ -16,16 +16,16 @@ printf "\" vim: filetype=vim\\n" > "$vifm_shortcuts" # Format the `directories` file in the correct syntax and sent it to all three configs. awk "!/^\s*$/{gsub(\"\\\s*#.*$\",\"\"); - printf(\"%s=\42cd %s && ls -a\42 \\\ \n\",\$1,\$2) >> \"$shell_shortcuts\" ; - printf(\"hash -d %s=%s \n\",\$1,\$2) >> \"$zsh_named_dirs\" ; - printf(\"abbr %s \42cd %s; and ls -a\42\n\",\$1,\$2) >> \"$fish_shortcuts\" ; - printf(\"map g%s :cd %s\nmap t%s :cd %s\nmap M%s :cd %s:mo\nmap Y%s :cd %s:co \n\",\$1,\$2, \$1, \$2, \$1, \$2, \$1, \$2) >> \"$vifm_shortcuts\" ; + printf(\"%s=\42cd %s && ls -a\42 \\\ \n\",\$1,\$2) >> \"$shell_shortcuts\" ; + printf(\"hash -d %s=%s \n\",\$1,\$2) >> \"$zsh_named_dirs\" ; + printf(\"abbr %s \42cd %s; and ls -a\42\n\",\$1,\$2) >> \"$fish_shortcuts\" ; + printf(\"map g%s :cd %s\nmap t%s :cd %s\nmap M%s :cd %s:mo\nmap Y%s :cd %s:co \n\",\$1,\$2, \$1, \$2, \$1, \$2, \$1, \$2) >> \"$vifm_shortcuts\" ; printf(\"config.bind(';%s', \42set downloads.location.directory %s ;; hint links download\42) \n\",\$1,\$2) >> \"$qute_shortcuts\" ; printf(\"map g%s cd %s\nmap t%s tab_new %s\nmap m%s shell mv -v %%s %s\nmap Y%s shell cp -rv %%s %s \n\",\$1,\$2,\$1,\$2, \$1, \$2, \$1, \$2) >> \"$ranger_shortcuts\" }" "${XDG_CONFIG_HOME:-$HOME/.config}/directories" # Format the `files` file in the correct syntax and sent it to both configs. awk "!/^\s*$/{gsub(\"\\\s*#.*$\",\"\"); - printf(\"%s=\42\$EDITOR %s\42 \\\ \n\",\$1,\$2) >> \"$shell_shortcuts\" ; - printf(\"abbr %s \42\$EDITOR %s\42 \n\",\$1,\$2) >> \"$fish_shortcuts\" ; - printf(\"map %s :e %s \n\",\$1,\$2) >> \"$vifm_shortcuts\" ; - printf(\"map %s shell \$EDITOR %s \n\",\$1,\$2) >> \"$ranger_shortcuts\" }" "${XDG_CONFIG_HOME:-$HOME/.config}/files" + printf(\"%s=\42\$EDITOR %s\42 \\\ \n\",\$1,\$2) >> \"$shell_shortcuts\" ; + printf(\"abbr %s \42\$EDITOR %s\42 \n\",\$1,\$2) >> \"$fish_shortcuts\" ; + printf(\"map %s :e %s \n\",\$1,\$2) >> \"$vifm_shortcuts\" ; + printf(\"map %s shell \$EDITOR %s \n\",\$1,\$2) >> \"$ranger_shortcuts\" }" "${XDG_CONFIG_HOME:-$HOME/.config}/files" From 16e228f3cc5e0ff47fe385e3b58eb621d8a26c14 Mon Sep 17 00:00:00 2001 From: Lucas Budde Mior Date: Sun, 31 May 2020 22:59:24 -0300 Subject: [PATCH 4/7] comments on shortcuts fixed --- .local/bin/shortcuts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.local/bin/shortcuts b/.local/bin/shortcuts index 15ef298..6d25231 100755 --- a/.local/bin/shortcuts +++ b/.local/bin/shortcuts @@ -15,7 +15,7 @@ printf "# vim: filetype=sh\\nalias " > "$shell_shortcuts" printf "\" vim: filetype=vim\\n" > "$vifm_shortcuts" # Format the `directories` file in the correct syntax and sent it to all three configs. -awk "!/^\s*$/{gsub(\"\\\s*#.*$\",\"\"); +awk "!/^\s*#/ {gsub(\"\\\s*#.*$\",\"\"); printf(\"%s=\42cd %s && ls -a\42 \\\ \n\",\$1,\$2) >> \"$shell_shortcuts\" ; printf(\"hash -d %s=%s \n\",\$1,\$2) >> \"$zsh_named_dirs\" ; printf(\"abbr %s \42cd %s; and ls -a\42\n\",\$1,\$2) >> \"$fish_shortcuts\" ; @@ -24,7 +24,7 @@ awk "!/^\s*$/{gsub(\"\\\s*#.*$\",\"\"); printf(\"map g%s cd %s\nmap t%s tab_new %s\nmap m%s shell mv -v %%s %s\nmap Y%s shell cp -rv %%s %s \n\",\$1,\$2,\$1,\$2, \$1, \$2, \$1, \$2) >> \"$ranger_shortcuts\" }" "${XDG_CONFIG_HOME:-$HOME/.config}/directories" # Format the `files` file in the correct syntax and sent it to both configs. -awk "!/^\s*$/{gsub(\"\\\s*#.*$\",\"\"); +awk "!/^\s*#/ {gsub(\"\\\s*#.*$\",\"\"); printf(\"%s=\42\$EDITOR %s\42 \\\ \n\",\$1,\$2) >> \"$shell_shortcuts\" ; printf(\"abbr %s \42\$EDITOR %s\42 \n\",\$1,\$2) >> \"$fish_shortcuts\" ; printf(\"map %s :e %s \n\",\$1,\$2) >> \"$vifm_shortcuts\" ; From 00bf44782de6c1d6b43fe071d4e182376620acd7 Mon Sep 17 00:00:00 2001 From: Lucas Budde Mior Date: Sun, 31 May 2020 22:59:24 -0300 Subject: [PATCH 5/7] comments on shortcuts fixed --- .local/bin/shortcuts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.local/bin/shortcuts b/.local/bin/shortcuts index 15ef298..80cd4ff 100755 --- a/.local/bin/shortcuts +++ b/.local/bin/shortcuts @@ -15,7 +15,7 @@ printf "# vim: filetype=sh\\nalias " > "$shell_shortcuts" printf "\" vim: filetype=vim\\n" > "$vifm_shortcuts" # Format the `directories` file in the correct syntax and sent it to all three configs. -awk "!/^\s*$/{gsub(\"\\\s*#.*$\",\"\"); +awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\"); printf(\"%s=\42cd %s && ls -a\42 \\\ \n\",\$1,\$2) >> \"$shell_shortcuts\" ; printf(\"hash -d %s=%s \n\",\$1,\$2) >> \"$zsh_named_dirs\" ; printf(\"abbr %s \42cd %s; and ls -a\42\n\",\$1,\$2) >> \"$fish_shortcuts\" ; @@ -24,7 +24,7 @@ awk "!/^\s*$/{gsub(\"\\\s*#.*$\",\"\"); printf(\"map g%s cd %s\nmap t%s tab_new %s\nmap m%s shell mv -v %%s %s\nmap Y%s shell cp -rv %%s %s \n\",\$1,\$2,\$1,\$2, \$1, \$2, \$1, \$2) >> \"$ranger_shortcuts\" }" "${XDG_CONFIG_HOME:-$HOME/.config}/directories" # Format the `files` file in the correct syntax and sent it to both configs. -awk "!/^\s*$/{gsub(\"\\\s*#.*$\",\"\"); +awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\"); printf(\"%s=\42\$EDITOR %s\42 \\\ \n\",\$1,\$2) >> \"$shell_shortcuts\" ; printf(\"abbr %s \42\$EDITOR %s\42 \n\",\$1,\$2) >> \"$fish_shortcuts\" ; printf(\"map %s :e %s \n\",\$1,\$2) >> \"$vifm_shortcuts\" ; From 63a7f762d7811fa3a8b47363f208530801c209d6 Mon Sep 17 00:00:00 2001 From: Lucas Budde Mior Date: Mon, 1 Jun 2020 00:22:52 -0300 Subject: [PATCH 6/7] escaped dollar sign on shortcuts --- .local/bin/shortcuts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.local/bin/shortcuts b/.local/bin/shortcuts index 80cd4ff..4bdaf05 100755 --- a/.local/bin/shortcuts +++ b/.local/bin/shortcuts @@ -15,7 +15,7 @@ printf "# vim: filetype=sh\\nalias " > "$shell_shortcuts" printf "\" vim: filetype=vim\\n" > "$vifm_shortcuts" # Format the `directories` file in the correct syntax and sent it to all three configs. -awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\"); +awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*\$\",\"\"); printf(\"%s=\42cd %s && ls -a\42 \\\ \n\",\$1,\$2) >> \"$shell_shortcuts\" ; printf(\"hash -d %s=%s \n\",\$1,\$2) >> \"$zsh_named_dirs\" ; printf(\"abbr %s \42cd %s; and ls -a\42\n\",\$1,\$2) >> \"$fish_shortcuts\" ; @@ -24,7 +24,7 @@ awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\"); printf(\"map g%s cd %s\nmap t%s tab_new %s\nmap m%s shell mv -v %%s %s\nmap Y%s shell cp -rv %%s %s \n\",\$1,\$2,\$1,\$2, \$1, \$2, \$1, \$2) >> \"$ranger_shortcuts\" }" "${XDG_CONFIG_HOME:-$HOME/.config}/directories" # Format the `files` file in the correct syntax and sent it to both configs. -awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\"); +awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*\$\",\"\"); printf(\"%s=\42\$EDITOR %s\42 \\\ \n\",\$1,\$2) >> \"$shell_shortcuts\" ; printf(\"abbr %s \42\$EDITOR %s\42 \n\",\$1,\$2) >> \"$fish_shortcuts\" ; printf(\"map %s :e %s \n\",\$1,\$2) >> \"$vifm_shortcuts\" ; From 42187933e071d1e97717d1a3837399a74d375953 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Sun, 31 May 2020 23:30:05 -0400 Subject: [PATCH 7/7] trailing whitespace fix --- .local/bin/shortcuts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.local/bin/shortcuts b/.local/bin/shortcuts index 4bdaf05..ed4f89f 100755 --- a/.local/bin/shortcuts +++ b/.local/bin/shortcuts @@ -6,7 +6,7 @@ zsh_named_dirs="${XDG_CONFIG_HOME:-$HOME/.config}/zshnameddirrc" ranger_shortcuts="${XDG_CONFIG_HOME:-$HOME/.config}/ranger/shortcuts.conf" qute_shortcuts="/dev/null" fish_shortcuts="/dev/null" -vifm_shortcuts="${XDG_CONFIG_HOME:-$HOME/.config}/vifm/vifmshortcuts" +vifm_shortcuts="/dev/null" # Remove, prepare files rm -f "$ranger_shortcuts" "$qute_shortcuts" "$zsh_named_dirs" 2>/dev/null @@ -15,8 +15,8 @@ printf "# vim: filetype=sh\\nalias " > "$shell_shortcuts" printf "\" vim: filetype=vim\\n" > "$vifm_shortcuts" # Format the `directories` file in the correct syntax and sent it to all three configs. -awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*\$\",\"\"); - printf(\"%s=\42cd %s && ls -a\42 \\\ \n\",\$1,\$2) >> \"$shell_shortcuts\" ; +awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\"); + printf(\"%s=\42cd %s && ls -a\42 \\\\\n\",\$1,\$2) >> \"$shell_shortcuts\" ; printf(\"hash -d %s=%s \n\",\$1,\$2) >> \"$zsh_named_dirs\" ; printf(\"abbr %s \42cd %s; and ls -a\42\n\",\$1,\$2) >> \"$fish_shortcuts\" ; printf(\"map g%s :cd %s\nmap t%s :cd %s\nmap M%s :cd %s:mo\nmap Y%s :cd %s:co \n\",\$1,\$2, \$1, \$2, \$1, \$2, \$1, \$2) >> \"$vifm_shortcuts\" ; @@ -24,8 +24,8 @@ awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*\$\",\"\"); printf(\"map g%s cd %s\nmap t%s tab_new %s\nmap m%s shell mv -v %%s %s\nmap Y%s shell cp -rv %%s %s \n\",\$1,\$2,\$1,\$2, \$1, \$2, \$1, \$2) >> \"$ranger_shortcuts\" }" "${XDG_CONFIG_HOME:-$HOME/.config}/directories" # Format the `files` file in the correct syntax and sent it to both configs. -awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*\$\",\"\"); - printf(\"%s=\42\$EDITOR %s\42 \\\ \n\",\$1,\$2) >> \"$shell_shortcuts\" ; +awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\"); + printf(\"%s=\42\$EDITOR %s\42 \\\\\n\",\$1,\$2) >> \"$shell_shortcuts\" ; printf(\"abbr %s \42\$EDITOR %s\42 \n\",\$1,\$2) >> \"$fish_shortcuts\" ; printf(\"map %s :e %s \n\",\$1,\$2) >> \"$vifm_shortcuts\" ; printf(\"map %s shell \$EDITOR %s \n\",\$1,\$2) >> \"$ranger_shortcuts\" }" "${XDG_CONFIG_HOME:-$HOME/.config}/files"