Last active
June 27, 2021 13:58
-
-
Save moatorres/91174602d61cc6d0df403affcff80a92 to your computer and use it in GitHub Desktop.
Bash Profile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# @hoxlux/bash | |
# 🗂 💡 🔑 🔐 🚨 🐙 🌴 🔥 🌈 🥥 🥚 ⏱ 🧰 🧪 🛍 🇬🇧 🇧🇷 | |
alias ga="git add ." | |
alias gc1="git commit -m 'commit inicial'" | |
alias gmaster="git switch master" | |
alias gnext="git switch next" | |
alias gprod="git switch production" | |
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | |
} | |
function prompt { | |
local ICO="🗂 " | |
local RED="\[\e[0;31m\]" | |
local BLUE="\[\e[0;34m\]" | |
local GREEN="\[\e[0;32m\]" | |
local BLUEBG_BLACKTXT="\[\e[37;44;1m\]" | |
local RESET="\[\e[0m\]" | |
export PS1="$ICO hoxlux® " | |
PS2='> ' | |
PS3='+ ' | |
} | |
prompt | |
alias bp='open -e ~/.bash_profile' | |
# 1. ENV | |
export PATH="$PATH:/usr/local/bin/" | |
export PATH="/usr/local/git/bin:/sw/bin/:/usr/local/bin:/usr/local/:/usr/local/sbin:/usr/local/mysql/bin:$PATH" | |
export EDITOR=/usr/bin/nano | |
export BLOCKSIZE=1k | |
export CLICOLOR=1 | |
export LSCOLORS=ExFxBxDxCxegedabagacad | |
# 2. TERMINAL | |
alias cp='cp -iv' # Versão do 'cp' preferida | |
alias mv='mv -iv' # Versão do 'mv' preferida | |
alias mkdir='mkdir -pv' # Versão do 'mkdir' preferida | |
alias ll='ls -FGlAhp' # Versão do 'ls' preferida | |
alias less='less -FSRXc' # Versão do 'less' preferida | |
cd() { builtin cd "$@"; ll; } # Sempre listar arquivos da pasta ao 'cd' | |
mcd () { mkdir -p "$1" && cd "$1"; } # mcd: Makes new Dir and jumps inside | |
trash () { command mv "$@" ~/.Trash ; } # trash: Moves a file to the MacOS trash | |
quicklook () { qlmanage -p "$*" >& /dev/null; } # ql: Opens any file in MacOS Quicklook Preview | |
alias cd..='cd ../' # Voltar 1 diretório (fast/erro) | |
alias ..='cd ../' # Voltar 1 diretório | |
alias ...='cd ../../' # Voltar 2 diretórios | |
alias f='open -a Finder ./' # f: Abrir diretório atual no Finder | |
alias ~="cd ~" # ~: Ir para pasta principal | |
alias c='clear' # c: Limpar tela do Terminal | |
alias DT='tee ~/Desktop/hxlx-terminal.txt' # DT: Enviar texto pro Desktop | |
alias lr='ls -R | grep ":$" | sed -e '\''s/:$//'\'' -e '\''s/[^-][^\/]*\//--/g'\'' -e '\''s/^/ /'\'' -e '\''s/-/|/'\'' | less' | |
# 3. ARQUIVOS E PASTAS | |
zipf () { zip -r "$1".zip "$1" ; } # zipf: To create a ZIP archive of a folder | |
alias numFiles='echo $(ls -1 | wc -l)' # numFiles: Count of non-hidden files in current dir | |
extract () { | |
if [ -f $1 ] ; then | |
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 ;; | |
*.Z) uncompress $1 ;; | |
*.7z) 7z x $1 ;; | |
*) echo "'$1' não pôde ser extraído via extract()" ;; | |
esac | |
else | |
echo "'$1' não é um arquivo válido" | |
fi | |
} | |
# 4. SEARCHING | |
ff () { /usr/bin/find . -name "$@" ; } # ff: Find file under the current directory | |
ffs () { /usr/bin/find . -name "$@"'*' ; } # ffs: Find file whose name starts with a given string | |
ffe () { /usr/bin/find . -name '*'"$@" ; } # ffe: Find file whose name ends with a given string | |
spotlight () { mdfind "kMDItemDisplayName == '$@'wc"; } | |
# 5. PROCESSO | |
# E.g. findPid '/d$/' finds pids of all processes with names ending in 'd' | |
findPid () { lsof -t -c "$@" ; } | |
alias memHogsTop='top -l 1 -o rsize | head -20' | |
alias memHogsPs='ps wwaxm -o pid,stat,vsize,rss,time,command | head -10' | |
alias cpu_hogs='ps wwaxr -o pid,stat,%cpu,time,command | head -10' | |
alias topForever='top -l 9999999 -s 10 -o cpu' | |
alias ttop="top -R -F -s 10 -o rsize" | |
meusProcessos() { ps $@ -u $USER -o pid,%cpu,%mem,start,time,bsdtime,command ; } | |
# 6. NETWORK | |
alias meuIp='ipconfig getifaddr en0' | |
alias myip='curl ip.appspot.com' # myip: Endereço de IP Público | |
alias netCons='lsof -i' # netCons: Sockets TCP/IP abertos | |
alias flushDNS='dscacheutil -flushcache' # flushDNS: Flush DNS | |
alias lsock='sudo /usr/sbin/lsof -i -P' # lsock: Mostrar open Sockets | |
alias lsockU='sudo /usr/sbin/lsof -nP | grep UDP' # lsockU: Mostrar UDP open Sockets | |
alias lsockT='sudo /usr/sbin/lsof -nP | grep TCP' # lsockT: Mostrar TCP open Sockets | |
alias ipInfo0='ipconfig getpacket en0' # ipInfo0: Conexões do en0 | |
alias ipInfo1='ipconfig getpacket en1' # ipInfo1: Conexões do en1 | |
alias openPorts='sudo lsof -i | grep LISTEN' # openPorts: Mostrar portas abertas (listening) | |
alias showBlocked='sudo ipfw list' # showBlocked: Mostrar regras do 'ipfw' inc. IPs bloqueados | |
ii() { | |
echo -e "\nVocê está logado no ${RED}$HOST" | |
echo -e "\nInformações Adicionais:$NC " ; uname -a | |
echo -e "\n${RED}Usuários Logados:$NC " ; w -h | |
echo -e "\n${RED}Data:$NC " ; date | |
echo -e "\n${RED}Stats:$NC " ; uptime | |
echo -e "\n${RED}Localização Física:$NC " ; scselect | |
echo | |
} | |
# 7. SYS OPS | |
alias cleanupDS="find . -type f -name '*.DS_Store' -ls -delete" | |
alias finderShowHidden='defaults write com.apple.finder ShowAllFiles TRUE' | |
alias finderHideHidden='defaults write com.apple.finder ShowAllFiles FALSE' | |
alias cleanupLS="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user && killall Finder" | |
alias screensaverDesktop='/System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background' | |
# 8. WEB DEV | |
httpHeaders () { /usr/bin/curl -I -L $@ ; } | |
httpDebug () { /usr/bin/curl $@ -o /dev/null -w "dns: %{time_namelookup} connect: %{time_connect} pretransfer: %{time_pretransfer} starttransfer: %{time_starttransfer} total: %{time_total}\n" ; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment