Skip to content

Instantly share code, notes, and snippets.

@caot
Last active March 23, 2024 19:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caot/5065387b84771b0d5a09959c9dbb9a5d to your computer and use it in GitHub Desktop.
Save caot/5065387b84771b0d5a09959c9dbb9a5d to your computer and use it in GitHub Desktop.
# git config merge.renormalize true ## https://stackoverflow.com/questions/861995/is-it-possible-for-git-merge-to-ignore-line-ending-differences
# git merge -s recursive -Xignore-space-at-eol
# git switch -f master # FIXED error: The following untracked working tree files would be overwritten by checkout
# https://unix.stackexchange.com/questions/314974/how-to-delete-broken-symlinks-in-one-go/314975#314975
# find . -xtype l -delete
# https://askubuntu.com/questions/55325/how-to-use-grep-command-to-find-text-including-subdirectories
# grep -Hrn 'Text to be searched' ../
# grep -inRsH "Text to be searched" /path/to/dir (it can be '.')
# i stands for ignore case distinctions
# r does a recursive search
# R stands for recursive and it also include symlinks. Better to use 'R' instead 'r'
# n stands for "it will print line number".
# s stands for "suppress error messages"
# H stands for "it will print the file name for each match"
for v in logs log
do
[ "$(ls -A ~/$v)" ] && rm ~/$v/*
done
bcom=~/.config/bcompare
# rm ./BCLOCK_* ./registry.dat
for v in $bcom/BCLOCK_* $bcom/registry.dat
do
[ -e $v ] && rm $v
done
export JAVA_HOME=~/apps/jdk-22
export PATH=$JAVA_HOME/bin:$PATH
export HISTCONTROL=ignoreboth:erasedups
alias grept='grep -inRsH'
alias l='ls -lrt'
alias la='ls -lrta'
alias killrs="ps aux | grep runserver | awk '{print $2}' | xargs kill -9"
# dos2unix
# awk '{ sub("\r$", ""); print }'
alias gurl='git config --get remote.origin.url'
alias gaa='git add --all'
alias gd='git diff --name-only --ignore-space-change'
alias gb='git branch'
alias gbc='gb | grep "*"'
alias gbr='git branch -r'
alias gbt="git for-each-ref --sort='-authordate:iso8601' --format=' %(authordate:relative)%09%(refname:short)' refs/heads | tac"
alias gbtr="gbt | grep -E 'days|hours|minutes|weeks|weeks|seconds'"
#alias gbl="for k in $(git branch -l | perl -pe 's/^..(.*?)( ->.*)?$/\1/'); do echo -e $(git show --pretty=format:'%Cgreen%ci %Cblue%cr%Creset' $k -- | head -n 1)\\t$k; done | sort | tail -15f"
alias gds='git diff --staged'
# git diff branch1..branch2
# Delete remote Branch
# Note that in most cases the remote name is origin. In such a case you'll have to use the command like so.
alias gpdo='git push -d origin '
# Delete Local Branch
# Note: The -d option is an alias for --delete, which only deletes the branch
# if it has already been fully merged in its upstream branch.
# You could also use -D, which is an alias for --delete --force, which deletes
# the branch "irrespective of its merged status." [Source: man git-branch]
alias gbd='git branch -d '
alias gbD='git branch -D '
# -m, --move Move/rename a branch and the corresponding reflog
alias gbm='git branch -m '
alias gbg='gbt | grep -E $(cut -f 3 xxxx | paste -sd "|")'
alias gst='git stash'
# git stash # saves your changes to the top of the stash stack
# git stash save "message to go along with changes"
# git stash -u # stash untracked files as well
alias gsl='git stash list'
alias gsd='git stash list --date=local'
alias gsp='git stash pop'
alias gss='git stash show -p stash@{0}'
# git stash apply stash@{stash_index} # apply a given item in the stash (from git stash list)
# How to list all the files in a commit?
alias gsh='git diff-tree --no-commit-id --name-only -r'
alias gp='git pull --ff'
alias gpf='git pull --rebase=false'
alias gpo='git push origin'
alias gpod='git push origin develop'
alias gpom='git push origin master'
alias gpor='git push origin Release'
# Delete remote Branch
# Note that in most cases the remote name is origin. In such a case you'll have to use the command like so.
alias gpdo='git push -d origin'
# git push -f
alias gpa='git format-patch HEAD'
# gcb - git checkout -b
alias gc='git checkout'
alias gca='git commit --amend'
alias gcd='git checkout develop && git pull --ff'
alias gcm='git checkout master && git pull --ff'
alias gcr='git checkout Release && git pull --ff'
# git checkout -- <bad-filename>
# git checkout <branch-name> <file-name>
alias gcmt='git config --global --add merge.ff true'
alias gcmf='git config --global --add merge.ff false'
alias gcus='git config --global core.safecrlf false' # https://stackoverflow.com/questions/5834014/lf-will-be-replaced-by-crlf-in-git-what-is-that-and-is-it-important
alias gcu='git config core.autocrlf false'
alias gcw='git config core.autocrlf true'
# From the branch you want to bring the commit *into*
# git cherry-pick <commit-sha>
alias grs='git reset --soft HEAD~1'
# git reset --hard HEAD
# git reset --hard HEAD~1
# git rebase -i <commit hash> # where the commit hash is the one *before* all the changes you want t
# git rebase --abort
alias gref='git reflog'
# git reset <commit-sha>
# git reset --hard HEAD~n # n is the last n commits
# git reset --hard <commit-sha> # or to a specific commit
# git rm --cached <file-name>
alias gs='git status'
alias gsfm='git switch -f master' # FIXED error: The following untracked working tree files would be overwritten by checkout
# alias gm='git merge'
# https://stackoverflow.com/questions/861995/is-it-possible-for-git-merge-to-ignore-line-ending-differences
alias gm='git merge --no-ff -s recursive -Xignore-space-at-eol'
alias gmf='git merge -s recursive -Xignore-space-at-eol'
alias gl='git log -n '
alias gl5='git log -n 5'
alias glm='git log --merges'
alias gl1='git log --oneline --author='
alias glh='git log --help'
alias glg='git log --graph'
# gst - git status
# gc - git commit
# gaa - git add --all
# gco - git checkout
# gp - git push
# gl - git pull
# gcb - git checkout -b
# gm - git merge
# grb - git rebase
# gpsup - git push --set-upstream origin $(current_branch)
# gbda - git branch --no-color --merged | command grep -vE "^(\+|\*|\s*(master|develop|dev)\s*$)" | command xargs -n 1 git branch -d
# gfa - git fetch --all --prune
alias glgrep="gl1 | awk '{print $2}' | grep RESIT | sort | uniq | grep "
alias mp='module purge'
alias ml='module list'
alias ml2='module purge && module load python/2.7.12'
alias ml3='module purge && module load anaconda/3'
alias anki@me='module purge && module load glibc/2.18 && anki'
alias gsmart='sh ~/apps/smartgit/bin/smartgit.sh&'
#alias eclipse='~/apps/eclipse-cpp-2020-03/eclipse/eclipse&'
function eclipse { command ~/apps/eclipse-cpp-2020-03/eclipse/eclipse > /dev/null 2>&1 & }
# alias navicat='~/apps/navicat*_premium_en_x64/start_navicat'
alias navicat='~/apps/navicat15-premium-en-15.0.23/AppRun&'
alias src='source'
@caot
Copy link
Author

caot commented Sep 24, 2019

cut -f 3 XX.txt | paste -sd "|" -

@caot
Copy link
Author

caot commented Apr 13, 2021

git status | egrep -v '.pyc|.old|.orig' | grep -E 'modified:' | awk '{print $3}' | xargs git checkout --

@caot
Copy link
Author

caot commented Dec 5, 2021

@caot
Copy link
Author

caot commented Mar 22, 2024

https://superuser.com/questions/456438/how-do-i-scp-a-file-through-an-intermediate-server/456458#456458

This has already been answered best here.

To summarize: put the following in ~/.ssh/config

Host target.machine
User targetuser
HostName target.machine
ProxyCommand ssh proxyuser@proxy.machine nc %h %p 2> /dev/null

and then simply scp to target.machine any time you want to proxy via proxy.machine!

Also works for ssh, so will save you time ssh-ing to the target machine too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment