Skip to content

Instantly share code, notes, and snippets.

@RobbiNespu
Last active July 9, 2020 01:52
Show Gist options
  • Save RobbiNespu/69830143374bde7ea83717ca3593ab66 to your computer and use it in GitHub Desktop.
Save RobbiNespu/69830143374bde7ea83717ca3593ab66 to your computer and use it in GitHub Desktop.
Setup and unset proxy environment for bash, Gnome setting,Git proxy, git log graph, current git branch and check battery infomation !
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=
# User specific aliases and functions
## set alias of some command
alias vi=vim
alias cls=clear
alias bat='upower -i /org/freedesktop/UPower/devices/battery_BAT0| grep --color=NEVER -E "present|state|to\ full|percentage|capacity|time\ to empty|time\ to full|technology"'
alias gitgraph='git log --graph --oneline --all --decorate --topo-order'
## set proxy (BASH only not systemwide)
function setproxy() {
export NO_PROXY='localhost,127.0.0.0/8,::1,*.uthm.edu.my'
export no_proxy='localhost,127.0.0.0/8,::1,*.uthm.edu.my'
export {HTTP,HTTPS,FTP}_PROXY='http://proxy.uthm.edu.my:8080/'
export {http,https,ftp}_proxy='http://proxy.uthm.edu.my:8080/'
gsettings set org.gnome.system.proxy mode 'manual'
gsettings set org.gnome.system.proxy.ftp host 'proxy.uthm.edu.my'
gsettings set org.gnome.system.proxy.ftp port 8080
gsettings set org.gnome.system.proxy.https host 'proxy.uthm.edu.my'
gsettings set org.gnome.system.proxy.https port 8080
gsettings set org.gnome.system.proxy.http host 'proxy.uthm.edu.my'
gsettings set org.gnome.system.proxy.http port 8080
gnome-terminal -x bash -c "git config --global http.proxy \"proxy.uthm.edu.my:8080\""
echo -e "Proxy environment variable has been setup!"
}
function unsetproxy() {
unset {HTTP,HTTPS,FTP}_PROXY
unset {http,https,ftp}_proxy
unset no_proxy
unset NO_PROXY
gsettings set org.gnome.system.proxy mode 'none'
gnome-terminal -x bash -c "git config --global http.proxy \"\""
echo -e "Proxy environment variable removed."
}
## set Android development enviroment
ANDROID_HOME=/run/media/robbi/Data/Android/Sdk-linux
export ANDROID_HOME=$ANDROID_HOME
export ANDROID_HOME=$ANDROID_HOME
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH
## Set node version manager (nvm)
export NVM_DIR="/home/robbi/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
[[ -r $NVM_DIR/bash_completion ]] && . $NVM_DIR/bash_completion
function parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[00;32m\]"
NO_COLOR="\[\033[0m\]"
BLUE="\[\033[00;34m\]"
PS1="[$BLUE\u@\h$NO_COLOR] \W $GREEN\$(parse_git_branch)$NO_COLOR\$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment