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.

36 lines
887 B

  1. #!/bin/bash
  2. key_aliases="$HOME/linux-config/aliases/key_aliases"
  3. # Ensure text of argument 1 exists in the file argument 2
  4. ensure() {{{
  5. if [[ ! -e "$2" ]]; then
  6. touch "$2"
  7. fi
  8. (grep "$1" "$2")>/dev/null 2>&1 || echo "$1" >> "$2"
  9. }}}
  10. # fish
  11. fish_config="$HOME/.config/fish/config.fish"
  12. fish_abbr="$HOME/.config/fish/key_aliases.fish"
  13. ensure "source $fish_abbr" "$fish_config"
  14. # bash/zsh
  15. bashrc="$HOME/.bashrc"
  16. zshrc="$HOME/.zshrc"
  17. aliases="$HOME/.aliases"
  18. ensure "source $aliases" "$bashrc"
  19. ensure "source $aliases" "$zshrc"
  20. # Remove, prepare files
  21. printf "# vim: filetype=sh\\n" > "$fish_abbr"
  22. printf "# vim: filetype=sh\\n" > "$aliases"
  23. sed -e '/^$/d' -e '/^[ \t#].*/d' "$key_aliases" | sort | tee \
  24. >(awk '{printf "abbr " $1; $1 = ""; print $0; }' >> "$fish_abbr") \
  25. | awk '{
  26. printf "alias " $1;
  27. $1 = "";
  28. printf "=";
  29. print gensub(" ", "", 1, $0);
  30. }' >> "$aliases"