Step Up Your Terminal Game – DZone

In the area of ​​productivity, every efficiency gain counts. For many, the terminal serves as a central hub for navigating the digital landscape. Whether you’re an experienced developer, system administrator, or just someone who spends a lot of time working at the command line, customizing your terminal can transform it from a basic tool into a personalized drive. In this guide, we’ll explore the different ways you can hack your terminal to improve your workflow, increase productivity, and create a workspace tailored to your needs. Most things will revolve around modifying your bashrc/zshrc configuration.

Enhance your look with Power level 10k

The aesthetic appeal of your terminal plays a significant role in your overall experience. Powerlevel10k is one of the best themes to install in your zsh terminal. It transforms your terminal from a basic interface into an elegant, informative and visually appealing display, providing a significant upgrade in aesthetics and functionality.

zsh terminal

Extensions and Add-ons: Fill your shell

Two indispensable Zsh shell plugins are zsh-autosuggestions and zsh-syntax-highlighting. These tools greatly improve the functionality and user experience of the Zsh shell.

  • Zsh-autosuggestions: Intelligently suggests command completion as you type, based on your command history. This feature not only saves time, but also helps prevent tipfellers and mistakes by offering contextually relevant suggestions.
  • Zsh-syntax highlighting: Provides visual feedback on the validity of your commands by highlighting syntax errors, invalid options, and other potential problems in real time. By detecting errors early, it simplifies the command line experience, reducing the likelihood of errors and increasing overall productivity.

Command Line Tools and Utilities: Your Performance Boosters

Learn command-line text processing tools like sed and jq to significantly reduce your time. jq, for example, is a powerful tool for parsing and manipulating JSON data effortlessly. Its concise syntax simplifies tasks such as extracting fields, filtering data, and formatting output. Widely adopted by developers, system administrators, and data engineers, jq streamlines JSON processing, increasing productivity in scripts, pipelines, and automated workflows.

Aliases and Functions: Your Time-Saving Techniques

Aliases and functions are indispensable tools for saving time and keystrokes in the terminal. Using frameworks like oh my zsh, you can easily have aliases for frequently used commands or sequences, making your life easier. Functions allow you to combine multiple commands into a single, easy-to-execute line, further simplifying your workflow.

Shell scripts: automate your tasks

Shell scripts are invaluable tools for simplifying and automating tasks, significantly increasing the efficiency and convenience of using the terminal. By writing shell scripts, users can automate repetitive tasks such as file manipulation, data processing, and system maintenance, saving time and effort in the long run.

Example: a day in the life of a developer

Being a software developer, I will go through my day-to-day activities with my terminal and how I do it differently with the help of all these points I mentioned. From creating branches and pushing code to running upgrades on Jenkins and deploying images to clusters, every step is optimized for efficiency and convenience.

Customizing Git workflow with aliases and functions

One of my personal favorites is using aliases and functions to simplify the Git workflow. For example, instead of typing long commands like git push origin branchnameI created an alias ggp using oh my zsh, which allows me to accomplish the same task with just ggp.

function gitpush() 
    gaa
    gcmsg "$*"
    ggp

# function call
# gitpush Add a meaningfull commit message here

Additionally, I created a function called gitpush which uses oh-my-zsh aliases and combines adding, listing and pushing changes in one line, saving valuable time and keystrokes.

Automating Jenkins builds with custom functions

In order to run Jenkins upgrades with ease, I created a custom function called jenkins-build().

function jenkins-build()
  curl -X POST https://your_jenkins_server.com/job/your_job/build --user username:apikey \
  --data-urlencode json='"parameter": ["name":"BRANCH_NAME", "value":"'"$1"'"]'

This function uses the Jenkins API to trigger the build by passing the branch name as a parameter. Now starting a build is as easy as typing jenkins-build my_branch_nameeliminating the need for manual intervention and speeding up the development process.

Deploying images to clusters with shell scripts and aliases

Deploying images to clusters involves several steps, including logging in, retrieving relevant data, and updating configurations. To simplify this process, I created a shell script that efficiently performs these tasks. I have created aliases to login to different openshift clusters as I am working with more than 3 clusters.

alias oc-dev='oc login dev-server.com -u username -p password -n namespace'
alias oc-stage="oc login stage-server.com -u username -p password -n namespace"

I also wrote a shell script that edits the deployment file to change the image installed on the cluster, which when run would replace the service image tag with the one specified.

ocimage() image: artifactory_url:$imageTag

By using pseudonyms like oc-dev for application and ocimg for deploying images, I can perform complex tasks with minimal effort, allowing me to focus on developing and testing my code.

We can’t wait to discover the inventive ideas and clever shortcuts you’ve integrated into your workflow! Share your insights in the comments below to inspire and empower others in our community. Whether it’s a time-saving script, a nifty alias, or a nifty set of commands, your contributions can unlock new features and make terminal use simpler for everyone. Let’s cooperate and release the full potential of our joint expertise!

Source link

Leave a Reply

Your email address will not be published. Required fields are marked *