Skip to content

Instantly share code, notes, and snippets.

@coldnebo
Last active February 6, 2016 20:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coldnebo/e74763de93ff0ad0be89 to your computer and use it in GitHub Desktop.
Save coldnebo/e74763de93ff0ad0be89 to your computer and use it in GitHub Desktop.
how I manage my paths
pathadd() {
if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then
PATH="${PATH:+"$PATH:"}$1"
fi
}
pathoverride() {
if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then
PATH="$1${PATH:+":$PATH"}"
fi
}
# remote to ubuntu
function rpwd {
local name=`pwd`
[[ "$name" =~ ^"$HOME"(/|$) ]] && name="~${name#$HOME}"
echo $name
}
# example use
# to change dir from mac /Users/lkyrala to /home/lkyrala automatically using the above rpwd.
alias ss='ssh lkyrala@ubuntu "cd `rpwd`; /bin/bash -i"'
# mac centric (acts like ubuntu with a twist):
# on prompt, only show the current directory, but in the window title
# show the entire path. prepended by user@machinename
PS1="\u@\h:../\W$ "
export PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}: ${PWD}\007"'
pathoverride $HOME/bin
export NODE_HOME=/local/node
pathadd $NODE_HOME/bin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment