Five super amazing shell aliases to use on Linux
If you are not taking full advantage of Shell abbreviations, you are wasting valuable time. Typing the same thing over and over again is boring, monotonous, and inefficient. Why spend time memorizing lengthy commands when you can simplify them?
Abbreviations are a way of giving a name to a command, a sequence of commands, or a short piece of text. Rewrite this sentence as: You can achieve more efficient operations by chaining multiple commands together, or passing a long list of arguments to a commonly used command and giving it a shorter alias. This is useful if you want to give the same thing you type frequently a more memorable name.
Use abbreviations to reduce the time it takes to run commonly used commands. You can build the correct parameters into the abbreviations so they are never forgotten. If set up correctly, you can achieve some truly magical things with abbreviations.
In this article, I want to tell you some abbreviations that I use every day as an engineer. These abbreviations are an absolute life saver. They have become muscle memory and I honestly can't live without them.
1. Git status
alias gg='git status'
Simple, yes. Efficient? You can't imagine. You might be surprised to learn how many times git status is called per day. This is a very common command in Git repositories. This command shows which files are ready for commit, which branch you are currently on, and a lot of other useful information.
Typing git status might not seem too crazy, but see how long it takes? Look at the way your fingers dance across the keyboard. There's a space, and the characters themselves are spaced out in a specific pattern that's prone to error. Once you mess up, you need to start over. So much time wasted. Just abbreviate it.
Typing gg is much faster, if you make a typo then maybe consider a typing course...
2. Run Pylint
alias pll='pylint -f colorized'
Whatever you Love it or hate it, code inspectors are essential. Like it or not, no engineer is perfect. We all make mistakes at some point. You need to perform inspections on your code, so making it simple and easy is crucial.
Since I write a lot of Python code, I rely heavily on Pylint for code inspection. Sometimes I use custom parameters so I can run Pylint with colored output. It's not fun typing this stuff over and over again. Set it to a short abbreviation and it's now even more interesting.
You can specify different format types, ignore files, inspectors and .rc files to pass. Basically, anything you can pass to a normal command can be put in an abbreviation. This is where it's powerful, because you can customize the code inspector yourself without having to remember or re-enter all the options to suit your preferences.
3. Log in to ECR
alias ecr_login='aws ecr get-login-password --region <REGION> | docker login --username AWS --password-stdin <ECR_URI>'
This unique command is more practical than bread for people who often use Docker images and ECR. Logging into ECR is very tedious. To log in to Docker, you need to chain these commands together and use specific credentials. It's a real pain if you don't remember that command. Then you have to look it up, which wastes a lot of time.
Just set the login command to a concise and clear alias. If you work in multiple ECR regions, you can even alias based on region. Set up a login alias for the East Coast, the West Coast and even beyond. The world is your oyster, now you can log in quickly and easily.
Don't forget to add your own zone and ECR URI in the above command to make it work properly.
4. Running Ansible
alias apb='cd <repo> && ansible-playbook -i <inventory_file>
For me, running Ansible playbooks is a daily routine. I run multiple plays every day, often repeatedly. Especially when I'm creating new roles or dealing with conditional logic in Ansible. Who doesn't love YAML as code?
It's very important to be able to run Ansible with the basic flags I need. Reentering a long list of parameters takes a long time. Although you can reuse a previously executed command by pressing the up arrow, this method is not always the most convenient. If you switch to editing the file, you now have to press the up arrow twice. This can easily be overlooked during development and then you have to type it all over again.
Just give it an alias.
如果你正在使用ansible.cfg文件,这也能给你机会确认。在上面的命令别名中,我们进入了我们的仓库并在该上下文中运行。这是因为我们的Ansible配置位于那里。一旦你进入那个目录,它会自动使用该配置。
如果有其他的清单文件,你也可以传入它们。如果你有一些跨多个环境的全局清单,这将非常有帮助。
5、缩短常用命令
alias tf='terraform'alias k='kubectl'
这是我最近开始实施的最后一个建议。我起初不认为这是必要的,但是一旦你开始使用缩写的命令代替长命令,就会有很大的区别。我每天都经常使用terraform和kubectl。
这些命令是另一个例子,它们的名称很烦人。它们容易出错,而将它们设为别名非常简单。现在就缩短它们,这样你就能避免拼写错误,提高方便。
我还鼓励你查看其他你经常输入的单词命令。可能有一些你一遍又一遍地输入的命令可以从缩短中受益。
现在,去给命令设置别名吧!
The above is the detailed content of Five super amazing shell aliases to use on Linux. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



How to use Docker Desktop? Docker Desktop is a tool for running Docker containers on local machines. The steps to use include: 1. Install Docker Desktop; 2. Start Docker Desktop; 3. Create Docker image (using Dockerfile); 4. Build Docker image (using docker build); 5. Run Docker container (using docker run).

The key differences between CentOS and Ubuntu are: origin (CentOS originates from Red Hat, for enterprises; Ubuntu originates from Debian, for individuals), package management (CentOS uses yum, focusing on stability; Ubuntu uses apt, for high update frequency), support cycle (CentOS provides 10 years of support, Ubuntu provides 5 years of LTS support), community support (CentOS focuses on stability, Ubuntu provides a wide range of tutorials and documents), uses (CentOS is biased towards servers, Ubuntu is suitable for servers and desktops), other differences include installation simplicity (CentOS is thin)

Troubleshooting steps for failed Docker image build: Check Dockerfile syntax and dependency version. Check if the build context contains the required source code and dependencies. View the build log for error details. Use the --target option to build a hierarchical phase to identify failure points. Make sure to use the latest version of Docker engine. Build the image with --t [image-name]:debug mode to debug the problem. Check disk space and make sure it is sufficient. Disable SELinux to prevent interference with the build process. Ask community platforms for help, provide Dockerfiles and build log descriptions for more specific suggestions.

Docker process viewing method: 1. Docker CLI command: docker ps; 2. Systemd CLI command: systemctl status docker; 3. Docker Compose CLI command: docker-compose ps; 4. Process Explorer (Windows); 5. /proc directory (Linux).

VS Code system requirements: Operating system: Windows 10 and above, macOS 10.12 and above, Linux distribution processor: minimum 1.6 GHz, recommended 2.0 GHz and above memory: minimum 512 MB, recommended 4 GB and above storage space: minimum 250 MB, recommended 1 GB and above other requirements: stable network connection, Xorg/Wayland (Linux)

Docker uses Linux kernel features to provide an efficient and isolated application running environment. Its working principle is as follows: 1. The mirror is used as a read-only template, which contains everything you need to run the application; 2. The Union File System (UnionFS) stacks multiple file systems, only storing the differences, saving space and speeding up; 3. The daemon manages the mirrors and containers, and the client uses them for interaction; 4. Namespaces and cgroups implement container isolation and resource limitations; 5. Multiple network modes support container interconnection. Only by understanding these core concepts can you better utilize Docker.

VS Code is the full name Visual Studio Code, which is a free and open source cross-platform code editor and development environment developed by Microsoft. It supports a wide range of programming languages and provides syntax highlighting, code automatic completion, code snippets and smart prompts to improve development efficiency. Through a rich extension ecosystem, users can add extensions to specific needs and languages, such as debuggers, code formatting tools, and Git integrations. VS Code also includes an intuitive debugger that helps quickly find and resolve bugs in your code.

The reasons for the installation of VS Code extensions may be: network instability, insufficient permissions, system compatibility issues, VS Code version is too old, antivirus software or firewall interference. By checking network connections, permissions, log files, updating VS Code, disabling security software, and restarting VS Code or computers, you can gradually troubleshoot and resolve issues.
