💾 Archived View for hajime.4teri.de › dotfiles › file › update.sh.gmi captured on 2021-12-03 at 14:04:38. Gemini links have been rewritten to link to archived content

View Raw

More Information

-=-=-=-=-=-=-

update.sh - dotfiles - Collection of my dotfiles

Log

Files

Refs

---

update.sh (2051B)

---

1 #! /bin/sh

2

3 UPTODATE_COLOUR_START="\033[32;48m"

4 CHANGE_COLOUR_START="\033[33;48m"

5 ERROR_COLOUR_START="\033[31;48m"

6 INFO_COLOUR_START="\033[30;47m"

7 IGNORE_COLOUR_START="\033[34;48m"

8 COLOUR_END="\033[0m"

9

10 update() {

11 if ! [ -z "$2" ]

12 then

13 if ! [ -e "$2" ]

14 then

15 echo -e "$ERROR_COLOUR_START $2 does not exist $COLOUR_END"

16 elif ! [ -e "$1" ]

17 then

18 echo -e "$CHANGE_COLOUR_START Creating $1 $COLOUR_END"

19 cp "$2" "$1"

20 elif diff "$1" "$2" > /dev/null

21 then

22 echo -e "$UPTODATE_COLOUR_START $1 is up-to-date $COLOUR_END"

23 else

24 echo -e "$CHANGE_COLOUR_START Updating $1 $COLOUR_END"

25 cp "$2" "$1"

26 fi

27 elif ! [ -e "$HOME/.$1" ]

28 then

29 echo -e "$ERROR_COLOUR_START $1 does not exist in $HOME $COLOUR_END"

30 elif ! [ -e "$1" ]

31 then

32 echo -e "$CHANGE_COLOUR_START Creating $1 $COLOUR_END"

33 cp "$HOME/.$1" "$1"

34 elif diff "$1" "$HOME/.$1" > /dev/null

35 then

36 echo -e "$UPTODATE_COLOUR_START $1 is up-to-date $COLOUR_END"

37 else

38 echo -e "$CHANGE_COLOUR_START Updating $1 $COLOUR_END"

39 cp "$HOME/.$1" "$1"

40 fi

41 }

42

43 dir_update() {

44 mkdir -p "$1"

45 echo -e "$INFO_COLOUR_START Checking $1... $COLOUR_END"

46 for file in $(/usr/bin/ls "$HOME"/.config/"$1")

47 do

48 if [[ "$2" = *"$file"* ]]

49 then

50 echo -e "$IGNORE_COLOUR_START $file will be ignored. $COLOUR_END"

51 elif ! [ -e "$1/$file" ]

52 then

53 echo -e "$CHANGE_COLOUR_START Creating $1/$file $COLOUR_END"

54 cp "$HOME/.config/$1/$file" "$1/$file"

55 elif diff "$1" "$HOME/.config/$1/$file" > /dev/null

56 then

57 echo -e "$UPTODATE_COLOUR_START $file is up-to-date $COLOUR_END"

58 else

59 echo -e "$CHANGE_COLOUR_START Updating $1/$file $COLOUR_END"

60 cp "$HOME/.config/$1/$file" "$1/$file"

61 fi

62 done

63 }

64

65

66 echo "Using $HOME as home"

67 update vimrc

68 update zshrc

69 update gitconfig

70 update tmux.conf

71 update wallpapermap

72

73 if [ -e "$HOME/.config/scripts" ]

74 then

75 dir_update scripts

76 fi

77

78 if [ -e "$HOME/.config/env" ]

79 then

80 dir_update env

81 fi

82

83 if [ -e "$HOME/.config/configures" ]

84 then

85 dir_update configures

86 fi

87

88 if [ -e "$HOME/.config/newsboat" ]

89 then

90 dir_update newsboat cache.db

91 fi

generated w/ stagit-gemini