Add custom commands to your bash terminal. Eg: running gs instead of git status.
The .bashrc file is a config file for your bash terminal, you can edit it to add stuff.
Windows: Open bash.bashrc found in C:\Program Files\Git\etc. For Linux, cd ~ to go to home dir and then nano .bashrc to edit the bashrc file.
Add this snippet to the end:
#User defined text startsecho'Ahh shit, here we go again.'#Your own welcome message#Typing "rp" command runs thisfunction rp(){#Switch to your repos foldercd'D:\Repos'}#short command aliasesfunction gs(){
git status
}#Create a dir and cd into it automaticallyfunction xmkdir (){
mkdir -p -- "$1"&&cd -P -- "$1"}#cd into a folder and immediately list all files insidefunction xcd (){cd"$@"&& ls
}#Automatically add all changes, commit and then push. Check your changes properly before using this.#Command format: acp "your commit message"function acp(){if[ -z "$1"];thenprintf"%s\n""Please provide a commit message.";else#Git add takes some time. If commit is run immediately after add, it fails. #So sleep for 3 secs by default to give add time to complete.#If there's a locked file you might have to run the same command a couple of times, just up arrow and enter
git add -A & sleep 3& git commit -m "$1"& git push
echo"$1"fi}
Download a file
1
wget <url>
List files
1
2
ls -1 #List files, 1 per line
ls -1 | wc -1 #List files and count lines (wc = word count)
View contents
1
2
3
4
5
cat <file_path> #Shows complete contents
nl <file_path> #Shows contents with line numbers
less <file_path> #Shows contents a page at a time
head <file_path> #Shows first 10 lines
tail <file_path> #Shows last 10 lines
Make a file executable
1
chmod +x <file_path>
Move files
1
mv <src_path> <destination_path> #Can be used to rename files too
cat file.txt | cut -c 10#Show first 10 characters of each line
cat file.txt | cut -d ',' -f 2#Split by delimiter ',' and show the 2nd field in each line
cat file.txt | cut -d ',' -f 1-2 #Split by delimiter ',' and show fields 1 and 2 in each line
Search
1
2
3
4
cat file.txt | grep "keywordRegex"
cat file.txt | grep -i "keywordRegex"#Case insensitive
cat file.txt | grep "keywordRegex" -A 2#For each match, show next 2 lines too
grep -HRi "data" * #Search through all files (H) recursively (R)