Personal wiki for common problems.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

139 lines
2.6 KiB

# mkr.sh
## A list of commands to simplify my life
## Read carefully, use at your own risk
## Add 'source path/to/mkr.sh' in your ~/.bashrc or ~/.zshrc
# Actually clear your terminal
alias cls='printf "\033c"'
# Copy to clipboard
## clip
## Usage: cat <file> | clip
## Copies output from previous command into clipboard
alias clip="xclip -selection clipboard"
7 years ago
# Simpler apt commands
alias update="sudo apt-get update"
alias i="sudo apt-get install -y"
alias purge="sudo apt purge -y"
alias autoremove="sudo apt autoremove -y"
7 years ago
## To install without -y
alias install="sudo apt-get install"
# Directory management
## mk
## Usage: mk <dir>
7 years ago
## Makes a new directory and enters it
mkd () {
mkdir -p "$1"
7 years ago
cd "$_"
}
## rmd
## Usage: rmd [dir]
7 years ago
## Use with caution: Removes current working directory and changes to one up level
## If an argument is passed, simply deletes that file or folder from current working directory
rmd () {
CWD="$(dirname $(realpath $0))"
if [ "$1" ]; then
rm -rf "$1"
else
cd ..
rm -rf "$CWD"
fi
}
# Git commands
## git graph
## Usage: git graph
git config --global alias.graph 'log --graph --date-order --pretty=format:"%C(bold yellow)%h%C(auto)%d %C(cyan)%an%C(bold white) %s %C(auto)%C(green)(%ar)%C(reset)"'
## lower-level `dot-git-cmd`, to be used for `dotgit` command
alias dot-git-cmd="git --git-dir=$HOME/.dotfiles --work-tree=$HOME"
# Manage dotfiles repo
# Usage: dotgit [commands...]
dotgit () {
if [[ "$1" == "-d" || "$1" == "--diff" ]]; then
dot-git-cmd diff
elif [[ "$1" == "-u" || "$1" == "--update" ]]; then
dot-git-cmd add $HOME
dot-git-cmd commit -m "$(date)"
elif [[ "$1" == "-p" || "$1" == "--push" ]]; then
dot-git-cmd add "$HOME"
dot-git-cmd commit -m date
dot-git-cmd push
else
dot-git-cmd "$1"
fi
}
## pull
## Usage: pull [remote branch]
pull () {
if [ "$1" ]; then
git pull "$1" "$2"
else
git pull
fi
}
## commit
## Usage: commit <commit-message>
commit () {
git add .
git commit -m "$1"
}
## push
## Usage: push <commit-message> [remote branch]
7 years ago
## if only commit message is present, pushes to default upstream
push () {
git add .
git commit -m "$1"
if [ "$2" ]; then
git push -u "$2" "$3"
else
git push
fi
}
# Systemctl commands
## status
## Usage: status <daemon>
7 years ago
status () {
sudo systemctl status "$1"
}
## start
## Usage: start <daemon>
7 years ago
start () {
sudo systemctl start "$1"
}
## stop
## Usage: stop <daemon>
7 years ago
stop () {
sudo systemctl stop "$1"
}
7 years ago
# MISC
## mkr-update
## Usage: mkr-update
mkr-update () {
curl -s https://raw.githubusercontent.com/MKRhere/wiki/master/scripts/mkr.sh -o ~/.mkr/mkr.sh
source ~/.mkr/mkr.sh
echo "[mkr.sh] Done updating script! Enjoy."
}