Find Part 1 here.

Tech Part

Simple alias

Now I will tell you about one of my favorite things about cmder "ALIASES" 🤩🤩.

As a developer I type lot of command lines but there are certain commands that we type more than others : (example for (git : git status, git commit -m "message") or (angular : ng g c myComponent) or (laravel : php artisan make:migration myMigration) or ….. etc).

so to create an alias you just have to type

alias ‘the alias you like’=’the command you hate to write every time’

example here : replacing git status with gs : alias gs=git status

Create cmder alias

Alias with parameters

Q: But wait what if I want to have parameters in my commands

A: I didn’t create cmder 🤣 … just kidding, of course you can add parameters, here is an example of replacing git add file/directory alias ga=git add $*

the $* means what ever comes after your alias (your parameter)

Create cmder alias with parameter

Q: What if I want to have a parameter in the middle of my command

A: Again, I didn’t … 🤣🤣, of course you can

Here is how you can do and use it (example : creating laravel controller) : alias pamkc=php artisan make:controller $*Controller

pamkc => initials of "php artisan make:controller", to use this alias type : pamkc Post, this will create a PostController.php file

Example of a cmder alias with one parameter

Q: What if I want to have more than one parameter in my command

You can do something like (example : serve a laravel app on different host and port) : alias pashp=php artisan serve --host $1 --port $2

to use this alias type : pashp 0.0.0.0 8888

Be careful about the order of your parameters ($1 = 0.0.0.0 and $2 = 8888) 😬

Example of a cmder alias with two parameters

Before you ask ✋ any other question, here is how you can use the same parameter in more than one place (example : creating a laravel factory for a specific model) : alias pamkf = php artisan make:factory $1Factory --model=$1 and to use it type : pamkf Post

The result will be : php artisan make:factory PostFactory --model=Post

Example of a cmder alias with one parameter used in multiple places

One alias, multiple commands

Now let’s see how to chain more than one command in one alias.

Example: Sometimes you want to switch to another partition, so you are in C:, and you want to switch to E:\MyDirectory, you type ‘cd E:\MyDirectory’ but you see nothing until you type ‘E:’, then your switch is done and you’re now in ‘E:\MyDirectory’, this brings me to another thing I like which is creating aliases for directories.

Example : alias desktop=cd C:\Users\UserName\Desktop\ $t C:

which will take me to my desktop then ($t) execute second command ‘C:’ to force it into the ‘C:’ partition (just in case I’m in a different partition)

You can also make alias for files / programs

Example : alias npp="C:\Program Files\Notepad++\notepad++.exe" $*

Here I’m running notepad++ editor with parameter $* which is the file i want to open.

Final Thoughts

Personally I’m currently satisfied with cmder, but I can’t say if it’s the best, may be other tools exists out there way better than cmder, but the idea is about "Always look for ways to get things done better, faster, cleaner".

Thanks for reading

Before you close this window I would like to share my list of aliases I use :

Explorer

e.=explorer .
exp=explorer $*

Git

ga.=git add .
ga=git add $*
gaa=git add .
gs=git status $*
gb=git branch $*
gc=git commit
gck=git checkout $*
gcl=git clone $*
gcm=git commit -m "$*"
gd=git diff $*
gi=git init
gl=git log
gm=git merge
gpl=git pull $*
gplbit=git pull bitbucket master $*
gplgit=git pull github master
gplo=git pull origin $*
gplom=git pull origin master $*
gps=git push $*
gpsbit=git push bitbucket master
gpsgit=git push github master
gpso=git push origin $*
gpsom=git push origin master $*
gr=git reset $*
grfl=git reflog $*
grh=git reset — hard $*
grhh=git reset — hard HEAD
grs=git reset — soft $*
grm=git rm $*
grv=git remote -v

NPM

ni=npm install $*
nu=npm update
nrb=npm run build
nrd=npm run dev
nrs=npm run serve
nrw=npm run watch

Composer

ci=composer install
cu=composer update
cmpref=composer dump-autoload

Angular

nggc=ng generate component — skipTests $*
nggcs=ng generate component $*
nggd=ng generate directive — spec=false $*
nggds=ng generate directive $*
nggs=ng generate service — spec=false $*
ngs=ng serve
ngsa=ng serve — aot

Laravel

pa=php artisan $*
padbs=php artisan db:seed $*
pakg=php artisan key:generate
pam=php artisan migrate
pamf=php artisan migrate:fresh
pamfs=php artisan migrate:fresh — seed
pamk=php artisan make:$*
pamkall=php artisan make:model $1 -m -c -f $t php artisan make:seeder $1sTableSeeder
pamkc=php artisan make:controller $*Controller
pamkcmp=php artisan make:component $*
pamkcr=php artisan make:controller $*Controller -r
pamkf=php artisan make:factory $1Factory — model=$1
pamkfm=php artisan make:factory $1Factory — model=$2
pamkmdl=php artisan make:model $*
pamkmg=php artisan make:migration create_$*_table
pamkmm=php artisan make:model $1 -m
pamkmmc=php artisan make:model $1 -m -c
pamkmmcr=php artisan make:model $1 -m -c -r
pamkr=php artisan make:resource $*Resource
pamkrc=php artisan make:resource $*Collection
pamks=php artisan make:seeder $1sTableSeeder
pams=php artisan migrate — seed
parl=php artisan route:list
pas=php artisan serve
pash=php artisan serve — host $*
pashp=php artisan serve — host $1 — port $2
pasp=php artisan serve — port $*
pasph=php artisan serve — port $1 — host $2
pat=php artisan tinker
pav=php artisan — version
rfl=composer dumpautoload $t php artisan optimize $t php artisan cache:clear $t php artisan view:clear

Docker

dc=docker-compose $*
dcx=docker-compose exec $*
dk=docker $*
dkim=docker image $*
dkimls=docker image ls $*
dkims=docker images $*
dkimsa=docker images -a $*
dkll=docker kill $*
dksp=docker system prune $*
dkspa=docker system prune -a $*
dps=docker ps $*
dpsa=docker ps -a $*
rmcn=docker container rm $*
rmim=docker image rm $*