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_profileproject.
Clone this project in your home folder ~.
cd ~ && git clone https://github.com/marcomontalbano/bash_profile.gitOpen 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-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.
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-
bash_profile__path - get project path.
-
bash_profile__cd -
cdto thebash_profilefolder. Something likecd ~/bash_profile -
bash_profile__version - get current version.
-
bash_profile__reload - reload the project.
-
bash_profile__reload_all - reload your own
.bash_profileor.bashrc. -
bash_profile__update - update the
bash_profileproject with latest changes. Is "just" agit pull😄
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 nodewill returntrueif node is installed on your system,falseotherwise. -
proxy__set - simply set the command line proxy. It works also for npm and apm, if you use them. usage:
proxy__set http://domain:8080orproxy__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__update_date - update last commit with current date. usage:
git__update_dateorgit__update_date -v -5H(only for OS X)
PS1 is customized with multiple lines.
- green label - you can fetch the pwd path.
- yellow label (optional) - it appear inside Git or Svn folders.
- cyan label - you have the username @ hostname
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