swaydots

my dotfiles
git clone https://git.awy.one/swaydots.git
Log | Files | Refs | README | LICENSE

shortcuts (3329B)


      1 #!/bin/sh
      2 
      3 bmdirs="${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs"
      4 bmfiles="${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-files"
      5 
      6 # Output locations. Unactivated progs should go to /dev/null.
      7 shell_shortcuts="${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc"
      8 shell_env_shortcuts="${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutenvrc"
      9 zsh_named_dirs="${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshnameddirrc"
     10 lf_shortcuts="/dev/null"
     11 vim_shortcuts="/dev/null"
     12 qute_shortcuts="/dev/null"
     13 fish_shortcuts="/dev/null"
     14 vifm_shortcuts="/dev/null"
     15 yazi_shortcuts="${XDG_CONFIG_HOME:-$HOME/.config}/yazi/keymap.toml"
     16 
     17 # Remove, prepare files
     18 rm -f "$lf_shortcuts" "$qute_shortcuts" "$zsh_named_dirs" "$vim_shortcuts" "$yazi_shortcuts" 2>/dev/null
     19 printf "# vim: filetype=sh\\n" > "$fish_shortcuts"
     20 printf "# vim: filetype=sh\\nalias " > "$shell_shortcuts"
     21 printf "# vim: filetype=sh\\n" > "$shell_env_shortcuts"
     22 printf "\" vim: filetype=vim\\n" > "$vifm_shortcuts"
     23 
     24 # Format the `directories` file in the correct syntax and sent it to all three configs.
     25 eval "echo \"$(cat "$bmdirs")\"" | \
     26 awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\");
     27   printf(\"%s=\42cd %s && ls -A\42 \\\\\n\",\$1,\$2)   >> \"$shell_shortcuts\" ;
     28   printf(\"[ -n \42%s\42 ] && export %s=\42%s\42 \n\",\$1,\$1,\$2)   >> \"$shell_env_shortcuts\" ;
     29   printf(\"hash -d %s=%s \n\",\$1,\$2)                 >> \"$zsh_named_dirs\"  ;
     30   printf(\"abbr %s \42cd %s; and ls -A\42\n\",\$1,\$2) >> \"$fish_shortcuts\"  ;
     31   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\" ;
     32   printf(\"config.bind(';%s', \42set downloads.location.directory %s ;; hint links download\42) \n\",\$1,\$2) >> \"$qute_shortcuts\" ;
     33   printf(\"map C%s cd \42%s\42 \n\",\$1,\$2)           >> \"$lf_shortcuts\" ;
     34   printf(\"cmap ;%s %s\n\",\$1,\$2)                    >> \"$vim_shortcuts\" ;
     35   split(\$1, a, \"\")
     36   chars = \"\"
     37   for (i = 1; i <= length(a); i++) {
     38     chars = chars sprintf(\"\\\"%s\\\"\", a[i])
     39     if (i < length(a)) chars = chars \", \"
     40     }
     41   printf(\"[[mgr.prepend_keymap]]\\non = [\\\"g\\\", %s]\\nrun = \\\"cd %s\\\"\\n\\n\", chars, \$2) >> \"$yazi_shortcuts\" }"
     42 
     43 # Format the `files` file in the correct syntax and sent it to both configs.
     44 eval "echo \"$(cat "$bmfiles")\"" | \
     45 awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\");
     46   printf(\"%s=\42\$EDITOR %s\42 \\\\\n\",\$1,\$2)  >> \"$shell_shortcuts\" ;
     47   printf(\"[ -n \42%s\42 ] && export %s=\42%s\42 \n\",\$1,\$1,\$2)   >> \"$shell_env_shortcuts\" ;
     48   printf(\"hash -d %s=%s \n\",\$1,\$2)             >> \"$zsh_named_dirs\"  ;
     49   printf(\"abbr %s \42\$EDITOR %s\42 \n\",\$1,\$2) >> \"$fish_shortcuts\"  ;
     50   printf(\"map %s :e %s<CR> \n\",\$1,\$2)          >> \"$vifm_shortcuts\"  ;
     51   printf(\"map E%s \$\$EDITOR \42%s\42 \n\",\$1,\$2)   >> \"$lf_shortcuts\" ;
     52   printf(\"cmap ;%s %s\n\",\$1,\$2)                    >> \"$vim_shortcuts\" ;
     53   split(\$1, a, \"\")
     54   chars = \"\"
     55   for (i = 1; i <= length(a); i++) {
     56     chars = chars sprintf(\"\\\"%s\\\"\", a[i])
     57     if (i < length(a)) chars = chars \", \"
     58     }
     59   printf(\"[[mgr.prepend_keymap]]\\non = [\\\"e\\\", %s]\\nrun = 'shell --block \\\"\$EDITOR %s\\\"'\\n\\n\", chars, \$2) >> \"$yazi_shortcuts\" }"