-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforfqgits.zsh
34 lines (33 loc) · 901 Bytes
/
forfqgits.zsh
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
30
31
32
33
34
#!/bin/zsh
#forf() is from $envzsh (.zsh_custom/envar.zsh)
#this forf is not updated, check $envzsh
forf(){
OFS=$IFS
IFS=$'\n'
[[ -z $1 ]] && echo -e "Usage: $0 [q (optional)] [file] [cmd]" && return 1
file_arg=1
cmd_arg=2
echo=1
if [ "$1" = "q" ];then
echo=0
file_arg=2
cmd_arg=3
fi
for line in $(cat "${(P)file_arg}");do
if [ $echo -eq 1 ];then
echo $line
fi
eval "${(P)cmd_arg}"
done
IFS=$OFS
}
forf q .zsh_gits 'line_trimmed=$(echo $line | cut -f 1 -d'=');tocd=${(P)line_trimmed};
if [[ ! "$tocd" =~ ^[0-9]$ ]];then
cd "$tocd";
gst=$(git status --porcelain);
if [ -n "$gst" ];then
echo $tocd;
echo $gst;
echo
fi;
fi;cd ~;' > list_status_gits.txt