mirror of
https://github.com/cheat/cheat.git
synced 2024-11-23 14:31:36 +01:00
Merge pull request #617 from bernermic/master
Adds some git helper scripts
This commit is contained in:
commit
17acefdd9b
15
README.md
15
README.md
@ -95,6 +95,21 @@ The `cheat` executable includes no cheatsheets, but [community-sourced
|
|||||||
cheatsheets are available][cheatsheets]. You will be asked if you would like to
|
cheatsheets are available][cheatsheets]. You will be asked if you would like to
|
||||||
install the community-sourced cheatsheets the first time you run `cheat`.
|
install the community-sourced cheatsheets the first time you run `cheat`.
|
||||||
|
|
||||||
|
### Script ###
|
||||||
|
You can manage the cheatsheets via a script `cheatsheets`.
|
||||||
|
|
||||||
|
#### Download and install ####
|
||||||
|
```sh
|
||||||
|
mkdir -p ~/.local/bin
|
||||||
|
wget -O ~/.local/bin/cheatsheets https://raw.githubusercontent.com/cheat/cheat/master/scripts/git/cheatsheets
|
||||||
|
chmod +x ~/.local/bin/cheatsheets
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Pull changes ####
|
||||||
|
To pull the community and personal cheatsheets call `cheatsheets pull`
|
||||||
|
|
||||||
|
#### Push changes ####
|
||||||
|
To push your personal cheatsheets call `cheatsheets push`
|
||||||
|
|
||||||
Cheatpaths
|
Cheatpaths
|
||||||
----------
|
----------
|
||||||
|
46
scripts/git/cheatsheets
Executable file
46
scripts/git/cheatsheets
Executable file
@ -0,0 +1,46 @@
|
|||||||
|
#!/bin/sh -e
|
||||||
|
|
||||||
|
pull() {
|
||||||
|
for d in `cheat -d | awk '{print $2}'`;
|
||||||
|
do
|
||||||
|
echo "Update $d"
|
||||||
|
cd "$d"
|
||||||
|
[ -d ".git" ] && git pull || :
|
||||||
|
done
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Finished update"
|
||||||
|
}
|
||||||
|
|
||||||
|
push() {
|
||||||
|
for d in `cheat -d | grep -v "community" | awk '{print $2}'`;
|
||||||
|
do
|
||||||
|
cd "$d"
|
||||||
|
if [ -d ".git" ]
|
||||||
|
then
|
||||||
|
echo "Push modifications $d"
|
||||||
|
files=$(git ls-files -mo | tr '\n' ' ')
|
||||||
|
git add -A && git commit -m "Edited files: $files" && git push || :
|
||||||
|
else
|
||||||
|
echo "$(pwd) is not a git managed folder"
|
||||||
|
echo "First connect this to your personal git repository"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Finished push operation"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if [ "$1" = "pull" ]; then
|
||||||
|
pull
|
||||||
|
elif [ "$1" = "push" ]; then
|
||||||
|
push
|
||||||
|
else
|
||||||
|
echo "Usage:
|
||||||
|
# pull changes
|
||||||
|
cheatsheets pull
|
||||||
|
|
||||||
|
# push changes
|
||||||
|
cheatsheets push"
|
||||||
|
fi
|
Loading…
Reference in New Issue
Block a user