mirror of
https://github.com/marcogll/mac_vntySet.git
synced 2026-01-13 13:25:15 +00:00
304 lines
9.8 KiB
Plaintext
304 lines
9.8 KiB
Plaintext
# =======================================================================
|
|
# Vanity Shell - Configuracion base para macOS (inspirada en MG v3.0)
|
|
# =======================================================================
|
|
# Orientada a Zsh + Oh My Zsh + Oh My Posh. Ajusta cualquier seccion
|
|
# segun tus necesidades personales antes de copiarla a ~/.zshrc.
|
|
# =======================================================================
|
|
|
|
# --- Locale --------------------------------------------------------------
|
|
export LANG=en_US.UTF-8
|
|
export LC_ALL=en_US.UTF-8
|
|
|
|
# --- Homebrew + PATH -----------------------------------------------------
|
|
if [[ -x /opt/homebrew/bin/brew ]]; then
|
|
eval "$(/opt/homebrew/bin/brew shellenv)"
|
|
elif [[ -x /usr/local/bin/brew ]]; then
|
|
eval "$(/usr/local/bin/brew shellenv)"
|
|
fi
|
|
|
|
typeset -U path PATH
|
|
path=(
|
|
/opt/homebrew/bin
|
|
/opt/homebrew/sbin
|
|
/usr/local/bin
|
|
/usr/local/sbin
|
|
$HOME/.local/bin
|
|
$HOME/bin
|
|
$HOME/.npm-global/bin
|
|
$HOME/AppImages
|
|
$HOME/go/bin
|
|
$path
|
|
)
|
|
export PATH
|
|
|
|
# --- Oh My Zsh -----------------------------------------------------------
|
|
export ZSH="$HOME/.oh-my-zsh"
|
|
ZSH_THEME="" # el prompt final lo gestiona Oh My Posh
|
|
|
|
plugins=(
|
|
git sudo history colorize
|
|
|
|
npm node python pip golang
|
|
copypath copyfile
|
|
zsh-autosuggestions
|
|
zsh-syntax-highlighting
|
|
zsh-completions
|
|
)
|
|
|
|
export ZSH_DISABLE_COMPFIX=true
|
|
zstyle ':completion::complete:*' use-cache on
|
|
zstyle ':completion::complete:*' cache-path "$HOME/.zcompcache"
|
|
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
|
|
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
|
|
zstyle ':completion:*' menu select
|
|
|
|
[[ -r "$ZSH/oh-my-zsh.sh" ]] && source "$ZSH/oh-my-zsh.sh"
|
|
|
|
for plugin_file in \
|
|
"${ZSH_CUSTOM:-$ZSH/custom}/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh" \
|
|
"/usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh"
|
|
do
|
|
[[ -r "$plugin_file" ]] && source "$plugin_file" && break
|
|
done
|
|
|
|
for plugin_file in \
|
|
"${ZSH_CUSTOM:-$ZSH/custom}/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" \
|
|
"/usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
|
|
do
|
|
[[ -r "$plugin_file" ]] && source "$plugin_file" && break
|
|
done
|
|
|
|
# --- Oh My Posh ----------------------------------------------------------
|
|
if command -v oh-my-posh >/dev/null 2>&1; then
|
|
if [[ -f "$HOME/.poshthemes/catppuccin.omp.json" ]]; then
|
|
eval "$(oh-my-posh init zsh --config "$HOME/.poshthemes/catppuccin.omp.json")"
|
|
else
|
|
eval "$(oh-my-posh init zsh)"
|
|
fi
|
|
fi
|
|
|
|
# --- Direnv --------------------------------------------------------------
|
|
if command -v direnv >/dev/null 2>&1; then
|
|
eval "$(direnv hook zsh)"
|
|
fi
|
|
|
|
# --- Go / Node / Python --------------------------------------------------
|
|
export GOPATH="$HOME/go"
|
|
export GOBIN="$GOPATH/bin"
|
|
export PATH="$GOBIN:$PATH"
|
|
|
|
export NVM_DIR="$HOME/.nvm"
|
|
[[ -s "$NVM_DIR/nvm.sh" ]] && source "$NVM_DIR/nvm.sh"
|
|
[[ -s "$NVM_DIR/bash_completion" ]] && source "$NVM_DIR/bash_completion"
|
|
|
|
alias pip='pip3'
|
|
alias python='python3'
|
|
|
|
venv() {
|
|
case "$1" in
|
|
create) python -m venv .venv && echo "Entorno virtual creado en .venv" ;;
|
|
on|activate)
|
|
if [[ -f .venv/bin/activate ]]; then
|
|
source .venv/bin/activate && echo "Entorno virtual activado"
|
|
else
|
|
echo "No se encontro .venv/bin/activate"
|
|
fi
|
|
;;
|
|
off|deactivate)
|
|
command -v deactivate >/dev/null 2>&1 && deactivate && echo "Entorno virtual desactivado" || echo "No hay entorno activo"
|
|
;;
|
|
*) echo "Uso: venv [create|on|off|activate|deactivate]" ;;
|
|
esac
|
|
}
|
|
|
|
# --- Alias Generales ------------------------------------------------------
|
|
alias cls='clear'
|
|
alias ll='ls -alF'
|
|
alias la='ls -A'
|
|
alias l='ls -CF'
|
|
alias ..='cd ..'
|
|
alias ...='cd ../..'
|
|
alias ....='cd ../../..'
|
|
alias reload='source ~/.zshrc'
|
|
|
|
# --- Git ------------------------------------------------------------------
|
|
alias gs='git status -sb'
|
|
alias ga='git add'
|
|
alias gc='git commit'
|
|
alias gcm='git commit -m'
|
|
alias gp='git push'
|
|
alias gl='git pull'
|
|
alias gd='git diff'
|
|
alias gb='git branch'
|
|
alias gco='git checkout'
|
|
alias gcb='git checkout -b'
|
|
alias glog='git log --oneline --graph --decorate'
|
|
gac() { git add . && git commit -m "$1"; }
|
|
|
|
# --- Docker Desktop ------------------------------------------------------
|
|
if docker compose version >/dev/null 2>&1; then
|
|
alias dc='docker compose'
|
|
else
|
|
alias dc='docker-compose'
|
|
fi
|
|
alias d='docker'
|
|
alias dps='docker ps -a'
|
|
alias di='docker images'
|
|
alias dex='docker exec -it'
|
|
alias dlog='docker logs -f'
|
|
|
|
# --- NPM ------------------------------------------------------------------
|
|
alias nrs='npm run start'
|
|
alias nrd='npm run dev'
|
|
alias nrb='npm run build'
|
|
alias nrt='npm run test'
|
|
alias ni='npm install'
|
|
alias nid='npm install --save-dev'
|
|
alias nig='npm install -g'
|
|
|
|
# --- Utilidades -----------------------------------------------------------
|
|
alias clima='curl wttr.in/Mexico+City'
|
|
mkcd() { mkdir -p "$1" && cd "$1"; }
|
|
extract() {
|
|
[[ ! -f "$1" ]] && echo "No es un archivo" && return 1
|
|
case "$1" in
|
|
*.tar.bz2) tar xjf "$1" ;;
|
|
*.tar.gz) tar xzf "$1" ;;
|
|
*.bz2) bunzip2 "$1" ;;
|
|
*.rar) unrar e "$1" ;;
|
|
*.gz) gunzip "$1" ;;
|
|
*.tar) tar xf "$1" ;;
|
|
*.tbz2) tar xjf "$1" ;;
|
|
*.tgz) tar xzf "$1" ;;
|
|
*.zip) unzip "$1" ;;
|
|
*.7z) 7z x "$1" ;;
|
|
*) echo "Formato no soportado: $1" ;;
|
|
esac
|
|
}
|
|
killport() {
|
|
[[ -z "$1" ]] && echo "Uso: killport <puerto>" && return 1
|
|
local pid
|
|
pid=$(lsof -ti:"$1" 2>/dev/null)
|
|
[[ -n "$pid" ]] && kill -9 "$pid" && echo "Proceso $pid detenido en puerto $1" || echo "Sin procesos en puerto $1"
|
|
}
|
|
serve() { python -m http.server "${1:-8000}"; }
|
|
|
|
# --- yt-dlp ---------------------------------------------------------------
|
|
# Mantiene los videos en ~/Movies/Youtube y el audio en ~/Music/Youtube
|
|
# para que aparezcan dentro de las apps de macOS (TV / Música) si así lo deseas.
|
|
export YTDLP_VIDEO_DIR="$HOME/Movies/Youtube"
|
|
export YTDLP_AUDIO_DIR="$HOME/Music/Youtube"
|
|
mkdir -p "$YTDLP_VIDEO_DIR" "$YTDLP_AUDIO_DIR" >/dev/null 2>&1
|
|
|
|
ytm() {
|
|
if [[ -z "$1" || "$1" == "-h" || "$1" == "--help" ]]; then
|
|
echo "Uso: ytm <url|busqueda> - Descarga audio MP3 en $YTDLP_AUDIO_DIR (calidad maxima)."
|
|
return 0
|
|
fi
|
|
yt-dlp -f bestaudio --extract-audio --audio-format mp3 --audio-quality 0 \
|
|
--embed-metadata --embed-thumbnail \
|
|
-o "$YTDLP_AUDIO_DIR/%(title).180s.%(ext)s" "$1"
|
|
}
|
|
|
|
ytv() {
|
|
if [[ -z "$1" ]]; then
|
|
echo "Uso: ytv <url|busqueda> [1080|720|480|best] - Descarga video MP4 en $YTDLP_VIDEO_DIR."
|
|
return 1
|
|
fi
|
|
local quality="${2:-best}"
|
|
local fmt
|
|
case "$quality" in
|
|
1080) fmt='bv*[height<=1080][ext=mp4]+ba/b[height<=1080]' ;;
|
|
720) fmt='bv*[height<=720][ext=mp4]+ba/b[height<=720]' ;;
|
|
480) fmt='bv*[height<=480][ext=mp4]+ba/b[height<=480]' ;;
|
|
*) fmt='bv*[ext=mp4]+ba/b[ext=mp4]/b' ;;
|
|
esac
|
|
yt-dlp -f "$fmt" --embed-subs --embed-metadata --embed-thumbnail \
|
|
-o "$YTDLP_VIDEO_DIR/%(title).180s.%(ext)s" "$1"
|
|
}
|
|
|
|
ytls() {
|
|
echo "Audios recientes ($YTDLP_AUDIO_DIR):"
|
|
ls -1t "$YTDLP_AUDIO_DIR" 2>/dev/null | head -5 | sed 's/^/ /' || echo " (vacio)"
|
|
echo "Videos recientes ($YTDLP_VIDEO_DIR):"
|
|
ls -1t "$YTDLP_VIDEO_DIR" 2>/dev/null | head -5 | sed 's/^/ /' || echo " (vacio)"
|
|
}
|
|
|
|
# --- SSH Agent ------------------------------------------------------------
|
|
if [[ -z "$SSH_AUTH_SOCK" ]]; then
|
|
export SSH_AGENT_DIR="$HOME/.ssh/agent"
|
|
mkdir -p "$SSH_AGENT_DIR"
|
|
SSH_ENV="$SSH_AGENT_DIR/env"
|
|
start_agent() {
|
|
ssh-agent >"$SSH_ENV"
|
|
chmod 600 "$SSH_ENV"
|
|
source "$SSH_ENV" >/dev/null
|
|
}
|
|
if [[ -f "$SSH_ENV" ]]; then
|
|
source "$SSH_ENV" >/dev/null
|
|
ps -p "$SSH_AGENT_PID" >/dev/null 2>&1 || start_agent
|
|
else
|
|
start_agent
|
|
fi
|
|
fi
|
|
|
|
alias ssh-list='ssh-add -l'
|
|
alias ssh-clear='ssh-add -D'
|
|
alias ssh-github='ssh -T git@github.com'
|
|
|
|
# --- zoxide ---------------------------------------------------------------
|
|
if command -v zoxide >/dev/null 2>&1; then
|
|
eval "$(zoxide init zsh)"
|
|
alias zz='z -'
|
|
alias zi='zi'
|
|
fi
|
|
|
|
# --- Historial ------------------------------------------------------------
|
|
HISTFILE="$HOME/.zsh_history"
|
|
HISTSIZE=100000
|
|
SAVEHIST=100000
|
|
setopt APPEND_HISTORY SHARE_HISTORY HIST_IGNORE_DUPS HIST_IGNORE_ALL_DUPS HIST_IGNORE_SPACE AUTO_CD EXTENDED_GLOB
|
|
stty -ixon 2>/dev/null
|
|
|
|
# --- Completions Extras ---------------------------------------------------
|
|
if command -v kubectl >/dev/null 2>&1; then
|
|
source <(kubectl completion zsh)
|
|
fi
|
|
if command -v docker >/dev/null 2>&1; then
|
|
source <(docker completion zsh)
|
|
fi
|
|
|
|
# --- Ayuda rapida ---------------------------------------------------------
|
|
vanity_help() {
|
|
cat <<'EOF'
|
|
Vanity CLI — ayuda rapida
|
|
|
|
Multimedia:
|
|
ytv <url> [1080|720|480|best] Descarga videos MP4 en ~/Movies/Youtube con metadatos.
|
|
ytm <url> Extrae audio MP3 en ~/Music/Youtube (incluye arte y metadata).
|
|
ytls Muestra los ultimos archivos bajados por ytv/ytm.
|
|
|
|
Productividad:
|
|
venv create|on|off Crea/activa/desactiva entornos Python en .venv.
|
|
mkcd <ruta> Crea un directorio y entra en el con un solo comando.
|
|
extract <archivo> Detecta extension y descomprime automaticamente.
|
|
killport <puerto> Elimina procesos que usan el puerto indicado.
|
|
serve [puerto] Levanta un servidor HTTP simple (default 8000).
|
|
reload Recarga ~/.zshrc para aplicar cambios al instante.
|
|
|
|
Contenedores:
|
|
d / dc / dps / dlog Alias para Docker CLI y docker compose via Docker Desktop.
|
|
lazydocker UI en terminal para revisar contenedores.
|
|
|
|
Red/Utilidades:
|
|
zerotier-cli info Muestra el estado del cliente ZeroTier.
|
|
speedtest-cli Ejecuta una prueba rapida de velocidad.
|
|
clima Clima de CDMX directamente en la terminal.
|
|
|
|
Tip: ejecuta 'help' en cualquier momento para ver este listado.
|
|
EOF
|
|
}
|
|
alias help='vanity_help'
|
|
|
|
echo "Vanity CLI | 'help' sirve para ver los comandos."
|