My scripts for startup, dmenu, and the command line
Vous ne pouvez pas sélectionner plus de 25 sujets
Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
|
- #!/bin/sh
-
- pull_backup() {
- check_args $# 2
- if [ ! -d "$BACKUPS_PATH/$2" ]; then
- invalid_path_msg "$1:$2"
- return 1;
- fi
-
- git -C $BACKUPS_PATH/$2 pull $1
- }
-
- push_backup() {
- check_args $# 2
- if [ ! -d "$BACKUPS_PATH/$2" ]; then
- invalid_path_msg "$1:$2"
- return 1;
- fi
-
- git -C $BACKUPS_PATH/$2 push $1
- }
-
- overwrite_local() {
- if [ ! -e "$BACKUPS_PATH/$1/$2" ]; then
- printf "The backup path does not exist\n"
- return 1;
- fi
- case "$1" in
- configs) cp -r "$BACKUPS_PATH/$1/$2" "$XDG_CONFIG_HOME/$2";;
- macros) cp -r "$BACKUPS_PATH/$1/$2" "$HOME/Macros/$2";;
- *) invalid_path_msg "$1"; return 1;;
- esac
- }
-
- overwrite_backup() {
- if [ git diff --stat $BACKUPS_PATH/$1 ]; then
- printf "There are uncommited changes in $1\n"
- return 1
- fi
- case "$1" in
- configs) cp -r "$XDG_CONFIG_HOME/$2" "$BACKUPS_PATH/$1/$2";;
- macros) cp -r "$HOME/Macros/$2" "$BACKUPS_PATH/$1/$2";;
- *) invalid_path_msg "$1"; return 1;;
- esac
- }
-
- invalid_path_msg() {
- printf "That path is invalid. $@\n"
- }
-
- check_args() {
- if [ $1 -ne $2 ]; then
- printf "Invalid number of arguments. Expected $2\n"
- exit;
- fi
- return 0;
- }
-
- case "$1" in
- pull-backup)
- case "$2" in
- configs) pull_backup configs;;
- macros) pull_backup macros;;
- esac
- ;;
- overwrite-local) overwrite_local $2 $3;;
- overwrite-backup) overwrite_backup $2 $3;;
- pull-backup) pull_backup $2 $3;;
- push-backup) push_backup $2 $3;;
- push-backup) overwrite_backup $2 $3;;
- *) printf "No such option\n";;
- esac
|