Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Avoiding Shell Hell: Aliases to the rescue

Avoiding Shell Hell: Aliases to the rescue

Aliases are a hack to developer productivity. Developers spend a couple of time typing long commands from Git to Docker and Kubernetes when these could be aliased saving us the time to achieve more. In this talk, I will expand on the tips and tricks developers can apply to achieve more in less time. Presented at forLoop Lagos Summit

Chiamaka Ikeanyi

March 08, 2019
Tweet

More Decks by Chiamaka Ikeanyi

Other Decks in Technology

Transcript

  1. Avoiding Shell Hell:
    Aliases to the rescue
    Lagos Summit 2019 | Chiamaka Ikeanyi
    March 8, 2019 @ Zone Tech Park, Gbagada

    View Slide

  2. Chiamaka Ikeanyi
    chiamakaikeanyi.dev @chiamakaikeanyi
    Poet & Writer
    Software Engineer at

    View Slide

  3. @chiamakaikeanyi

    View Slide

  4. @chiamakaikeanyi

    View Slide

  5. gc?
    @chiamakaikeanyi

    View Slide

  6. An alias to git commit
    @chiamakaikeanyi

    View Slide

  7. Say hello to Aliases
    @chiamakaikeanyi

    View Slide

  8. What is an alias?
    @chiamakaikeanyi

    View Slide

  9. An alias is an alternate name for a
    command.
    Just a shortcut.
    @chiamakaikeanyi

    View Slide

  10. Why are aliases important?
    @chiamakaikeanyi
    ● Spend less time typing
    ● Reduce the chances of typos in a long command
    ● The secret to speeding up your terminal workflow

    View Slide

  11. docker ps | grep forloop
    Is this cool?
    @chiamakaikeanyi

    View Slide

  12. dgp forloop
    What of this?
    @chiamakaikeanyi

    View Slide

  13. @chiamakaikeanyi
    Consider this Scenario
    Client 1
    Website
    You
    $ kubectl get pods | grep $podName
    $ kubectl logs $podName
    $ kubectl exec -it $podName bash
    Client 2

    View Slide

  14. @chiamakaikeanyi

    View Slide

  15. Aliases instruct the shell to replace
    one string with another when
    executing commands.
    @chiamakaikeanyi

    View Slide

  16. ● Git
    ● Docker
    ● Kubernetes
    ● . . .
    Popular usage
    @chiamakaikeanyi

    View Slide

  17. isLong && repetitive ? alias : null
    Alias every command?
    @chiamakaikeanyi
    No, Not really

    View Slide

  18. Who needs to use aliases?
    @chiamakaikeanyi

    View Slide

  19. Lazy software engineers
    @chiamakaikeanyi

    View Slide

  20. gac "Fix filters"
    gpo patch/filters
    git add .
    git commit -m "Fix filters"
    git push origin patch/filters
    Works Smart
    Works Hard

    View Slide

  21. How can you add aliases?
    @chiamakaikeanyi

    View Slide

  22. Syntax
    alias name=command
    @chiamakaikeanyi

    View Slide

  23. Syntax
    alias name="command with space"
    @chiamakaikeanyi

    View Slide

  24. Store in the home directory
    @chiamakaikeanyi

    View Slide

  25. Bourne-again shell (Bash): ~/.bashrc
    or ~/.bash_profile
    Z Shell (ZSH): ~/.zshrc
    Default Files
    @chiamakaikeanyi

    View Slide

  26. echo $SHELL
    cd ~
    ls -la
    touch ~/.bash_profile
    Not Found?
    @chiamakaikeanyi

    View Slide

  27. alias workspace=
    "git config user.name 'your_name'
    && git config user.email
    'your_email'"
    @chiamakaikeanyi

    View Slide

  28. alias blog="open
    https://chiamakaikeanyi.dev"
    @chiamakaikeanyi

    View Slide

  29. alias nis='f(){ npm install
    --save "[email protected]" }; f'
    @chiamakaikeanyi

    View Slide

  30. source ~/.zshrc
    or
    . ~/.zshrc
    Reload
    @chiamakaikeanyi

    View Slide

  31. nano ~/.zshrc
    open ~/.zshrc
    code ~/.zshrc
    alias
    @chiamakaikeanyi
    Accessing your Aliases
    NB: Substitute .zshrc with the shell you’re using - .bashrc or .bash_profile ...

    View Slide

  32. BASH
    @chiamakaikeanyi

    View Slide

  33. At the end…
    What matters is becoming more
    productive
    @chiamakaikeanyi

    View Slide

  34. Demo
    Let’s see an example
    @chiamakaikeanyi

    View Slide

  35. https://github.com/chiamakaikeanyi/dotfiles
    Resource
    @chiamakaikeanyi

    View Slide

  36. Tomorrow is mystery
    But you can save time
    By using Aliases
    - Chiamaka Ikeanyi
    @chiamakaikeanyi
    Yesterday is history

    View Slide

  37. Thank you
    chiamakaikeanyi.dev @chiamakaikeanyi

    View Slide