modifyed gwip function
This commit is contained in:
parent
706f690a8e
commit
382312eb23
2 changed files with 97 additions and 65 deletions
|
@ -41,6 +41,14 @@ else
|
|||
alias hl="grep --passthrough"
|
||||
fi
|
||||
|
||||
ffile() {
|
||||
if [ -z $2 ]; then
|
||||
find -type f "${1:-./**}"
|
||||
else
|
||||
find -type f "'${1:-./**}'" -name "${2}"
|
||||
fi
|
||||
}
|
||||
|
||||
if command_exists dog; then
|
||||
alias dig="dog"
|
||||
fi
|
||||
|
@ -484,26 +492,64 @@ __git__() {
|
|||
|
||||
# Check if there are any changes on the remote branch
|
||||
if git diff --quiet "$branch" "origin/$branch"; then
|
||||
local commit_files
|
||||
local commit_files=()
|
||||
local commit_message
|
||||
|
||||
if [ -n "$2" ]; then
|
||||
commit_files="$1"
|
||||
commit_message="$2"
|
||||
else
|
||||
if [ -e "$1" ]; then
|
||||
commit_files="$1"
|
||||
commit_message="wip"
|
||||
else
|
||||
commit_files="."
|
||||
commit_message="${1:-wip}"
|
||||
fi
|
||||
fi
|
||||
case "$1" in
|
||||
'.')
|
||||
commit_files=.
|
||||
commit_message="wip"
|
||||
|
||||
echo "${CYAN}No changes on the remote branch. Adding changes and pushing with ${RED}${BOLD}'$commit_message'${NC}${CYAN} commit.${NC}"
|
||||
git add "$commit_files"
|
||||
git commit -m "$commit_message"
|
||||
git push
|
||||
echo "${CYAN}No changes on the remote branch. Adding changes and pushing with ${RED}${BOLD}'$commit_message'${NC}${CYAN} commit.${NC}"
|
||||
# echo "${GREEN}Committed files: ${BOLD}${commit_files[*]}${NC}"
|
||||
|
||||
git add "$commit_files"
|
||||
git commit -m "$commit_message"
|
||||
git push
|
||||
;;
|
||||
*)
|
||||
|
||||
if [[ -n "$1" ]]; then
|
||||
for f in "$@"; do
|
||||
if [ -e "$f" ]; then
|
||||
commit_files+=("$f")
|
||||
# shift
|
||||
else
|
||||
commit_message+="${f}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
else
|
||||
echo "${BOLD}${YELLOW}You have to provide the command like..:"
|
||||
echo "${GREEN}'gwip <list of files> <commit message>' or like 'gwip .'${NC}"
|
||||
return
|
||||
fi
|
||||
|
||||
[[ -z "$commit_files" ]] && commit_files=.
|
||||
|
||||
echo "${CYAN}No changes on the remote branch. Adding changes and pushing with ${RED}${BOLD}'$commit_message'${NC}${CYAN} commit.${NC}"
|
||||
echo "${GREEN}Committed files: ${BOLD}${commit_files[*]}${NC}"
|
||||
# for f in "${commit_files[@]}"; do
|
||||
# echo git add "$f"
|
||||
# done
|
||||
git add "${commit_files[*]}"
|
||||
git commit -m "${commit_message:-wip}"
|
||||
git push
|
||||
;;
|
||||
esac
|
||||
|
||||
# if [ -n "$2" ]; then
|
||||
# commit_files="$1"
|
||||
# commit_message="$2"
|
||||
# else
|
||||
# if [ -e "$1" ]; then
|
||||
# commit_files="$1"
|
||||
# commit_message="wip"
|
||||
# else
|
||||
# commit_files="."
|
||||
# commit_message="${1:-wip}"
|
||||
# fi
|
||||
# fi
|
||||
else
|
||||
echo "${RED}${BOLD}There are changes on the remote branch. Please pull the latest changes first.${NC}"
|
||||
fi
|
||||
|
@ -551,29 +597,6 @@ else
|
|||
echo_missing "tmux"
|
||||
fi
|
||||
|
||||
# Zellij session manager
|
||||
# if command_exists zellij; then
|
||||
# za() {
|
||||
# # local zsession='zellij list-sessions | tail -1 | grep -q EXITED'
|
||||
# if ! zellij list-sessions >/dev/null 2>&1; then
|
||||
# echo "-- Zellij session active! | Connecting to existing session --"
|
||||
# sleep 0.3
|
||||
# zellij attach
|
||||
# elif ! zellij list-sessions | tail -1 | grep -q EXITED; then
|
||||
# echo "-- Zellij session active! | Connecting to existing session --"
|
||||
# sleep 0.3
|
||||
# zellij attach
|
||||
# else
|
||||
# echo "-- No Zellij session active! | Creating one --"
|
||||
# sleep 0.3
|
||||
# zellij
|
||||
# fi
|
||||
# }
|
||||
# alias ta="za"
|
||||
#
|
||||
# # alias zs="zellij setup --dump-config > $HOME/.config/zellij/config.yaml"
|
||||
# fi
|
||||
|
||||
# Function to get the IP address
|
||||
get_ip() {
|
||||
ip a | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | cut -d/ -f1 | head -n 1
|
||||
|
@ -585,31 +608,6 @@ if command_exists hugo; then
|
|||
alias hs='hugo server -D --noHTTPCache --disableFastRender' # --bind "$(get_ip)"'
|
||||
fi
|
||||
|
||||
# Check if php is available, then create the alias
|
||||
# if command_exists php; then
|
||||
# alias phprun="php artisan serve --host=$(get_ip) --port=8000"
|
||||
# fi
|
||||
|
||||
# Check if npm is available, then create the alias
|
||||
# if command_exists npm; then
|
||||
# npmrun() {
|
||||
# npmrun_help() {
|
||||
# echo "Usage: npmrun [environment] [optional:port]"
|
||||
# echo " environment: The npm environment you want to run (e.g. dev)"
|
||||
# echo " port: Port to use (default: 8000)"
|
||||
# return
|
||||
# }
|
||||
# if [[ "$1" == "--help" || "$1" == "-h" ]]; then
|
||||
# npmrun_help
|
||||
# return
|
||||
# fi
|
||||
#
|
||||
# local env="$1"
|
||||
# local port="${2:-8080}"
|
||||
#
|
||||
# npm run "$env" -- --host="$(get_ip)" --port="$port"
|
||||
# }
|
||||
# fi
|
||||
missing() {
|
||||
local e=(
|
||||
bash
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue