Some useful scripts used by myself on linux server. 简体中文 | English
Current version: 0.0.0
This repository is inspired by a often occurring situation: Every time I change my working directory using cd
, I have to type ls
to check the files in the directory. So I write a script cdl.sh
to combine cd
and ls
together.
After that, I write some other scripts to make my work more efficient. This repository includes the most useful (only for myself XD) scripts I have written. Hope it can help others too :)
This section introduce the environment I use to develop and test these scripts. The scripts should work on other linux distributions, but I can't guarantee that.
Basic information:
- OS: Ubuntu 20.04
- Shell: zsh
- Editor: vim
Other information:
- python: 3.9.7 (with conda 22.9.0)
To use these scripts, clone this repository and add some aliases to your shell configuration file. These commands only work if you have installed git
and zsh
on your machine.
git clone https://github.com/TreemanCHou/linux-my-utils.git
cd linux-my-utils
export current_path=$(pwd)
echo -e 'alias cdl="source $current_path/cdl.sh"\nalias its="sh $current_path/its.sh"\nalias upload="sh $current_path/upload.sh"\nalias download="sh $current_path/download.sh"\nalias lc="sh $current_path/count.sh"\n# alias unzip="uz"\n\n# Some kuaijiefangshi\nalias zshrc="vim ~/.zshrc"\nalias bashrc="vim ~/.bashrc"\nalias condarc="vim ~/.condarc"\nalias vimrc="vim ~/.vimrc"\nalias cls="clear"' >> ~/.zshrc
For those machines which use bash
as the default shell or use zsh
without oh-my-zsh
, this repo provides a install-zsh.sh
script to install zsh
and oh-my-zsh
automatically. You can use the following command to install zsh
and oh-my-zsh
:
sh install-zsh.sh
You can switch your zsh theme manually. But because I mainly use anaconda, most original themes provided by oh-my-zsh
are not compatible with anaconda. In the zsh-themes
directory, I provide some modified themes that are compatible with anaconda.
In the above command, these themes are already switched to the modified themes.
Here is a list of the themes I provide:
aussiegeek
crcandy
juanghurtado
linuxonly
This script is used to combine cd
and ls
together. It will change the working directory and list the files in the directory at the same time.
user@server:/home/user $ cdl <directory>
CURRENT PATH : /home/user/<directory>
total 36
drwxr-xr-x 3 user user 180 Nov 5 21:31 .
drwxr-xr-x 3 user user 180 Nov 5 21:31 ..
Files in current Path: 0
Folders in current Path: 0
user@server:/home/user/<directory> $
This script is used to count the number of files and folders in the current directory. This function is also included in cdl.sh
. For those folders with too many files, it's better to use this script to count the number of files and folders.
user@server:/home/user $ lc
drwxr-xr-x 3 user user 180 Nov 5 21:31 .
drwxr-xr-x 3 user user 180 Nov 5 21:31 ..
drwxr-xr-x 3 user user 180 Nov 5 21:31 test.txt
drwxr-xr-x 3 user user 180 Nov 5 21:31 test2.txt
drwxr-xr-x 3 user user 180 Nov 5 21:31 test3.txt
Files in current Path: 3
Folders in current Path: 2
This script only repeats your feeling.
user@server:/home/user $ its cool!
Yep, it's cool!
To make you modify the configuration files more easily, I also provide some aliases to open the configuration files using vim
.
user@server:/home/user $ zshrc
user@server:/home/user $ bashrc
user@server:/home/user $ condarc
Those aliases are used to open the configuration files of zsh
, bash
, and conda
.
For those who want to clear the terminal, but still used to type cls
in windows, I also provide an alias cls
to clear the terminal. XD
user@server:/home/user $ cls
If you have any questions or suggestions, please feel free to contact me or put an issue in this repository. I will reply as soon as possible.
mailbox: [email protected]