xy2z
10/28/2019 - 1:21 PM

.bash_aliases

alias xy_alias_version='echo xy_alias version 1.2'
alias xy_alias_url='echo https://gist.github.com/xy2z/0dad738b1519aed3f67613a6e9e2917a'
alias xy_alias_update_linux='wget -O ~/.bash_aliases https://gist.githubusercontent.com/xy2z/0dad738b1519aed3f67613a6e9e2917a/raw && source ~/.bash_aliases'

alias ll='ls -alh --show-control-chars -F --color $*'
alias gl='git log --oneline --all --graph --decorate  $*'
alias gs='git status'
alias dc='sudo docker-compose'
alias ddrush='sudo docker-compose exec web vendor/bin/drush'
alias grep='grep --color=auto $*'
alias c='clear' 
alias cls='clear'
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias watch='watch -d -n 0.5'

Setup

Linux

WARNING: This will overwrite your current ~/.bash_aliases file (if it exists). To see if it exists run cat ~/.bash_aliases

wget -O ~/.bash_aliases https://gist.githubusercontent.com/xy2z/0dad738b1519aed3f67613a6e9e2917a/raw && source ~/.bash_aliases

Windows (Cmder)

This will NOT overwrite your current aliases, cmder will overwrite the existing and add the new, and not delete your own aliases.

Requirements: PHP

php -r "echo str_replace(['alias ', '\''], '', file_get_contents('https://gist.githubusercontent.com/xy2z/0dad738b1519aed3f67613a6e9e2917a/raw'));" >> %CMDER_ROOT%\config\user_aliases.cmd

Restart cmder.exe.

Why?

Having multiple devices (home pc, home laptop, work pc, etc.) and servers it can be a difficult job to set all your own aliases, this is a way to fix that with one command that should be run on every device.

Help

  • To see a list of all aliases run alias
  • To see the current version, run xy_alias_version
  • To update just run the command again

Problems

Sometimes when running the install/update command, it will return a cached version if it's run multiple times. Wait ~5 minutes and try again. I've tried with wget --no-cache but it didnt help, however it did work after a couple minutes.

Todo

  • Is it possible to make a xy_alias_update alias that will run the script again? That will need some logic to know if the OS is linux or windows, so probably not since that would be a "function", and not sure that works in windows. So maybe a xy_alias_update_linux and xy_alias_update_windows command.
  • Remove 'sudo' from windows?

Tips

  • To automatically update aliases on every ssh login, add xy_alias_update_linux to the end of your ~/.bashrc file. This will slow your login down a tiny bit, but then it will always be up to date.