Skip to content

Commit 780030c

Browse files
Update SHX.
1 parent 6240306 commit 780030c

File tree

6 files changed

+74
-9
lines changed

6 files changed

+74
-9
lines changed

sh/amend.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
# shx Standard Utility
3+
# Push to a single remote
4+
git stage -A && git commit --amend && git push --force $1
5+
# Push to all remotes
6+
#git stage -A && git commit --amend && git remote | xargs -L1 git push --force
7+
exit

sh/commit.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
#!/bin/bash
2-
git stage -A && git commit && git push
2+
#shx Standard Utility
3+
# Push to a single remote
4+
git stage -A && git commit && git push $1
5+
# Push to all remotes
6+
#git stage -A && git commit && git remote | xargs -L1 git push
37
exit

sh/diff.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
# shx Standard Utility
3+
git stage -A
4+
git diff ${1:-HEAD}

sh/tag.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
git tag -a "$1" "${2:-HEAD}" && git push origin "$1"
3+
exit

sh/version.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
echo "shx version: $SHX_VERSION"
3+
echo "Current shell: $CURRENT_SHELL"
4+
echo "Source directory: $SOURCE_DIR"
5+
echo "Invoke directory: $INVOKE_DIR"

shx

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,62 @@
11
#!/bin/bash
2+
# Check the current shell
3+
export SHX_VERSION=0.2.1
4+
export INVOKE_DIR=$PWD
5+
export CURRENT_SHELL=$(ps h -p $$ -o args='' | cut -f1 -d' ')
6+
if [[ "${NO_SHELL_CHECK}" == "" ]] &&
7+
[[ "${CURRENT_SHELL}" != *"bash" ]] &&
8+
[[ "${CURRENT_SHELL}" != *"ksh" ]] &&
9+
[[ "${CURRENT_SHELL}" != *"zsh" ]]; then
10+
echo "Please run with bash instead of ${CURRENT_SHELL}."
11+
exit
12+
fi
13+
# Define runner
14+
runner="bash"
15+
if [[ "${CURRENT_SHELL}" == *"bash" ]]; then
16+
runner=$CURRENT_SHELL
17+
elif [[ "$(bash --version >/dev/null 2>/dev/null;echo $?)" == "0" ]]; then
18+
printf ""
19+
else
20+
echo -e "\033[1;33mWarning\033[0m: Not using Bash. Scripts may not work."
21+
fi
22+
# Locate the project folder
23+
OIFS="$IFS"
24+
IFS='/' read -r -a paths <<< "$PWD" 2>/dev/null || paths=('' ${(@s:/:)PWD})
25+
let fsPointer=$((${#paths[@]} - 1))
26+
IFS='/'
27+
while [ "$fsPointer" -ge 0 ]; do
28+
fsPath="${paths[@]:0:$((fsPointer + 1))}"
29+
fsPath=${fsPath:-/}
30+
if [ -f "$fsPath/shx" ] && [ -d "$fsPath/sh" ] ; then
31+
#echo "Switched to \"$fsPath\"."
32+
cd "$fsPath"
33+
break
34+
#else
35+
#echo "No match for \"$fsPath\"."
36+
fi
37+
fsPointer=$(($fsPointer - 1))
38+
done
39+
if [[ "$fsPath" == "/" ]] ; then
40+
echo "No project directory is found. Quitting."
41+
exit 1
42+
fi
43+
IFS="$OIFS"
44+
export SOURCE_DIR=$PWD
45+
export PATH=$PATH:./:./sh
46+
# Command parsing
247
arg="$@"
348
args=( "$@" )
4-
if [ "$arg" == "" ] ; then
49+
if [[ "${arg}" == "" ]] ; then
50+
echo -e "\033[1;37mshx ${SHX_VERSION}\033[0m"
551
echo "All available actions:"
652
ls -1 sh | while IFS= read -r file; do
7-
echo "${file/.sh/}"
53+
echo "· ${file/.sh/}"
854
done
9-
exit
10-
fi
11-
if [ -e "sh/$1.sh" ] ; then
12-
export PATH=./:./sh/:$PATH
55+
elif [ -e "sh/$1.sh" ] ; then
1356
bash "sh/$1.sh" "${args[@]:1}"
1457
elif [ -e "sh/$1" ] ; then
15-
export PATH=./:./sh/:$PATH
1658
bash "sh/$1" "${args[@]:1}"
1759
else
18-
echo "No action found as \"$1\". Command: \"${args[@]:1}\"".
60+
echo -e "\033[1;31mError\033[0m: No action found as \"$1\". Command: shx ${args[@]:1}".
1961
fi
2062
exit

0 commit comments

Comments
 (0)