Mac bash rc

Posted Elta

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Mac bash rc相关的知识,希望对你有一定的参考价值。

######################################

########## .bashrc

######################################

 

case $- in

*i*) ;;

*) return ;;

esac

 

# bogus

if [ -f /unix ] ; then

alias ls=‘/bin/ls -CGF‘

else

alias ls=‘/bin/ls -GF‘

fi

alias ll=‘ls -l‘

alias dir=‘ls -ba‘

 

alias ss="ps -aux"

alias dot=‘ls .[a-zA-Z0-9_]*‘

alias news="xterm -g 80x45 -e trn -e -S1 -N &"

 

alias c="clear"

alias m="more"

alias j="jobs"

 

# common misspellings

alias mroe=more

alias pdw=pwd

 

hash -p /usr/bin/mail mail

 

if [ -z "$HOST" ] ; then

export HOST=${HOSTNAME}

fi

 

HISTIGNORE="[   ]*:&:bg:fg"

 

psgrep()

{

ps -aux | grep $1 | grep -v grep

}

 

#

# This is a little like `zap‘ from Kernighan and Pike

#

 

pskill()

{

local pid

 

pid=$(ps -ax | grep $1 | grep -v grep | awk ‘{ print $1 }‘)

echo -n "killing $1 (process $pid)..."

kill -9 $pid

echo "slaughtered."

}

 

term()

{

        TERM=$1

export TERM

tset

}

 

xtitle () 

echo -n -e "\033]0;$*\007"

}

 

cd()

{

builtin cd "[email protected]" && xtitle $HOST: $PWD

}

 

bold()

{

tput smso

}

 

unbold()

{

tput rmso

}

 

if [ -f /unix ] ; then

clear()

{

tput clear

}

fi

 

rot13()

{

if [ $# = 0 ] ; then

tr "[a-m][n-z][A-M][N-Z]" "[n-z][a-m][N-Z][A-M]"

else

tr "[a-m][n-z][A-M][N-Z]" "[n-z][a-m][N-Z][A-M]" < $1

fi

}

 

watch()

{

        if [ $# -ne 1 ] ; then

                tail -f nohup.out

        else

                tail -f $1

        fi

}

 

#

#       Remote login passing all 8 bits (so meta key will work)

#

rl()

{

        rlogin $* -8

}

 

function setenv()

{

if [ $# -ne 2 ] ; then

echo "setenv: Too few arguments"

else

export $1="$2"

fi

}

 

function chmog()

{

if [ $# -ne 4 ] ; then

echo "usage: chmog mode owner group file"

return 1

else

chmod $1 $4

chown $2 $4

chgrp $3 $4

fi

}

 

######################################

########## .PS1

######################################

if [ -z "$PS1" ]; then

   return

fi

 

PS1=‘\e[35;36m[\[email protected]\w] $\e[0m ‘

######################################

########## .git-completion.bash

######################################

source ~/.git-completion.bash

 

######################################

########## brew

######################################

export PATH=$PATH:/Users/xiaomi/opt/brew/bin

以上是关于Mac bash rc的主要内容,如果未能解决你的问题,请参考以下文章

在 mac 上升级 bash

Mac升级bash到最新版本

mac相关bash文件

如何在 Mac 上从 Dockerfile 运行 bash 脚本

mac 配置.bash_profile不生效问题

sh [Bash Scripts for Mac] #shell #bash #run