diff --git a/aliases b/aliases index bdefddb298..10f09ea3c0 100644 --- a/aliases +++ b/aliases @@ -111,7 +111,7 @@ alias rdc='rails db:create' alias rdm='rails db:migrate' # rails db:seed -alias rds='rails db:seed' +# alias rds='rails db:seed' # rails db:seed db:create db:migrate @@ -275,3 +275,11 @@ function vnc() { #$ print -rl -- $TMP #=>cat # question code snippet : #read -q "REPLY?Enter COMMIT?" + +# Development Server Aliases +alias rds="$HOME/code/AzCez/dotfiles/scripts/rds.sh" # Start both Rails and Vite servers +alias crs="$HOME/code/AzCez/dotfiles/scripts/crs.sh" # Check server status +alias krs="$HOME/code/AzCez/dotfiles/scripts/krs.sh" # Kill Rails server only +alias kvs="$HOME/code/AzCez/dotfiles/scripts/kvs.sh" # Kill Vite server only +alias rvs="$HOME/code/AzCez/dotfiles/scripts/rvs.sh" # Start just Vite server +alias kas="$HOME/code/AzCez/dotfiles/scripts/kas.sh" # Kill all servers diff --git a/aliases.backup b/aliases.backup new file mode 100644 index 0000000000..ea6cdcc5d5 --- /dev/null +++ b/aliases.backup @@ -0,0 +1,285 @@ +# ---- +# Custom aliases +# Rails + npm workflow: see ./dev.sh and README-dev.md for full docs +# Key commands: dev (both), devs (status), devk (stop) +# ---- +# +# Get External IP / local IPs +alias ip="curl ipinfo.io/ip" +alias ips="ifconfig -a | perl -nle'/(\d+\.\d+\.\d+\.\d+)/ && print $1'" +alias speedtest="wget -O /dev/null http://speedtest.wdc01.softlayer.com/downloads/test10.zip" + + + + + +#Python + + +# Quickly serve the current directory as HTTP +alias serve='ruby -run -e httpd . -p 8000' # Or python -m SimpleHTTPServer :) + +#pyton vitual env activated Le Wagon +alias penv='pyenv activate lewagon' + +#open jupyter notebook +alias jnote='jupyter notebook' + + +#kill port processes +alias kp='npx kill-port' # + +#List running server +alias wsr='lsof -nP +c 15 | grep LISTEN' + +# Server port 3000 +alias s3='rails s' + +# Server port 4000 +alias s4='rails s -p 4000' + +# Server port 5000 +alias s5='rails s -p 5000' + +# Server port 6000 +alias s6='rails s -p 6000' s + +# Server port 7000 +alias s7='rails s -p 7000' + +# Server port 8000 +alias s8='rails s -p 8000' + + +# Rails + npm Development Aliases +# Make sure dev.sh is executable: chmod +x dev.sh + +# Development script aliases +alias dev-rails='./dev.sh rails' +alias dev-npm='./dev.sh npm' +alias dev-both='./dev.sh both' +alias dev-build='./dev.sh build' +alias dev-watch='./dev.sh watch' +alias dev-stop='./dev.sh stop' +alias dev-status='./dev.sh status' + +# Quick development shortcuts +alias dev='./dev.sh both' # Start both Rails and npm watch +alias devs='./dev.sh status' # Show status +alias devk='./dev.sh stop' # Kill all processes + +# Enhanced Rails server aliases (building on your existing ones) +alias s3dev='RAILS_PORT=3000 ./dev.sh rails' +alias s4dev='RAILS_PORT=4000 ./dev.sh rails' +alias s5dev='RAILS_PORT=5000 ./dev.sh rails' + +# Enhanced npm aliases +alias npm-dev='./dev.sh npm' +alias npm-build='./dev.sh build' +alias npm-watch='./dev.sh watch' + + +# Webpack compile +alias wpc='webpack-dev-server' + +#open ngrok +Alias ngrok='./ngrok' + +# Rails/Vite server management (moved from zshrc to keep upstream zshrc clean) +# Note: we keep existing `rds` for rails db:seed; do not reuse that name here. +alias krs="echo 'Killing Rails server...' && pkill -f 'rails server' 2>/dev/null && echo '✅ Rails server killed' || echo 'ℹ️ Rails server not running'" +alias kvs="echo 'Killing Vite server on port 3036...' && (lsof -ti:3036 | xargs kill -9 2>/dev/null || true); pkill -f 'vite' 2>/dev/null; pkill -f 'npm exec vite' 2>/dev/null; echo '✅ Vite server killed'" +alias crs="echo '=== SERVER STATUS CHECK ==='; echo; if lsof -i :3000 >/dev/null 2>&1; then echo '✅ Rails (3000): running (PID '$(lsof -ti :3000 | head -1)')'; else echo '❌ Rails (3000): not running'; fi; echo; if lsof -i :3036 >/dev/null 2>&1; then echo '✅ Vite (3036): running (PID '$(lsof -ti :3036 | head -1)')'; else echo '❌ Vite (3036): not running'; fi; echo; echo 'URLs:'; echo ' Rails: http://localhost:3000'; echo ' Vite: http://localhost:3036'" +alias rvs="npx vite --port 3037" + +# Ruby + +alias ru='ruby cd \"${fileDirname}\"\u000D' + + +# RoR + + + +# rails db:drop +alias rdd='rails db:drop' + +# rails db:create +alias rdc='rails db:create' + +# rails db:migrate +alias rdm='rails db:migrate' + +# rails db:seed +# alias rds='rails db:seed' + + +# rails db:seed db:create db:migrate +alias rdb='rdd rdc rdm' + + +#Push your code to Heroku +alias gph='git push heroku master' + +alias hpass='git push chateaupass master' +alias hdm='heroku run rails db:migrate --app chateaupass' +alias hrc='heroku run rails c --app chateaupass' +alias hlogs='heroku logs --tail --app chateaupass' + + +# GIT + +# remove .git +alias rmgit='rm -rf .git' + +#git create repo + ignore DS_Store +alias repo='git init; hub create -p; find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch;echo .DS_Store >> .gitignore;git add .gitignore;git commit -m ".DS_Store banished!";git push origin master; ga; comthis "first push on repo"; gor' + +#git generic commit +alias nocom='ga;comthis "generic commit either for test purpose or just lasy...";gor' + +#git ignore DS_Store +alias ds=' find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch;echo .DS_Store >> .gitignore;git add .gitignore;git commit -m ".DS_Store banished!";git push --set-upstream origin $(git rev-parse --abbrev-ref HEAD)' + + +# one-line git log with 24h date+time +alias lo="git log --abbrev-commit --pretty=format:'%h %ad %s' --date=format-local:'%Y-%m-%d %H:%M'" + + +#git remote remove origin +alias grr='git remote remove origin' + +#git log --oneline +#alias com='git log --oneline' +#or +alias com='git lg' + +# git fetch +alias gf='git fetch' + +# git pull +alias gp='git pull' + +# git fetch then pull +alias gfp='gf; gp' + +# git add . +alias ga='git add .' + +#git commit -m .... +alias comthis='git commit -m' + +#Git add/status/commit with question prompt in terminal +function gcom() { + git add . + gst + read REPLY\?"Type commit => " + print "" + print ">> commit is: \"${REPLY}\"" + print "" + git commit -m "${REPLY}" + } + +#Git add/status/commit/push with question prompt in terminal +function cg() { + git add . + gst + read REPLY\?"Type commit => " + print "" + print ">> commit is: \"${REPLY}\"" + print "" + git commit -m "${REPLY}" + git push --set-upstream origin $(git rev-parse --abbrev-ref HEAD) + print "" + print ">> Git STATUS after commit and push origin:" + print "" + gst + } + +# git status then git add . then git status +function gsa() { + gst + ga + gst +} + + +#git checkout master +alias gcm='git checkout main' + +#git checkout branch +alias gcb='git checkout' + +# git push origin +alias gpo='git push origin' + +#git push origin .... +alias gor='git push --set-upstream origin $(git rev-parse --abbrev-ref HEAD)' + +#reset git ignore + +alias resig='git rm -r --cached .; git add .; git commit -m "fixed untracked files"; gst' + + +#LOCAL +# 11. Reload shortcut +alias reload='source ~/.zshrc' # one-word command to re-source your config + +# Show alias file content in terminal +alias al='cat /Users/ces/code/AzCez/dotfiles/aliases' + +# Open your dotfiles in VS Code with: +alias dotfiles='code /Users/ces/code/AzCez/dotfiles' + +# open in visual studio +alias vsc='open . -a "Visual Studio Code"' + +# go to Local to CODE folder +alias codef='cd /Users/ces/code' + + +# go to code folder in cloud +alias icloud='cd /Users/ces/Library/Mobile\ Documents/com~apple~CloudDocs' + +# go to mobeetravel folder in cloud +alias mt='cd /Users/ces/Library/Mobile\ Documents/com~apple~CloudDocs/code/Mobeetravel' + +# 1. Open files or folders in the Cursor IDE +# c() { open -a "Cursor" "$@"; } # defines `c` to launch the Cursor app with given file/dir + +#ZSH test + +function vnc() { + open vnc://"$USER"@"$1" +} + function question() { + git add . + gst + read REPLY\?"Type commit =>" + print "" + print ">> commit is: ${REPLY}" + print "" + git commit -m "${REPLY}" + } + + + + + + + + +#ZSH Interpolation +#TMP=" hello ${:-=cat}" +#$ TMP="${:-=cat}" +#$ print -rl -- $TMP +#=>cat +# question code snippet : #read -q "REPLY?Enter COMMIT?" + +# Development Server Aliases +alias rds="$HOME/code/AzCez/dotfiles/scripts/rds.sh" # Start both Rails and Vite servers +alias crs="$HOME/code/AzCez/dotfiles/scripts/crs.sh" # Check server status +alias krs="echo "Killing Rails server on port 3000..." && lsof -ti:3000 | xargs kill -9 2>/dev/null; pkill -f "rails" 2>/dev/null; pkill -f "puma" 2>/dev/null; pkill -f "bundle exec rails" 2>/dev/null; echo "✅ Rails server killed"" # Kill Rails server only +alias kvs="echo "Killing Vite server on port 3036..." && lsof -ti:3036 | xargs kill -9 2>/dev/null; pkill -f "vite" 2>/dev/null; pkill -f "npm exec vite" 2>/dev/null; echo "✅ Vite server killed"" # Kill Vite server only +alias rvs="$HOME/code/AzCez/dotfiles/scripts/rvs.sh" # Start just Vite server +alias kas="$HOME/code/AzCez/dotfiles/scripts/kas.sh" # Kill all servers \ No newline at end of file diff --git a/scripts/crs.sh b/scripts/crs.sh new file mode 100755 index 0000000000..a5f60b8d5c --- /dev/null +++ b/scripts/crs.sh @@ -0,0 +1,58 @@ +#!/bin/bash +echo "=== SERVER STATUS CHECK ===" +echo "" + +# Check Rails server +RAILS_RUNNING=false +if lsof -i :3000 >/dev/null 2>&1; then + PID=$(lsof -ti :3000 | head -1) + echo "✅ Rails server (port 3000): Running locally on IPv4 & IPv6 (localhost only). PID $PID." + RAILS_RUNNING=true +else + echo "❌ Rails server (port 3000): Not running" +fi + +echo "" + +# Check Vite server +VITE_RUNNING=false +if lsof -i :3036 >/dev/null 2>&1; then + PID=$(lsof -ti :3036 | head -1) + echo "✅ Vite dev server (port 3036): Running and listening on all interfaces (*). PID $PID." + VITE_RUNNING=true +else + echo "❌ Vite dev server (port 3036): Not running" +fi + +echo "" +echo "Related processes:" + +# Check for npm exec vite +NPM_PID=$(ps aux | grep "npm exec vite" | grep -v grep | awk '{print $2}' | head -1) +if [ ! -z "$NPM_PID" ]; then + echo " 📦 npm exec vite helper, PID $NPM_PID." +fi + +# Check for ruby_lsp_rails +RUBY_PID=$(ps aux | grep "ruby_lsp_rails" | grep -v grep | awk '{print $2}' | head -1) +if [ ! -z "$RUBY_PID" ]; then + echo " 🔧 ruby_lsp_rails language server, PID $RUBY_PID." +fi + +echo "" +echo "🌐 Access URLs:" +if [ "$RAILS_RUNNING" = true ]; then + echo " Rails: http://localhost:3000" +fi +if [ "$VITE_RUNNING" = true ]; then + echo " Vite: http://localhost:3036" +fi + +echo "" +echo "🔧 Management commands:" +echo " rds # Start both Rails and Vite servers" +echo " crs # Check server status (this command)" +echo " krs # Kill Rails server only" +echo " kvs # Kill Vite server only" +echo " rvs # Start just Vite server" +echo " kas # Kill all servers" diff --git a/scripts/kas.sh b/scripts/kas.sh new file mode 100755 index 0000000000..3902b7b48c --- /dev/null +++ b/scripts/kas.sh @@ -0,0 +1,27 @@ +#!/bin/bash +echo "🛑 Killing all development servers..." +echo "" + +echo "Stopping Rails server (port 3000)..." +lsof -ti:3000 | xargs kill -9 2>/dev/null +pkill -f "rails" 2>/dev/null +pkill -f "puma" 2>/dev/null +pkill -f "bundle exec rails" 2>/dev/null + +echo "Stopping Vite server (port 3036)..." +lsof -ti:3036 | xargs kill -9 2>/dev/null +pkill -f "vite" 2>/dev/null +pkill -f "npm exec vite" 2>/dev/null + +sleep 1 + +echo "" +echo "✅ All servers killed!" +echo "" +echo "🔧 Management commands:" +echo " rds # Start both Rails and Vite servers" +echo " crs # Check server status" +echo " krs # Kill Rails server only" +echo " kvs # Kill Vite server only" +echo " rvs # Start just Vite server" +echo " kas # Kill all servers (this command)" \ No newline at end of file diff --git a/scripts/krs.sh b/scripts/krs.sh new file mode 100755 index 0000000000..8358d55a61 --- /dev/null +++ b/scripts/krs.sh @@ -0,0 +1,18 @@ +#!/bin/bash +echo "🛑 Killing Rails server on port 3000..." +echo "" + +lsof -ti:3000 | xargs kill -9 2>/dev/null +pkill -f "rails" 2>/dev/null +pkill -f "puma" 2>/dev/null +pkill -f "bundle exec rails" 2>/dev/null + +echo "✅ Rails server killed!" +echo "" +echo "🔧 Management commands:" +echo " rds # Start both Rails and Vite servers" +echo " crs # Check server status" +echo " krs # Kill Rails server only (this command)" +echo " kvs # Kill Vite server only" +echo " rvs # Start just Vite server" +echo " kas # Kill all servers" diff --git a/scripts/kvs.sh b/scripts/kvs.sh new file mode 100755 index 0000000000..24b7c58d5e --- /dev/null +++ b/scripts/kvs.sh @@ -0,0 +1,17 @@ +#!/bin/bash +echo "🛑 Killing Vite server on port 3036..." +echo "" + +lsof -ti:3036 | xargs kill -9 2>/dev/null +pkill -f "vite" 2>/dev/null +pkill -f "npm exec vite" 2>/dev/null + +echo "✅ Vite server killed!" +echo "" +echo "🔧 Management commands:" +echo " rds # Start both Rails and Vite servers" +echo " crs # Check server status" +echo " krs # Kill Rails server only" +echo " kvs # Kill Vite server only (this command)" +echo " rvs # Start just Vite server" +echo " kas # Kill all servers" diff --git a/scripts/rds.sh b/scripts/rds.sh new file mode 100755 index 0000000000..a810dff26a --- /dev/null +++ b/scripts/rds.sh @@ -0,0 +1,40 @@ +#!/bin/bash +echo "🚀 Starting Rails and Vite servers..." +echo "" + +# Kill any existing servers first +echo "Stopping any existing servers..." +pkill -f "bin/rails s" 2>/dev/null || true +pkill -f "bin/vite dev" 2>/dev/null || true +sleep 1 + +echo "Starting Rails server in background..." +(bin/rails s > /tmp/rails.log 2>&1 &) +RAILS_PID=$! + +echo "Starting Vite server in background..." +(bin/vite dev > /tmp/vite.log 2>&1 &) +VITE_PID=$! + +sleep 3 + +echo "" +echo "✅ Both servers started!" +echo "Rails: http://localhost:3000 (PID: $RAILS_PID)" +echo "Vite: http://localhost:3036 (PID: $VITE_PID)" +echo "" +echo "📋 To view server logs:" +echo " tail -f /tmp/rails.log # Rails server" +echo " tail -f /tmp/vite.log # Vite server" +echo "" +echo "🔧 Management commands:" +echo " rds # Start both Rails and Vite servers" +echo " crs # Check server status" +echo " krs # Kill Rails server only" +echo " kvs # Kill Vite server only" +echo " rvs # Start just Vite server" +echo " kas # Kill all servers" +echo "" +echo "🌐 Access URLs:" +echo " Rails: http://localhost:3000" +echo " Vite: http://localhost:3036" diff --git a/scripts/rvs.sh b/scripts/rvs.sh new file mode 100755 index 0000000000..8a531747cf --- /dev/null +++ b/scripts/rvs.sh @@ -0,0 +1,31 @@ +#!/bin/bash +echo "⚡ Starting Vite server..." +echo "" + +# Kill any existing Vite server first +echo "Stopping any existing Vite server..." +pkill -f "bin/vite dev" 2>/dev/null || true +pkill -f "vite" 2>/dev/null || true +sleep 1 + +echo "Starting Vite server in background..." +(bin/vite dev > /tmp/vite.log 2>&1 &) +VITE_PID=$! + +sleep 3 + +echo "" +echo "✅ Vite server started!" +echo "Vite: http://localhost:3036 (PID: $VITE_PID)" +echo "" +echo "📋 To view Vite logs:" +echo " tail -f /tmp/vite.log" +echo "" +echo "🔧 Management commands:" +echo " rds # Start both Rails and Vite servers" +echo " crs # Check server status" +echo " krs # Kill Rails server only" +echo " kvs # Kill Vite server only" +echo " rvs # Start just Vite server" +echo " kas # Kill all servers" +🌐 Access URL: \ No newline at end of file diff --git a/zshrc b/zshrc index 0cebe11525..7af1dfd692 100644 --- a/zshrc +++ b/zshrc @@ -70,3 +70,4 @@ export EDITOR=code # Set ipdb as the default Python debugger export PYTHONBREAKPOINT=ipdb.set_trace +