![]() To see it at work, open the todo.py file with your preferred text editor, and make some changes to it. bat -show-all flask-restful/examples/todo.pyīat also integrates with Git. But bat has the added advantage of using special characters and highlighting to represent non-printing characters more clearly. Like cat, bat gives the option to show non-printing characters, making it easier to track spaces, tabs, line breaks, etc. bat -paging=never flask-restful/examples/todo.py However, you can also have bat print to the command line, just like in cat with the -paging=never flag. bat flask-restful/examples/todo.pyīy default, bat uses less to paginate its results. Now, you can open up one of the Python files in this repository using bat. Replace apt with dnf if you are on Fedora, and yum if you are on AlmaLinux or CentOS. ![]() You can get the code by installing Git (if you do not already have it) and cloning the repository. To really show off the capabilities of bat, this guide uses some example code provided in the Flask-RESTful GitHub project. You issue the bat command, followed by the path to a file you want to view. Getting started with bat is similar to the basic usage of the cat command. Once you have installed bat, by whatever method, you can verify the installation using the version command. You can create the alias by adding the following line to the end of the file. Likely, the file is located in your user’s home directory, as in: ~/.bashrc. sudo mv bat-v0.18.2-x86_64-unknown-linux-musl /usr/local/batĪdd an alias for bat to your. The URL is needed in the next step.Ĭopy the package’s URL, and use the following command to download the package as bat.zip. tar.gz package with your system’s CPU architecture, followed by unknown-linux-musl in the name. Identify the latest version of bat from the release page. In this example - and in the commands that follow - the CPU architecture is x86_64. Here is an example of what your output might look like. sudo yum install tarĬheck the CPU architecture of your Linux system using the following command: uname -a If you do not already have it, install tar, which you use to extract the bat package in a later step. For those distributions, follow the steps below to download the appropriate bat release and install it. Otherwise, if you choose to keep bacula-console-qt installed, you must stick with using the batcat command instead of bat.įor AlmaLinux and CentOS, a few more steps are required. If you have installed the bacula-console-qt package, be sure to remove it before executing the commands listed above. ![]() You can, however, use the following commands to link the bat command: mkdir -p ~/.local/bin On Debian and Ubuntu, bat uses the batcat command by default because of a conflict with an existing package, bacula-console-qt. This is the case for Debian, Ubuntu, and Fedora distributions.įor Debian and Ubuntu, install bat using the following command: sudo apt install bat How to Install batįor many Linux distributions, you can get bat from the package manager. You can even use bat to view past versions of files under version control. By default, bat provides annotations to indicate modified lines for files tracked by Git. This, combined with other display enhancements - easier-to-follow formatting, pagination, graphical non-printing characters - makes bat exceptional for reading files that contain code.īat also comes ready to integrate with several other command-line tools, chief among them is Git. But bat comes with a more modern display and several added features that set it apart.įor one, bat adds syntax highlighting. Like cat, bat also gives you a simple command-line method for displaying file contents. It is included in most distributions by default and gets referenced frequently as a quick way of viewing the contents of a file contents while on the command line. You may be familiar with the Linux cat command. If you’re not familiar with the sudo command, see the Linux Users and Groups guide. Commands that require elevated privileges are prefixed with sudo. The steps in this guide are written for a non-root user.
0 Comments
Leave a Reply. |