๐ Curated list of awesome bashrc snippets that will make your work easier.
Working with bash in daily life, it is very irritating writing the same command multiple times. To avoid that we write aliases/snippets for bashrc and make our life easier.
This repository will have collection of such aliases. Read Contribution Guidelines before contributing.
- Contents
- C/C++ compile and run
- git diff for JS Devs
- git status
- Upload your package to PyPi.org
- apt-get update
- open
- List files
- Check free space on disks
- Safe operations with files
- git branch
- git.io alias
- tree alias
- Fast upwards navigation (comes with ZSH)
- Download music from youtube video
- Get saved WiFi keys
- Take Screenshot of connected ADB Device
- Bootstrap your CF Round
- Run Matlab scripts
- Convert GIF to WebM
- License
cpp-run() {
echo "Compiling file..."
g++ -o "$1" "$1.cpp"
echo "Compiled! Enter input :D"
./"$1"
}
# cpp-run filename
c-run() {
echo "Compiling file..."
gcc -o "$1" "$1.c"
echo "Compiled! Enter input :D"
./"$1"
}
# c-run filename
alias gd="git diff --ignore-all-space
--ignore-space-at-eol
--ignore-space-change
--ignore-blank-lines -- .
':(exclude)*package-lock.json'"
# Write gd to ignore not important differences.
# Credits: https://www.reddit.com/r/javascript/comments/9i6hl3/alias_for_open_source_js_devs/
alias s="git status"
This generates the respective dist files and uploads them to PyPi.org by asking your credentials at the end.
alias pyup="python setup.py sdist bdist_wheel && twine upload dist/*"
alias update='sudo apt-get update'
Open any file using its default program (eg. pdfs, torrents, etc).
alias open="xdg-open"
alias ll='ls -laht'
alias l='ls -aC'
alias df='df -h'
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
This will display the current git branch of any repository you're in.
# Add git branch if its present to PS1
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
# Pass the function to the color parser of the terminal to colorize the branch name.
if [ "$color_prompt" = yes ]; then
if [[ ${EUID} == 0 ]] ; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\h\[\033[01;34m\] \W $(parse_git_branch)\$\[\033[00m\] '
else
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\] \[\033[01;34m\]\w $(parse_git_branch)\$\[\033[00m\] '
fi
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h \w \$ '
fi
unset color_prompt force_color_prompt
Get shortened git.io URLs from a single command
gurl() {
curl -i https://git.io -F "url=$1" \
-F "code=$2"
}
# Usage
# gurl https://github.com/anshumanv anshumanv
After these steps, https://git.io/anshumanv will redirect you to https://github.com/anshumanv
Get representation of underlying files and folders as a tree.
alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'"
alias ..='cd ..'
alias ...='cd ../../../'
alias ....='cd ../../../../'
alias .....='cd ../../../../'
You will need mp3-lame library and youtube-dl utility.
alias youtube-mp3="youtube-dl --extract-audio --audio-format mp3"
# Usage
# youtube-mp3 https://youtube.com/{id}
alias wifikey="sudo grep -r '^psk=' /etc/NetworkManager/system-connections/"
# Usage (requires sudo)
# wifikey
alias cap="adb shell screencap -p /sdcard/screen.png && \
adb pull /sdcard/screen.png && \
adb shell rm /sdcard/screen.png"
# Usage (requires connected device)
# Saves the screenshot with name screen.png
# cap
cf() {
mkdir "CF#$1" &&\
cd "CF#$1" &&\
touch inp.txt &&\
touch out.txt && \
curl -L "https://files.aashutosh.dev/cpp.cpp" -o A.cpp
}
# Usage: cf 549
# The above command initialzes, Your CF Round folder and downloads your sample template.
# https://files.aashutosh.dev/cpp.cpp refers to link of your template
matlab-run() {
matlab -nodesktop -nosplash -r "$1"
}
# matlab-run filename
Why? => Read this (You can save upto 90% on size of media)
gif2webm() {
ffmpeg -i $1.gif -c vp9 -b:v 0 -crf 41 $1.webm
}
# gif2webm gif-name-without-format
File Templates taken from awesome-no-login-web-apps