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

AWS Elasticache Memcached connection

https://docs.aws.amazon.com/AmazonElastiCache/latest/mem-ug/accessing-elasticache.html#access-from-outside-aws http://hourlyapps.blogspot.com/2010/06/examples-of-memcached-commands.html Access memcached https://docs.aws.amazon.com/AmazonElastiCache/latest/mem-ug/GettingStarted.AuthorizeAccess.html Zip include hidden file https://stackoverflow.com/questions/12493206/zip-including-hidden-files phpmemcachedadmin ~ phpMyAdmin or phpPgAdmin ... telnet mycachecluster.eaogs8.0001.usw2.cache.amazonaws.com 11211 stats items stats cachedump 27 100 https://docs.aws.amazon.com/AmazonElastiCache/latest/mem-ug/VPCs.EC.html https://lzone.de/cheat-sheet/memcached VPC ID Security Group ID (sg-...) Cluster: The identifier for the cluster memcached1 Creation Time: The time (UTC) when the cluster was created January 9, 2019 at 11:47:16 AM UTC+7 Configuration Endpoint: The configuration endpoint of the cluster memcached1.ahgofe.cfg.usw1.cache.amazonaws.com:11211 St...

Notes Windows 10 Virtualbox config, PHP Storm Japanese, custom PHP, Apache build, Postgresql

 cmd => Ctrl + Shift + Enter mklink "C:\Users\HauNT\Videos\host3" "C:\Windows\System32\drivers\etc\hosts" https://www.quora.com/How-to-create-a-router-in-php https://serverfault.com/questions/225155/virtualbox-how-to-set-up-networking-so-both-host-and-guest-can-access-internet 1 NAT + 1 host only config https://unix.stackexchange.com/questions/115464/how-to-properly-set-up-2-network-interfaces-in-centos-running-in-virtualbox DEVICE=eth0 TYPE=Ethernet #BOOTPROTO=dhcp BOOTPROTO=none #IPADDR=10.9.11.246 #PREFIX=24 #GATEWAY=10.9.11.1 #IPV4_FAILURE_FATAL=yes #HWADDR=08:00:27:CC:AC:AC ONBOOT=yes NAME="System eth0" [root@localhost www]# cat /etc/sysconfig/network-scripts/ifcfg-eth1 # Advanced Micro Devices, Inc. [AMD] 79c970 [PCnet32 LANCE] DEVICE=eth1 IPADDR=192.168.56.28 <= no eff => auto like DHCP #GATEWAY=192.168.56.1 #BOOTPROTO=dhcp BOOTPROTO=static <= no eff ONBOOT=yes HWADDR=08:00:27:b4:20:10 [root@localhost www]# ...

Rocket.Chat DB schema

_raix_push_notifications avatars.chunks avatars.files instances meteor_accounts_loginServiceConfiguration meteor_oauth_pendingCredentials meteor_oauth_pendingRequestTokens migrations rocketchat__trash rocketchat_cron_history rocketchat_custom_emoji rocketchat_custom_sounds rocketchat_import rocketchat_integration_history rocketchat_integrations rocketchat_livechat_custom_field rocketchat_livechat_department rocketchat_livechat_department_agents rocketchat_livechat_external_message rocketchat_livechat_inquiry rocketchat_livechat_office_hour rocketchat_livechat_page_visited rocketchat_livechat_trigger rocketchat_message rocketchat_oauth_apps rocketchat_oembed_cache rocketchat_permissions rocketchat_raw_imports rocketchat_reports rocketchat_roles rocketchat_room rocketchat_settings rocketchat_smarsh_history rocketchat_statistics rocketchat_subscription rocketchat_uploads system.indexes users usersSessions https://rocket.chat/docs/developer-guides/sc...