Skip to main content

My OSX ~/.bash_profile

# HERE IS SOME USEFUL ALIAS
export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced
alias ls='ls -GFh'
alias l='ls -GFh'
# Fast way check network connect
alias pingggs='ping -n google.com'
alias pinglocals='ping 192.168.0.1'
alias pingnadia='ping 192.168.10.254'
alias ping10='ping 10.0.0.254'
alias ping101='ping 10.0.0.1'
alias w3mgg='w3m google.com'
alias getip='ifconfig |grep inet'
alias myip='curl icanhazip.com'
# Some manipulate action.
alias c='clear'
alias ll='ls -la'
alias l.='ls -d .* --color=auto'
alias c="clear"
alias l.='ls -d .* --color=auto'
alias ..='cd ..'
alias ...='cd ../..'
alias duh='du -sh'
alias dus='du -sh * |sort -n'
alias findname='find . -name '
alias findloc='/usr/local/bin/findloc.sh'
alias grr='grep -r'
alias grl='grep -rl'
#git
alias gitst='git status'
alias gitpom='git push origin master'
alias gitpod='git push origin develop'
alias gitpdungd='git push dungnv develop'
alias gitp='git pull'
alias gitco='git checkout'
alias gitdiff='git diff'
alias gitlog='git log'
alias gitcm='git commit -m '
#count LOC
alias gitcmnr='git log |grep commit |wc -l'
#Fast go recent project.
alias cdnro='cd ~/Desktop/Netreal1.0/Source/NR_old/'
alias cdnr='cd ~/Documents/SymApp/netreal-2.0/app/'
alias cdmama='cd /Applications/MAMP/'
# Update bash profile and fast edit alias
alias sourcebash='source ~/.bash_profile'
alias viprofile='sudo vim ~/.bash_profile'
#alias phpunit='vendor/bin/phpunit'
alias mampsql='/Applications/MAMP/Library/bin/mysql -u root -p'
alias mampctl=' sudo /Applications/MAMP/Library/bin/apachectl restart'
alias vimphost=' vim /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf'
#MAMP shortcut
alias tailsql='tail -f /Applications/MAMP/logs/mysql_sql.log'
alias tailsql2='tail -f /Applications/MAMP/logs/mysql_error_log.err'
alias tailphp='tail -f /Applications/MAMP/logs/php_error.log'
alias tailapache='tail -f /Applications/MAMP/logs/apache_error.log'
alias tailnr='tail -f ~/Documents/SymApp/netreal-2.0/app/logs/log-2014-03-25.php'
alias tailemp_er='tail -f /Applications/MAMP/logs/emp_9demo_error_log'
alias tailemp_ac='tail -f /Applications/MAMP/logs/emp_9demo_access.log'
alias tailgc_er='tail -f /Applications/MAMP/logs/gcc_9demo_error_log'
alias tailgc_ac='tail -f /Applications/MAMP/logs/gcc_9demo_access.log'
alias tailjob_er='tail -f /Applications/MAMP/logs/job_9demo_error_log'
alias tailjob_ac='tail -f /Applications/MAMP/logs/job_9demo_access.log'
# Math support
alias bc='bc-l'
alias hist='history'
alias j='jobs -l'
#fast ssh
alias sshnal='ssh dev.nal.vn'
alias sshnrpd='ssh netreal@153.122.40.100'
alias sshnal2='ssh netreal2@153.122.30.207'
alias sshbnya='ssh boatnya@157.7.167.16'
alias sshtuan='ssh tuandt@192.168.0.58'
alias sshhuyen='ssh huyendt@192.168.0.62'
alias sshcanh='ssh canhnnt@192.168.0.60'
alias sshhung='ssh hungn@192.168.0.51'
alias svi='sudo vi'
alias vis='vim "+set si"'
alias vinu='vim "+set nu"'
alias ping='ping -c 5'
alias fastping='ping -c 100 -s.2'
# Show opon port
alias ports='netstat -tulanp'
alias phparts='php artisan serve'
## shortcut  for iptables and pass it via sudo#
alias ipt='sudo /sbin/iptables'
# display all rules #
alias iptlist='sudo /sbin/iptables -L -n -v --line-numbers'
alias iptlistin='sudo /sbin/iptables -L INPUT -n -v --line-numbers'
alias iptlistout='sudo /sbin/iptables -L OUTPUT -n -v --line-numbers'
alias iptlistfw='sudo /sbin/iptables -L FORWARD -n -v --line-numbers'
alias firewall=iptlist
export PATH="/usr/local/bin:$PATH"
export PATH=/Applications/MAMP/bin/php/php5.4.10/bin:$PATH
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
# ulimit for mongo warning added by dungnv 28/9
ulimit -n 2048
##
# Your previous /Users/dungnv/.bash_profile file was backed up as /Users/dungnv/.bash_profile.macports-saved_2014-05-22_at_10:54:28
##
# MacPorts Installer addition on 2014-05-22_at_10:54:28: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
export PATH="$PATH:/opt/local/bin"
export PATH=/Applications/MAMP/bin/php/php5.5.10/bin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.
HISTFILESIZE=12080



/************************ On Fly Aliases ****************************************/
When You do not have permission to edit .bashrc, .bash_aliases ... OR you only use aliases on the fly (not want annoying another). You can paste these alias to command line, so be happy in your session.


alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
alias pinggg='ping -n google.com'
alias pingyh='ping -n yahoo.com'
alias pinglocal='ping 192.168.1.1'
alias pinglocal0='ping 192.168.0.1'
alias ping100='ping 192.168.100.1'
alias c="clear"
alias p="clear && pwd"
alias cl="clear && ls"
alias clpd="clear && pwd"
alias cls='printf "\033c"'
alias l.='ls -d .* --color=auto'
alias ..='cd ..'
alias ...='cd ../..'
alias duh='du -sh'
alias dus='du -sh * |sort -n'
alias grr='grep -r'
alias grrex='grep -r --exclude=-s.3'
alias grl='grep -rl'
alias grn='grep -rn'
alias findname='find . -name'


alias chm7='sudo chmod -R 777 '
alias temp='sensors'

# Math support
alias bc='bc-l'
alias hist='history'
alias j='jobs -l'

alias svi='sudo vi'
alias subl='sublime'
alias vis='vim "+set si"'
alias vinu='vim "+set nu"'
alias vimbashrc='vim ~/.bashrc'
alias vimsite='cd /etc/apache2/sites-available/ && sudo vim $1'

alias ping='ping -c 5'
alias fastping='ping -c 100 -s.2'

# Show opon port
alias ports='netstat -tulanp'

## shortcut  for iptables and pass it via sudo#
alias ipt='sudo /sbin/iptables'
alias getip='ifconfig |grep inet'
alias getlcip="ifconfig eth0 | grep inet | awk '{ print $2 }'"
alias getsvip="curl icanhazip.com"

# display all rules #
alias iptlist='sudo /sbin/iptables -L -n -v --line-numbers'
alias iptlistin='sudo /sbin/iptables -L INPUT -n -v --line-numbers'
alias iptlistout='sudo /sbin/iptables -L OUTPUT -n -v --line-numbers'
alias iptlistfw='sudo /sbin/iptables -L FORWARD -n -v --line-numbers'
alias firewall=iptlist

# Dungnv added
#rail start redmine
alias redmst='cd ~/Documents/RoR/Andalousia/redmine && rails s'

#Git n android
alias gitst='git status'
alias gitbr='git branch'
alias gitdif='git diff'
alias gitcm='git commit -m'
alias gitco='git checkout'
alias gitpom='git push origin master'
alias gitcmnr='git log |grep commit |wc -l'
alias gitpuom='git pull origin master'
alias gitpuod='git pull origin develop'
alias gitpom='git push origin master'
alias gitpod='git push origin develop'

alias sourcebash='source ~/.bashrc && source ~/.bash_profile'
# System info
## pass options to free ##
alias meminfo='free -m -l -t'

## get top process eating memory
alias psmem='ps auxf | sort -nr -k 4'
alias psmem10='ps auxf | sort -nr -k 4 | head -10'
 
## get top process eating cpu ##
alias pscpu='ps auxf | sort -nr -k 3'
alias pscpu10='ps auxf | sort -nr -k 3 | head -10'
 
## Get server cpu info ##
alias cpuinfo='lscpu'
   
## older system use /proc/cpuinfo ##
##alias cpuinfo='less /proc/cpuinfo' ##
   
## get GPU ram on desktop / laptop##
alias gpumeminfo='grep -i --color memory /var/log/Xorg.0.log'

#Apache
alias apc_rld='sudo service apache2 reload'
alias apc_rst='sudo service apache2 restart'
alias tail_apch_err='tail -f /var/log/apache2/error.log'
alias tailsql='tail -f /var/log/mysql/mysqld_query.log'
alias tailphp='tail -f /var/log/apache2/error.log'
alias mysqllogin='mysql -u dungnv -p'

#Laravel
alias atsroute='php artisan route:list'
alias atsroutegr='php artisan route:list | grep $1'







Comments

  1. Kết hợp Alias và Bash.
    Kết hợp các mã bash và gõ nhanh khá tiện trong nhiều trường hợp. Ví dụ bạn muốn đếm xem trong mục này có bao nhiêu dòng code của PHP hay C (LOC).
    Bạn có thể thêm 1 file bash vào /usr/local/bin/findloc.sh hay một thư mục bin của riêng bạn. Sau đó thêm alias trong ~/.bashrc hoặc ~/.bash_profile:

    alias findloc='/usr/local/bin/findloc.sh'

    Cập nhật : source ~/.bash_profile. Hoặc dùng luôn 1 alias cho việc này:
    alias viprofile='sudo vim ~/.bash_profile'
    alias sourcebash='source ~/.bash_profile'

    chạy thử: findloc php .:
    806 ./vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/KernelTest.php
    807 ./vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeExtensionGuesser.php
    807 ./vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Kernel.php
    814 ./vendor/laravel/framework/src/Illuminate/Routing/Route.php
    829 ./vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/SimpleMessageTest.php
    830 ./vendor/symfony/finder/Symfony/Component/Finder/Finder.php
    831 ./vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Table.php
    836 ./vendor/laravel/framework/src/Illuminate/Database/Schema/Blueprint.php
    840 ./vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/DB2Platform.php
    840 ./vendor/predis/predis/tests/Predis/Transaction/MultiExecContextTest.php
    841 ./vendor/phpseclib/phpseclib/phpseclib/Crypt/Hash.php
    842 ./vendor/laravel/framework/src/Illuminate/View/Factory.php
    848 ./vendor/laravel/framework/src/Illuminate/Support/Collection.php
    865 ./vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleMimeEntity.php
    866 ./vendor/laravel/framework/src/Illuminate/Container/Container.php
    869 ./vendor/symfony/finder/Symfony/Component/Finder/Tests/FinderTest.php
    870 ./vendor/nesbot/carbon/tests/DiffTest.php

    ....

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. ~/.bashrc thì khi thêm alias có thể các user khác hoặc phần mềm khác có gắn terminal như AndroidStudio có thể không nhận alias. Còn nếu thêm vào ~/.bash_profile thì các terminal các Software khác có thể nhận.
    Chi tiết thêm GG Các trường hợp check allias : ssh, IDE terminal ...

    ReplyDelete
  4. Git alias:
    Lệnh git quá dài và nhàm chán, mất thời gian:

    alias gitcm='git commit -m '
    alias gitcmnr='git log |grep commit |wc -l'
    alias gitco='git checkout'
    alias gitcofr='/Users/dungnv/bin/merge_arg.sh'
    alias gitdiff='git diff'
    alias gitlog='git log'
    alias gitmerd='git merge develop'
    alias gitp='git pull'
    alias gitpdungd='git push dungnv develop'
    alias gitpfr='/Users/dungnv/bin/push_front.sh'
    alias gitpod='git push origin develop'
    alias gitpom='git push origin master'
    alias gitpufr='/Users/dungnv/bin/pull_front.sh'
    alias gitpuod='git pull origin develop'
    alias gitpuom='git pull origin master'
    alias gitst='git status'
    alias gitstapl='git stash apply'

    ReplyDelete
  5. alias gitcofr='/Users/dungnv/bin/merge_arg.sh'

    #!/bin/bash
    FEATURE_FRONT_BRANCH="feature/front_"
    FEATURE_FRONT_BRANCH+="$1"
    git checkout $FEATURE_FRONT_BRANCH

    ReplyDelete
  6. Cách dùng:
    Ví dụ git repo:
    codeception
    develop
    feature/accounts
    feature/encrypt-password
    feature/front_footer
    feature/front_list
    feature/front_profile
    * feature/front_top
    feature/gui_firefox_install
    feature/localForVn
    feature/manage-survey
    feature/master-layout
    feature/migrate
    feature/popup-msg
    feature/refactor-command
    feature/route-structure
    feature/total

    Muốn checkout 1 branch front:
    gitcofr profile tương đương:
    git checkout feature/front_profile.

    cool huh ? :)

    ReplyDelete
  7. Cập nhật Git alias:

    alias gitcm='git commit -m '
    alias gitcmnr='git log |grep commit |wc -l'
    alias gitco='git checkout'
    alias gitcofr='/Users/dungnv/bin/merge_arg.sh'
    alias gitdiff='git diff'
    alias gitlog='git log'
    alias gitmerd='git merge develop'
    alias gitp='git pull'
    alias gitpdungd='git push dungnv develop'
    alias gitpfr='/Users/dungnv/bin/push_front.sh'
    alias gitpod='git push origin develop'
    alias gitpom='git push origin master'
    alias gitpufr='/Users/dungnv/bin/pull_front.sh'
    alias gitpuod='git pull origin develop'
    alias gitpuom='git pull origin master'
    alias gitst='git status'

    ReplyDelete

Post a Comment

Popular posts from this blog

Rand mm 10

https://stackoverflow.com/questions/2447791/define-vs-const Oh const vs define, many time I got unexpected interview question. As this one, I do not know much or try to study this. My work flow, and I believe of many programmer is that search topic only when we have task or job to tackle. We ignore many 'basic', 'fundamental' documents, RTFM is boring. So I think it is a trade off between the two way of study language. And I think there are a bridge or balanced way to extract both advantage of two method. There are some huge issue with programmer like me that prevent we master some technique that take only little time if doing properly. For example, some Red Hat certificate program, lesson, course that I have learned during Collage gave our exceptional useful when it cover almost all topic while working with Linux. I remember it called something like RHEL (RedHat Enterprise Linux) Certificate... I think there are many tons of documents, guide n books about Linux bu

Martin Fowler - Software Architecture - Making Architecture matter

  https://martinfowler.com/architecture/ One can appreciate the point of this presentation when one's sense of code smell is trained, functional and utilized. Those controlling the budget as well as developer leads should understand the design stamina hypothesis, so that the appropriate focus and priority is given to internal quality - otherwise pay a high price soon. Andrew Farrell 8 months ago I love that he was able to give an important lesson on the “How?” of software architecture at the very end: delegate decisions to those with the time to focus on them. Very nice and straight-forward talk about the value of software architecture For me, architecture is the distribution of complexity in a system. And also, how subsystems communicate with each other. A battle between craftmanship and the economics and economics always win... https://hackernoon.com/applying-clean-architecture-on-web-application-with-modular-pattern-7b11f1b89011 1. Independent of Frameworks 2. Testable 3. Indepe