Skip to content
A collection of bash utilities. Set and unset proxy. Completions for git, svn and ssh. PS1 customization.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
images
.bash_profile
.bash_profile__colors
.bash_profile__git
.bash_profile__svn
.bash_profile__utility
.gitignore
CHANGELOG.md
LICENSE
README.md
VERSION

README.md

.bash_profile

This is a collection of bash utilities. It contains:

  • PS1 customization with Git and Svn integration.
  • Bash Completions for Git, Svn, SSH and SFTP.
  • set/unset proxy faster.
  • Updatable bash_profile project.

Get started

Clone this project in your home folder ~.

cd ~ && git clone https://github.com/marcomontalbano/bash_profile.git

Open and modify your $HOME/.bash_profile on OS X and Windows or $HOME/.bashrc on Ubuntu, adding the following script.

# https://github.com/marcomontalbano/bash_profile
source ~/bash_profile/.bash_profile -u

Options

  • -p <http-proxy>: combined with -u, you can use self-update behind proxy.
  • -u: enables self-update for bash_profile. (the latest release will automatically downloaded and loaded)
  • -w: show welcome screen on new tabs.

Completions

The following procedure works for OS X. If you are using Windows or Ubuntu, you don't need it.

If you want to use the git, svn and ssh completion, just run following scripts.

# Bash Completion for GIT
curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/bash_profile/.bash_completion_git

# Bash Completion for SVN
curl http://svn.apache.org/repos/asf/subversion/trunk/tools/client-side/bash_completion -o ~/bash_profile/.bash_completion_svn

# Bash Completion for SSH and SFTP
curl https://gist.githubusercontent.com/marcomontalbano/7c48f6756e4e4133c30fdb8e1fff3100/raw -o ~/bash_profile/.bash_completion_ssh

Useful Commands

Bash Profile

  • bash_profile__path - get project path.

  • bash_profile__cd - cd to the bash_profile folder. Something like cd ~/bash_profile

  • bash_profile__version - get current version.

  • bash_profile__reload - reload the project.

  • bash_profile__reload_all - reload your own .bash_profile or .bashrc.

  • bash_profile__update - update the bash_profile project with latest changes. Is "just" a git pull 😄

General

Below a list of utilities that you can use on command line or your own .bash_profile.

  • console__set_title - set a console title. (only for OS X and Windows)

  • cli__is_installed - check if a program is installed on your system. cli__is_installed node will return true if node is installed on your system, false otherwise.

  • proxy__set - simply set the command line proxy. It works also for npm and apm, if you use them. usage: proxy__set http://domain:8080 or proxy__set http://domain:8080 https://domain:8080

  • proxy__unset - simply unset the command line proxy.

  • network__get_ip - get ip address (e.g. 192.168.0.5)

  • network__get_gateway - get gateway address (e.g. 192.168.0.1)

  • network__get_broadcast - get broadcast address (e.g. 192.168.0.1)

  • java__use_jdk - if you work with different version of JDK, you can easily switch with java__use_jdk 1.8. (only for OS X)

Git

  • git__update_date - update last commit with current date. usage: git__update_date or git__update_date -v -5H (only for OS X)

PS1 customization

PS1 is customized with multiple lines.

  1. green label - you can fetch the pwd path.
  2. yellow label (optional) - it appear inside Git or Svn folders.
  3. cyan label - you have the username @ hostname

Git integration

there are no changes on the active master branch

there are changes on the active master branch, but not committed yet

you have created a new-branch, but not pushed yet

you have created and pushed a new-branch

you have created a new-branch with some changes, but not committed and pushed yet

you have pushed the new-branch, but it has other changes to commit

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.