Skip to content

mitsutaka/zcmd

Repository files navigation

zcmd: mitZ's CoMmanD line collections

CircleCI GoDoc Go Report Card

Installation

go get github.com/mitsutaka/zcmd/pkg/z

Usage

z

sync command

rsync wrapper command for servers. It plans replace it with Go native sync library.

  • z sync pull: Pull files from the remote server in parallel.
  • z sync push: Push files to the remote server in parallel.

Command line flag can append additional rsync flags. Default rsync flags are -avzP --stats --delete --delete-excluded.

Configuration example $HOME/.z.yaml:

sync:
  # Config for pulling
  pull:
    # It uses when command runs with particular path
    - name: movie
      # Source URL for pulling
      source: RSYNC_URL
      # Destination directory
      destination: /mnt/nas/movie
    - name: picture
      source: RSYNC_URL
      destination: /mnt/nas/picture
      # Exclude pattern
      excludes:
        - xxxx
        - yyyy
  # Config for pushing
  push:
    - name: music
      source: /mnt/nas/music
      destination: RSYNC_URL
      excludes:
        - zzzz
    - name: fuse
      source: /home/mitz/Documents
      destination: LOCAL_PATH
      # Some cases should disable sudo with fuse mounts
      disable_sudo: true

backup command

rsync wrapper command for backup.

  • z backup: Run backup to the remote server in parallel.

Command line flag can append additional rsync flags. Default rsync flags are -avzP --stats --delete.

Configuration example $HOME/.z.yaml:

backup:
  # Backup URLs
  destinations:
    - rsync://BACKUP_URL
  # Include backup paths
  includes:
    - /
    - /boot
    - /home
 # Exclude paths and pattern
  excludes:
    - .cache/
    - /dev
    - /media
    - /misc
    - /mnt
    - /proc
    - /run
    - /sys
    - /var/cache

repos-update command

Run git clean, git checkout master and git pull for checked out git repositories.

Configuration example $HOME/.z.yaml:

repos:
  # Root directory of the git repositories
  root: /your/root/git/repos

dotfiles command

dotfiles manager inspired by https://github.com/dotphiles/dotphiles

  • z dotfiles init GITURL: Initialize dotfiles in local.
  • z dotfiles pull: Download latest dotfiles and make symbolic links.
dotfiles:
  # default is $HOME/.zdotfiles
  dir: /home/mitz/.zdotfiles
  hosts:
    - YOUR_HOSTNAME
  files:
    - bashrc
    - config/sway/config
    - spacemacs
    - ssh

proxy command

NOT IMPLEMENTED YET

Make multiple ssh port forward at once.

  • z proxy: Setup ssh port forward.
proxy:
  - name: testforward1
    user: ubuntu
    address: remotehost1
    private_key: ~/.ssh/id_rsa
    forward:
      # Local forwarding
      - type: local
        # default bindAddress is *
        bind_pddress: localhost
        bind_port: 13128
        remote_address: localhost
        remote_port: 3128
      # Dynamic forwarding for SOCK4, 5
      - type: dynamic
        bind_address: localhost
        bind_port: 1080
  - name: testforward2
    user: admin
    address: remotehost2
    private_key: ~/.ssh/id_ecdsa
    port: 10000
    forward:
      # Remote forwarding
      - type: remote
        bind_address: localhost
        bind_port: 9000
        remote_address: localhost
        remote_port: 3000

Misc

To load bash completion scripts, run:

. <(z completion)

License

MIT

About

mitZ's CoMmanD utilities for personal use

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published