summaryrefslogtreecommitdiff
path: root/dotfiles/system/.zsh/modules/copy_from_zsh_src.zsh
blob: 89eee0138d23737e707946dfa94f4d71f2bd737c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env zsh

[[ -z "$1" || "$1" = "-h" || "$1" = "--help" ]] && { print "Single argument: path to Zsh source tree"; exit 0; }

print "Will invoke git clean -dxf, 3 seconds"
sleep 3

git clean -dxf

[[ ! -d "$1" ]] && { print "Path to Zsh source doesn't exist (i.e.: $1)"; exit 1; }

local from="$1"

autoload -Uz colors
colors

integer count=0

for i in configure.ac Src/*.c Src/*.h; do
    if [[ -f "$from/$i" ]]; then
        cp -vf "$from/$i" "$i" && (( ++ count )) || print "${fg_bold[red]}Copy error for: $i${reset_color}"
    else
        print "${fg[red]}$i Doesn't exist${reset_color}"
    fi
done

echo "${fg[green]}Copied ${fg[yellow]}$count${fg[green]} files${reset_color}"

patch -p2 -i ./patch_cfgac.diff