Last active
July 13, 2024 23:57
-
-
Save Crowles/f2f2a78e5c0dfb0e74caff40429f8c23 to your computer and use it in GitHub Desktop.
Useful aliases, commands, ini configs etc. (general resource)
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
alias statc="stat -c '%a %G:%U %n'" | |
alias ccat="pygmentize -g" | |
alias tlog="tail -f -n 0 storage/logs/laravel.log" | |
alias phpcf="php --ini | grep 'Loaded'" | |
eval $(thefuck --alias) | |
# custom functions | |
# IP Lookup | |
function rip | |
{ | |
getent hosts $1 | awk '{ print $1 }' | |
} | |
# Traverse Directories | |
function up | |
{ | |
LIMIT=$1 | |
P=$PWD | |
for ((i=1; i <= LIMIT; i++)) | |
do | |
P=$P/.. | |
done | |
cd $P | |
export MPWD=$P | |
} | |
function back | |
{ | |
LIMIT=$1 | |
P=$MPWD | |
for ((i=1; i <= LIMIT; i++)) | |
do | |
P=${P%/..} | |
done | |
cd $P | |
export MPWD=$P | |
} | |
# Recursively search archives | |
function uzsearch | |
{ | |
for i in *.zip; do grep -iq "$1" < <( unzip -l $i ) && echo $i; done | |
} | |
function parse_git_branch | |
{ | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | |
} | |
function centos | |
{ | |
( cd ~/centOS-dev-box && vagrant $* ) | |
} | |
# Override prompt | |
PS1='\[\033]0;${PWD//[^[:ascii:]]/?}\007\]' # set window title | |
PS1=$PS1'\[\033[01;32m\]\[\033[01m\033[01;32m\]\u\[\033[01;00m\]@\[\033[01;32m\]\h ' # user @ host | |
PS1=$PS1'\[\033[01;00m\]\W' # current working directory | |
PS1=$PS1'\[\033[01;33m\]$(parse_git_branch)' # git branch | |
PS1=$PS1'\n\[\033[01;32m\]└─\[\033[01m\033[0;00m\] \$\[\033[00m\] ' # newline prompt | |
MSYS2_PS1="$PS1" # for detection by MSYS2 SDK's bash.basrc |
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
# https://stackoverflow.com/questions/1838873/visualizing-branch-topology-in-git/34467298#34467298 | |
[alias] | |
lg = !"git lg1" | |
lg1 = !"git lg1-specific --all" | |
lg2 = !"git lg2-specific --all" | |
lg3 = !"git lg3-specific --all" | |
lg1-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)' | |
lg2-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(auto)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' | |
lg3-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset) %C(bold cyan)(committed: %cD)%C(reset) %C(auto)%d%C(reset)%n'' %C(white)%s%C(reset)%n'' %C(dim white)- %an <%ae> %C(reset) %C(dim white)(committer: %cn <%ce>)%C(reset)' |
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
# Copy SSH keys | |
ssh-copy-id -i $HOME/.ssh/id_rsa.pub [email protected] | |
# Search specific lines in file e.g. last 20 of first 30 lines (10 - 30) | |
head -30 /path/to/file | tail -20 | |
sed -n '4119485,4119585p;4119586q' /path/to/file | |
# Delete multiple git branches (first is a safe 'dry run') | |
git branch -r | awk -F/ '/\/PREFIX/{print $2}' | |
# git branch -r | awk -F/ '/\/PREFIX/{print $2}' | xargs -I {} git push origin :{} | |
# setup dir | |
install -d -m 700 ~/.ssh | |
# Find and kill processes | |
ps -eaf | grep [p]attern | |
kill -9 pid | |
# Obtain names of shared libs | |
ldd /path/to/program | |
# Read value of symbolic link | |
readlink /path/ | |
# List vhost ips | |
apache2ctl -S 2>&1 | grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | sort | uniq | |
# Unban IP | |
fail2ban-client set *jail* unbanip *ip* |
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
[xdebug] | |
zend_extension=xdebug.so | |
xdebug.remote_connect_back=1 | |
xdebug.profiler_enable=1 | |
xdebug.profiler_output_dir="/home/vagrant/app_profiles" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment