Skip to content

Instantly share code, notes, and snippets.

@TRex22
Last active February 4, 2020 10:37
Show Gist options
  • Save TRex22/2777f3f17b3145c0c05041d5bbba4cc1 to your computer and use it in GitHub Desktop.
Save TRex22/2777f3f17b3145c0c05041d5bbba4cc1 to your computer and use it in GitHub Desktop.
Useful Bash, Git and Other Scripts and Aliases

Kill a process by ip connection

kill -9 $(lsof -i tcp:80 -t)

Reset OpenSSH-Server config (debian dpkg based)

sudo rm /etc/ssh/ssh_host_*
sudo dpkg-reconfigure openssh-server

Aliases

alias ls='ls -G'
alias ll='ls -lG'
alias l='ls'

alias s='spring stop;./bin/start'
alias ss='./bin/spring stop'
alias r='./bin/rake'
alias rt='./bin/rake test'

alias harakiri="heroku access:remove <user_email> --app <app-name>"
alias kill-rails='ss;kill -9 97916 97920'
alias hc='heroku console --app'

alias update_tex='texhash'
alias install_tex='sudo tlmgr install'

alias dr='docker run -it '

Git

Find any focus tags in tests

git diff|grep focus|cat
git diff|grep --color focus|cat
git diff --name-only | xargs grep --color -Hn focus

Git alias

git config --global alias.undo '!git checkout origin/master --' # use with a file name or will reset all files to master
git config --global alias.uncommit '!git reset --soft HEAD^'
git config --global alias.diffp '!git diff --color | diff-so-fancy'
git config --global alias.mm '!git merge --no-ff origin/master'
git config --global alias.unstage 'reset HEAD --'
git config --global alias.last 'log -1 HEAD'
git config --global alias.visual '!gitk'
git config --global alias.glog '!git log --oneline --decorate --graph'
git config --global alias.undo-commit '!git reset --soft HEAD~1'

git config --global alias.addall '! ~/git_addall.sh' (see: https://gist.github.com/TRex22/e0c0cbce50c7436b01a09dc8535f0fb8)

Del local branches which have been merged on master

alias gcc='git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d'

Fix a locking condition

vim -r /Users/jasonmaxchalom/development/repo/.git/MERGE_MSG
rm /Users/jasonmaxchalom/development/repo/.git/.MERGE_MSG.swp

Random

Rollup GitHub UI when reviewing a lareg PR with many files (web browser console)

for (el of document.getElementsByClassName("js-details-target")) {el.click()}.

rename multiple files

https://stackoverflow.com/questions/20169517/globally-replace-text-to-rename-multiple-files-in-sublime If you are using a linux system instead of using sublime you could use a terminal, change directories to your project root and use:

find . -name '*owner*' -exec bash -c 'mv $0 ${0/owner/user}' {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment