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 full-size slide

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

    View full-size slide

  3. @chiamakaikeanyi

    View full-size slide

  4. @chiamakaikeanyi

    View full-size slide

  5. gc?
    @chiamakaikeanyi

    View full-size slide

  6. An alias to git commit
    @chiamakaikeanyi

    View full-size slide

  7. Say hello to Aliases
    @chiamakaikeanyi

    View full-size slide

  8. What is an alias?
    @chiamakaikeanyi

    View full-size slide

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

    View full-size 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 full-size slide

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

    View full-size slide

  12. dgp forloop
    What of this?
    @chiamakaikeanyi

    View full-size 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 full-size slide

  14. @chiamakaikeanyi

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  18. Who needs to use aliases?
    @chiamakaikeanyi

    View full-size slide

  19. Lazy software engineers
    @chiamakaikeanyi

    View full-size 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 full-size slide

  21. How can you add aliases?
    @chiamakaikeanyi

    View full-size slide

  22. Syntax
    alias name=command
    @chiamakaikeanyi

    View full-size slide

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

    View full-size slide

  24. Store in the home directory
    @chiamakaikeanyi

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  29. alias nis='f(){ npm install
    --save "$@" }; f'
    @chiamakaikeanyi

    View full-size slide

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

    View full-size 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 full-size slide

  32. BASH
    @chiamakaikeanyi

    View full-size slide

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

    View full-size slide

  34. Demo
    Let’s see an example
    @chiamakaikeanyi

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  37. Thank you
    chiamakaikeanyi.dev @chiamakaikeanyi

    View full-size slide