/anyrc

:shell: Bring your shell environment to anywhere

Primary LanguageShellApache License 2.0Apache-2.0

🐚 anyrc

Bring your .bashrc, .zshrc, .vimrc, etc. into any remote environments, such as ssh, docker container (docker run / docker exec / kubectl exec), and another user (su).

🔜 Usage

Just use *rc commands instead of original commands

  • sshrc xxx instead of ssh xxx
    • e.g., sshrc -p 10022 foo@XXX.XXX.XXX.XXX
  • surc xxx instead of su xxx
    • e.g., surc foo
  • dockerrc exec xxx instead of docker exec xxx
    • e.g., dockerrc exec foo_running_container bash
  • dockerrc run xxx instead of docker run -it xxx
    • e.g., dockerrc run foo_image bash
  • kubectlrc exec xxx instead of kubectl exec xxx
    • e.g., kubectlrc exec foo_running_pod zsh

Note: Incompatible subcommands (e.g., ps for dockerrc) will be passed to the original command (i.e., docker ps will be executed).

Setup

# If you want to install the latest version, change 0.0.1 to master in the url
# DIR: Where to install (default: /usr/local/bin)
# FORCE: If defined, override .anyrc (default: undefined)
curl -sS https://raw.githubusercontent.com/amaya382/anyrc/0.0.1/install.sh | DIR=/usr/local/bin bash

# Put your dotfiles or create symlinks of them into $HOME/.anyrc.d
ln -s /path/to/your/dotfiles/.dotfile $HOME/.anyrc.d/.dotfile

Options

  • ANYRC_DANYRC: Path to .anyrc. Default is in home dir or curr dir
  • ANYRC_DANYRCD: Path to .anyrc.d. Default is in home dir or curr dir
  • ANYRC_SSH_CMD: ssh command, i.e., you can use autossh instead
  • ANYRC_DOCKER_WO_TAR: If set, will work w/o tar on dockerrc
  • ANYRC_K8S_WO_TAR: If set, will work w/o tar on kubectlrc
  • ANYRC_WO_TAR: If set, will work w/o tar on any remote environment

Customize

Config files

  • .anyrc: Pre-configured for zsh, bash, tmux, and vim. If you want to support other tools, edit me.
  • .anyrc.d/*: Dotfiles you want to bring into remote. Symlinks are allowed.

Environment variables (in .anyrc and .anyrc.d/*)

  • ANYRC_ENV: Show remote environment (ssh/su/docker/k8s)
  • ANYRC_ROOT: Path to tmp dir including all anyrc-related files each connection
  • ANYRC_HOME: Path to dir for dotfiles
  • ANYRC_DANYRC: Path to .anyrc
  • ANYRC_DANYRCD: Path to .anyrc.d

Examples

See example

🔱 Features

Supported remote environments

  • ssh
    • Attach w/ a login shell
  • docker run
    • Attach w/ a specified shell
  • docker exec
    • Attach w/ a specified shell
  • kubectl exec
    • Attach w/ a specified shell
  • su (work w/ sudo)
    • Attach w/ a login shell

Supported tools

  • zsh
  • bash
  • tmux
  • vim
  • git
  • etc.

🙇 Acknowledgement