Skip to content

Instantly share code, notes, and snippets.

@audetcameron
Last active January 7, 2021 20:50
Show Gist options
  • Save audetcameron/6f7fd9d639eedb895cae03c08963e44b to your computer and use it in GitHub Desktop.
Save audetcameron/6f7fd9d639eedb895cae03c08963e44b to your computer and use it in GitHub Desktop.
Bash and zsh aliases and helpers Laravel / NPM etc

aslias for .bashrc and or .zshrc

npm

list npm packages local and global

alias ng="npm list -g --depth=0 2>/dev/null"
alias nl="npm list --depth=0 2>/dev/null"

Laravel

clear laravel cache

alias cachemeoutside='php artisan route:clear && php artisan view:clear && php artisan config:clear && php artisan cache:clear && php artisan clear-compiled && composer dump-autoload'

php artisan rollback function

a-rollback () {
    if [ -z "$1" ]; then
        echo 'php artisan migrate:rollback --step=1'
     else
        echo "php artisan migrate:rollback --step='$1'"
    fi

}

bash command

php artisan route:clear && php artisan view:clear && php artisan config:clear && php artisan cache:clear && php artisan clear-compiled && composer dump-autoload

other helpers

log

alias mysitelog='tail -f /system/path/to/your/laravel.log'

backup

-exclude-vcs to exclude git -exclude='debugbar' to exclude debugbar json

alias mysitebackup='mysqldump mydatabase > ../pathtoyourbackups/mydatabase.sql; tar -zcvf "/pathtoyourbackups/yourfilename-$(date '+%Y-%m-%d').tar.gz" --exclude='*vendor*' --exclude='*node_modules*'  /system/path/to/your/laravel/rootproject'

alias nah="git reset --hard && git clean -df"

when rebooting osx the ssh-add -L has no ssh clients

run ssh-add to add your key to the client so when you ssh into servers it knows who you are.

ssh-add -D to remove identies

Or use an alias function that runs each time the terminal is loaded.

function agentkey(){
	CURRENT_KEY=$(ssh-add -L)
	DEFAULT_MESSAGE="The agent has no identities."
	#echo  ${#CURRENT_KEY} $the count if needed
	#echo  $CURRENT_KEY
	#echo $DEFAULT_MESSAGE
	#if [[ "${#CURRENT_KEY}" -gt 28 ]]; then #this is for counting the default 28 characters of The Agent has no identities.
	if [ "$CURRENT_KEY" != "$DEFAULT_MESSAGE" ]; then
	  #echo "ssh agent is using a key"
	else
	  echo "adding key to ssh agent"
		ssh-add
	fi
}
#run when starting a new terminal window
agentkey
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment