This repository has been archived by the owner on Jun 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
toledo
executable file
·66 lines (56 loc) · 1.69 KB
/
toledo
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# refactor above function
parse_git_dirty() {
for STATUS in $(git status 2> /dev/null | sed -e 's/^# / /' -e 's/^#\t/ /' | cut -d ' ' -f 1); do
case "$STATUS" in
*"renamed"*) printf "${cyan}~${reset}"; ;;
*"ahead"*) printf "${purple}!${reset}"; ;;
*"new file"*) printf "${blue}+${reset}"; ;;
*"Untracked files"*) printf "${cyan}?${reset}"; ;;
*"modified"*) printf "${yellow}*${reset}"; ;;
*"deleted"*) printf "${red}-${reset}"; ;;
*"behind"*) printf "${red}ˬˬ${reset}"; ;;
esac
done
}
# create some helpful functions
clone_repo() {
username=$1
repo_name=$2
dir_name=${3:-$repo_name}
provider="https://github.com/${username}/${repo_name}.git"
if [[ $4 == "-gl" ]]; then
provider="https://gitlab.com/${username}/${repo_name}.git"
fi
git ls-remote --exit-code --heads $provider &> /dev/null
if [ $? -ne 0 ]; then
echo "Repository not found on GitHub."
echo "Usage: gcl <username> <repo_name> [<dir_name>] [-gh | -gl]"
return 1
fi
git clone $provider $dir_name
}
# create some helpful aliases
alias gs='git status'
alias gd='git diff'
alias gc='git commit -m'
alias gp='git push'
alias gcb='git checkout -b'
alias gco='git checkout'
alias gf='git fetch'
# some useful aliases
alias gcl=clone_repo
# export the colours
red='\033[0;31m' # Red
cyan='\033[0;96m' # Cyan
yellow='\033[0;92m' # Yellow (not really)
blue='\033[0;34m' # Blue
reset='\e[0m' # reset
purple='\033[0;35m' # purple
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
}
export_ps1() {
export PS1="\$(parse_git_branch) \$(parse_git_dirty) λ "
}
export_ps1
PROMPT_COMMAND='export_ps1'