Git Product home page Git Product logo

bash-profile-switcher's Introduction

bash-profile-switcher CI

Easily change environment variables and settings using bash

About

This script aim to manage multiple profile files for bash. It's like having multiple .bashrc files to load or unload when needed.
All you need to do is to create your custom profile files under ~/.bash_profiles directory. Each profile must have extension .load where you define variables, aliases and so on. You can optionally create files with extension .unload to clear what is loaded with a speficic profile.

Installation

Copy bash_profile_switcher.sh script in your homedir and source it at the end of your ~/.bashrc. Reload your shell or close terminal.

Usage

Use switch_profile function to manage profiles

 ~]$ switch_profile -h
switch_profile [options] profile

OPTIONS
  -k
    Keep env. Load selected profile without unloading current environment.
  -d
    Don't load profile. Unload current profile and don't load any profile in new bash shells
  -t
    Temporary profile. Load selected profile in current shell without starting it in new bash shells
  -l
    List available profiles
  -h Show help instructions (this help)

PROFILE
  A profile to load in ~/.bash_profiles. Profile files end with extension '.load' for loading (set variables) and '.unload' for unloading (unset variables)
  Current profile is stored in environment variable BASH_CURRENT_PROFILE and in file ~/.bash_saved_profile

Example:

  ~]$ switch_profile dev

  To load profile dev from ~/.bash_profiles/dev.load and unload it from ~/.bash_profiles/dev.unload

Example

Create the following profile files in ~/.bash_profiles:

myprofile.load

export PS1="Funky Prompt:: \w ]\\$ "

myprofile.unload

unset PS1

Then load it with: switch_profile myprofile

Issues

  • Spaces and blank characters are not supported on profile filenames
  • Unload files must be written manually to match exactly what you loaded or defined
  • Be careful when managing special variables like PATH

bash-profile-switcher's People

Contributors

gianluca-mascolo avatar

Watchers

 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.