GithubHelp home page GithubHelp logo

linktohack / anyrc Goto Github PK

View Code? Open in Web Editor NEW

This project forked from amaya382/anyrc

1.0 2.0 0.0 53 KB

:shell: Bring your shell environment to anywhere

License: Apache License 2.0

Shell 99.95% Vim Script 0.05%

anyrc's Introduction

๐Ÿš 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
  • surc xxx instead of su xxx
    • e.g., surc foo
  • dockerrc exec -it xxx instead of docker exec -it xxx
    • e.g., dockerrc exec -it foo_running_container bash
  • dockerrc run -it xxx instead of docker run -it xxx
    • e.g., dockerrc run -it foo_image bash
  • kubectlrc exec -it xxx instead of kubectl exec -it xxx
    • e.g., kubectlrc exec -it 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/Upgrade

# If you want to install the latest version, change version to master in the url and set VERSION
# REPO: anyrc fork (default: same as install script fork)
# VERSION: anyrc version (default: same as install script version)
# DIR: Where to install (default: /usr/local/bin)
# FORCE: If defined, override .anyrc (default: undefined)
## default installation example
curl -sS https://raw.githubusercontent.com/amaya382/anyrc/0.1.0/install.sh | bash
## fully-customized installation example
curl -sS https://raw.githubusercontent.com/amaya382/anyrc/master/install.sh | VERSION=master DIR=~/.local/bin FORCE=1 bash

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

See example as well.

More options

  • ANYRC_ANYRC: Path to .anyrc. Default is in home dir or curr dir
  • ANYRC_ANYRCD: 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
# sshrc will use autossh internally
ANYRC_SSH_CMD=autossh sshrc user@host

Customize

Config files

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

Available 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_ANYRC: Path to .anyrc
  • ANYRC_ANYRCD: Path to .anyrc.d

Examples

See example

Completion

zsh

compdef dockerrc=docker
compdef kubectlrc=kubectl

๐Ÿ”ฑ 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. (can support other tools by editing .anyrc)

๐Ÿ™‡ Acknowledgement

anyrc's People

Contributors

amaya382 avatar linktohack avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.