Browse Source

feat: updates to mkr.sh

master
Muthu Kumar 2 years ago
parent
commit
3a383801ae
Failed to extract signature
  1. 13
      scripts/README.md
  2. 65
      scripts/mkr.sh

13
scripts/README.md

@ -26,22 +26,9 @@ mkr-update
- General
- `cls` : Clears screen
- `clip` : Copies to clipboard
- apt
- `i <package-names...>` : Accepts prompts and installs packages
- `install <package-names...>` : Installs packages without auto-accepting
- `update` : Equivalent to `apt-get update`
- `purge <package-names...>` : Removes packages
- `ar` / `autoremove` : Equivalent to `apt autoremove`
- Directories
- `mkd </path/to/dir>` : Creates dir at given path and changes cwd to it
- `rmd [dir]` : Removes current directory and moves up OR removes directory by given name
- git
- `git graph` : Opens a pretty commit log graph
- `commit <commit-message>` : Adds all untracked files and commits them
- `push <commit-message> [remote branch]` : Adds all untracked files, commits and pushes them
- `dotgit [commands...]` : Requires a `~/.dotfiles` bare repo to exist
- `-u` to commit to the dotgit repo
- `-p` to push the dotgit repo to remote
- systemctl
- `status <daemon>`
- `start <daemon>`

65
scripts/mkr.sh

@ -4,6 +4,9 @@
## Read carefully, use at your own risk
## Add 'source path/to/mkr.sh' in your ~/.bashrc or ~/.zshrc
mkdir -p $HOME/.mkr/bin
export PATH="$PATH:$HOME/.mkr/bin"
# Actually clear your terminal
alias cls='printf "\033c"'
@ -15,17 +18,6 @@ alias cls='printf "\033c"'
## Copies output from previous command into clipboard
alias clip="xclip -selection clipboard"
# 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"
## To install without -y
alias install="sudo apt-get install"
# Directory management
## mk
@ -42,7 +34,7 @@ mkd () {
## If an argument is passed, simply deletes that file or folder from current working directory
rmd () {
CWD="$(dirname $(realpath $0))"
CWD="$PWD"
if [ "$1" ]; then
rm -rf "$1"
else
@ -57,55 +49,6 @@ rmd () {
## 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]
## 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

Loading…
Cancel
Save