Dotfiles for my tiling window manager + terminal workflow.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.6 KiB

  1. #!/bin/bash
  2. # key_aliases="$HOME/Downloads/sync-aliases/key_aliases"
  3. key_aliases="$HOME/linux-config/aliases/key_aliases"
  4. # tmp_aliases="/tmp/sync-aliases.tmp"
  5. # create temp file with no comments/blank lines
  6. # sed -e '/^$/d' -e '/^[ \t#].*/d' "$key_aliases" | sort > "$tmp_aliases"
  7. # Ensure text of argument 1 exists in the file argument 2
  8. ensure() {
  9. if [[ ! -e "$2" ]]; then
  10. touch "$2"
  11. fi
  12. (grep "$1" "$2")>/dev/null 2>&1 || echo "$1" >> "$2"
  13. }
  14. # fish
  15. fish_config="$HOME/.config/fish/config.fish"
  16. # fish_abbr="$HOME/Downloads/sync-aliases/key_aliases.fish"
  17. fish_abbr="$HOME/.config/fish/key_aliases.fish"
  18. ensure "source $fish_abbr" "$fish_config"
  19. # bash
  20. bashrc="$HOME/.bashrc"
  21. zshrc="$HOME/.zshrc"
  22. # fish_abbr="$HOME/Downloads/sync-aliases/key_aliases.fish"
  23. aliases="$HOME/.aliases"
  24. ensure "source $aliases" "$bashrc"
  25. ensure "source $aliases" "$zshrc"
  26. # Remove, prepare files
  27. printf "# vim: filetype=sh\\n" > "$fish_abbr"
  28. printf "# vim: filetype=sh\\n" > "$aliases"
  29. # # sed -e 's/\([a-z0-9]\+\) \(".\+"\)$/abbr \1 \2/g' "$tmp_aliases"
  30. # # awk '{printf "abbr " $1; $1 = ""; print $0; }' "$tmp_aliases"
  31. # awk '{printf "abbr " $1; $1 = ""; print $0; }' "$tmp_aliases" > "$fish_abbr"
  32. sed -e '/^$/d' -e '/^[ \t#].*/d' "$key_aliases" | sort | tee \
  33. >(awk '{printf "abbr " $1; $1 = ""; print $0; }' >> "$fish_abbr") \
  34. | awk '{
  35. printf "alias " $1;
  36. $1 = "";
  37. printf "=";
  38. print gensub(" ", "", 1, $0);
  39. }' >> "$aliases"
  40. # # sed -e 's/^\([a-z]\+\) \(".\+"\)$/alias \1=\2/g' "$tmp_aliases"
  41. # awk '{
  42. # printf "alias " $1;
  43. # $1 = "";
  44. # printf "=";
  45. # print gensub(" ", "", 1, $0);
  46. # }' "$tmp_aliases" > "$bash_aliases"