diff options
| -rw-r--r-- | mkshrc | 77 |
1 files changed, 70 insertions, 7 deletions
@@ -3,13 +3,18 @@ # vim: syn=sh # How to install: -# For ZSH: -# curl https://www.rygel.us/etc/mkshrc > $HOME/.mkshrc && echo '. $HOME/.mkshrc' >> .zshrc.local # For Bash: # curl https://www.rygel.us/etc/mkshrc > $HOME/.mkshrc && echo '. $HOME/.mkshrc' >> .bashrc # # Personally I use this with mksh, .mkshrc is auto loaded by mksh +# This will hopefully fix the bullshit with zsh +if \ + [ $SHELL = "/bin/zsh" ] || \ + [ $SHELL = "/usr/bin/zsh" ] || \ + [ $SHELL = "/usr/local/bin/zsh" ] ; then +else + #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% # ____ _ @@ -83,6 +88,9 @@ do_cd() { [ $(id -u) -eq 0 ] && PS1="$USER@$hostname:$pwd # " } +# ZSH doesn't handle these functions all too well +fi + #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% # _ _ _ _____ _ _ # / \ | (_) __ _ ___ | ___| _ _ __ ___| |_(_) ___ _ __ ___ @@ -99,7 +107,6 @@ setaliases() { alias m="$PAGER"; alias j="jobs"; alias p="pwd"; - # [ $(which nvi 2>/dev/null) ] && alias vi='nvi'; alias gdb='gdb -q' alias bc='bc -q' alias egrep='egrep --color=auto' @@ -122,6 +129,21 @@ setcoloraliases() { alias search='egrep --color=auto -rnI'; alias t='tree -CdL' } + +setsudoaliases() { + # Package managers + alias apt-get='sudo apt-get' + alias yum='sudo dnf' + alias dnf='sudo dnf' + alias pacman='sudo pacman' + alias pkg='sudo pkg' + + # Filesystem utilities + alias zfs='sudo zfs' + alias btrfs='sudo btrfs' + alias mount='sudo mount' +} + # Usage debugstarttls $ipaddr:$port debugstarttls() { openssl s_client -starttls smtp -crlf -connect $1 $2 @@ -475,9 +497,9 @@ setcolorterminal() { } setlscolors() { - if [ "$(uname)" == "Linux" ] ; then + if [ "$(uname)" = "Linux" ] ; then export LS_COLORS='di=36;40:ln=1;31;40:so=32;40:pi=33;40:ex=1;32;40:bd=34;46:cd=34;43:su=0;41:sg=0;46:tw=0;42:ow=0;43:' - elif [ "$(uname)" == "FreeBSD" ] ; then + elif [ "$(uname)" = "FreeBSD" ] ; then export LSCOLORS='gxBxcxdxCxegedabagacad' fi } @@ -495,6 +517,40 @@ colormanpages() { export GROFF_NO_SGR=1 } +#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +# __ __ _ _____ _ _ +#| \/ (_)___ ___ | ___| _ _ __ ___| |_(_) ___ _ __ ___ +#| |\/| | / __|/ __| | |_ | | | | '_ \ / __| __| |/ _ \| '_ \/ __| +#| | | | \__ \ (__ | _|| |_| | | | | (__| |_| | (_) | | | \__ \ +#|_| |_|_|___/\___| |_| \__,_|_| |_|\___|\__|_|\___/|_| |_|___/ +#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +set_editor() { + export EDITOR="vi" + + if [ -x "$(which nvim)" ] ; then + export EDITOR="$(which nvim)" + elif [ -x "$(which vim)" ] ; then + export EDITOR="$(which vim)" + fi + + # Set an alias for our editor of choice + alias vi="$EDITOR" + alias edit="$EDITOR" + alias e="$EDITOR" +} +set_pager() { + if [ -x "$(which less)" ] ; then + export EDITOR="$(which less)" + elif [ -x "$(which more)" ] ; then + export EDITOR="$(which more)" + fi +} +set_lang() { +export CHARSET="$1"; +export LANG="$1"; +} +#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -530,13 +586,14 @@ COLOR=1 ############################################################ ########## Enviroment variables -export PAGER="less" -export EDITOR="vi" +set_pager +set_editor export PATH="$HOME/bin:$PATH" export VISUAL="$EDITOR" export GOPATH=$HOME/go export PATH=$PATH:$GOPATH/bin +set_lang "en_US.UTF-8" # Load pre config if [ -e $PRELOAD ] ; then @@ -555,6 +612,7 @@ then bind ^L=clear-screen setaliases + setsudoaliases if [ $COLOR -eq 1 ] ; then set_prompt @@ -563,9 +621,14 @@ then setcoloraliases setlscolors fi +elif [ $SHELL = "/bin/zsh" ] || + [ $SHELL = "/usr/bin/zsh" ] || + [ $SHELL = "/usr/local/bin/zsh" ] ; then + set -o emacs else # Support other shells setaliases + setsudoaliases [ $SHELL = "/bin/sh" ] && set_super_basic_prompt |
