aboutsummaryrefslogtreecommitdiff
path: root/scripts/dot-local/bin/shortcuts
diff options
context:
space:
mode:
authorMohammad Reza Karimi <m.r.karimi.j@gmail.com>2026-01-04 21:28:36 -0500
committerMohammad Reza Karimi <m.r.karimi.j@gmail.com>2026-01-04 21:28:36 -0500
commit06d1242317f7159ccf3014f0a1480e7c56236ebb (patch)
tree89863b3287ae2c7cc88cd532220f18c38e8d8657 /scripts/dot-local/bin/shortcuts
parent5a41da5881a11ba3fdc3890c342aa3b7eb53e0cf (diff)
add all sorts of things
Diffstat (limited to 'scripts/dot-local/bin/shortcuts')
-rwxr-xr-xscripts/dot-local/bin/shortcuts46
1 files changed, 46 insertions, 0 deletions
diff --git a/scripts/dot-local/bin/shortcuts b/scripts/dot-local/bin/shortcuts
new file mode 100755
index 0000000..d5644c0
--- /dev/null
+++ b/scripts/dot-local/bin/shortcuts
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+confdir="${XDG_CONFIG_HOME:-$HOME/.config}/shellshort"
+
+bmdirs="$confdir/bm-dirs"
+bmfiles="$confdir/bm-files"
+
+# Output locations. Unactivated progs should go to /dev/null.
+shell_shortcuts="$confdir/shortcutrc"
+shell_env_shortcuts="/dev/null"
+zsh_named_dirs="/dev/null"
+lf_shortcuts="${XDG_CONFIG_HOME:-$HOME/.config}/lf/shortcutrc"
+vim_shortcuts="/dev/null"
+qute_shortcuts="/dev/null"
+fish_shortcuts="/dev/null"
+vifm_shortcuts="/dev/null"
+
+# Remove, prepare files
+rm -f "$lf_shortcuts" "$qute_shortcuts" "$zsh_named_dirs" "$vim_shortcuts" 2>/dev/null
+printf "# vim: filetype=sh\\n" >"$fish_shortcuts"
+printf "# vim: filetype=sh\\nalias " >"$shell_shortcuts"
+printf "# vim: filetype=sh\\n" >"$shell_env_shortcuts"
+printf "\" vim: filetype=vim\\n" >"$vifm_shortcuts"
+
+# Format the `directories` file in the correct syntax and sent it to all three configs.
+eval "echo \"$(cat "$bmdirs")\"" |
+ awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\");
+ printf(\"%s=\42cd %s && ls -A\42 \\\\\n\",\$1,\$2) >> \"$shell_shortcuts\" ;
+ printf(\"[ -n \42%s\42 ] && export %s=\42%s\42 \n\",\$1,\$1,\$2) >> \"$shell_env_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<CR>\nmap t%s <tab>:cd %s<CR><tab>\nmap M%s <tab>:cd %s<CR><tab>:mo<CR>\nmap Y%s <tab>:cd %s<CR><tab>:co<CR> \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 C%s cd \42%s\42 \n\",\$1,\$2) >> \"$lf_shortcuts\" ;
+ printf(\"vim.keymap.set('c', ';%s', '%s', { noremap=true })\n\",\$1,\$2) >> \"$vim_shortcuts\" }"
+
+# Format the `files` file in the correct syntax and sent it to both configs.
+eval "echo \"$(cat "$bmfiles")\"" |
+ awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\");
+ printf(\"%s=\42\$EDITOR %s\42 \\\\\n\",\$1,\$2) >> \"$shell_shortcuts\" ;
+ printf(\"[ -n \42%s\42 ] && export %s=\42%s\42 \n\",\$1,\$1,\$2) >> \"$shell_env_shortcuts\" ;
+ printf(\"hash -d %s=%s \n\",\$1,\$2) >> \"$zsh_named_dirs\" ;
+ printf(\"abbr %s \42\$EDITOR %s\42 \n\",\$1,\$2) >> \"$fish_shortcuts\" ;
+ printf(\"map %s :e %s<CR> \n\",\$1,\$2) >> \"$vifm_shortcuts\" ;
+ printf(\"map E%s \$\$EDITOR \42%s\42 \n\",\$1,\$2) >> \"$lf_shortcuts\" ;
+ printf(\"vim.keymap.set('c', ';%s', '%s', { noremap=true })\n\",\$1,\$2) >> \"$vim_shortcuts\" }"