From 11aedecab8a8ef7d54f0fa2f1adc67ac78ba42eb Mon Sep 17 00:00:00 2001 From: Mitsuo Tokumori Date: Mon, 20 Mar 2023 02:12:27 -0500 Subject: Simplify bashrc, modify install.sh, add nvim/ bashrc is now simpler. Hopefully with the same functionality. Remove some of the default stuff that came with Debian years ago. Start with default Archlinux bashrc as base (very minimal). install.sh now recommends only using slinks. nvim and zathura now get linked directory-wise. This is way better because added configuration files will get here seamlessly. Doing diffs between 2 independent copies is painful. Now I'm transitioning to NeoVim. I've copied all relevant config from vimrc (Vim) to init.vim (NeoVim). Very promising. File got smaller and more organized in my opinion. PD: Cheers, this pulse15 laptop is amazing. --- install.sh | 99 ++++++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 64 insertions(+), 35 deletions(-) (limited to 'install.sh') diff --git a/install.sh b/install.sh index e2aebea..2d7425a 100755 --- a/install.sh +++ b/install.sh @@ -14,6 +14,7 @@ # people usually manage them. # https://wiki.archlinux.org/title/Dotfiles + # Config # ====== @@ -30,58 +31,86 @@ if [[ -z $XDG_CONFIG_HOME ]]; then mkdir -p $XDG_CONFIG_HOME fi -if [[ $mode = "copy" ]]; then +if [[ $mode = "--help" ]]; then + echo "You might want to first run: $0 echo" + echo "Revise the output" + echo "And only then run: $0 slink" + exit +elif [[ $mode = "copy" ]]; then cp_or_ln="cp" + echo Why? Custom modifications will be difficult to track. + echo Maybe not a good idea. Good bye. + exit elif [[ $mode = "slink" ]]; then - cp_or_ln="ln -s" # if you are fearless add the `-f` option + cp_or_ln="ln -siv" # if you are fearless add the `-f` option +elif [[ $mode = "echo" ]]; then + cp_or_ln="echo ln -siv" else - echo "Usage: $0 copy|slink" + echo "Usage: $0 copy|slink|echo" exit fi -VIMFILES="$HOME/.vim" # In windows it's `%userprofile%/vimfiles/` +prompt() { + read -p "Install $1 configuration files? [Y/n/e(exit)] " yesno + yesno=$(echo $yesno | tr '[:upper:]' '[:lower:]') + case $yesno in + y | yes | "" ) + return 0;; + e | exit ) + exit;; + * ) + return 1;; + esac +} # Install # ======= -# bash (`eval` concatenates and executes) - -eval $cp_or_ln " ${PWD}/bash/profile $HOME/.profile" -eval $cp_or_ln " ${PWD}/bash/bashrc $HOME/.bashrc" -eval $cp_or_ln " ${PWD}/bash/bash_aliases $HOME/.bash_aliases" -eval $cp_or_ln " ${PWD}/bash/inputrc $HOME/.inputrc" - -# vim - -# `~/.vimrc` takes priority over `~/.vim/vimrc`. Remove the former if it exists - -mkdir -p $VIMFILES/{undo,swap,backup,plugins} -chmod 0700 $VIMFILES/swap # swap files should only be readable by owner - -eval $cp_or_ln " ${PWD}/vim/vimrc $VIMFILES/vimrc" -eval $cp_or_ln " ${PWD}/vim/fun.vim $VIMFILES/fun.vim" +# FIXME: If $PWD has spaces in it, this might fail. -# git - -[ -d $XDG_CONFIG_HOME/git ] || mkdir -p $XDG_CONFIG_HOME/git -eval $cp_or_ln " ${PWD}/git/ignore $XDG_CONFIG_HOME/git/ignore" -eval $cp_or_ln " ${PWD}/git/config $XDG_CONFIG_HOME/git/config" -eval $cp_or_ln " ${PWD}/git/git-prompt.sh $HOME/.git-prompt.sh" +# Filewise +if prompt "bash"; then + eval $cp_or_ln " ${PWD}/bash/bash_profile $HOME/.bash_profile" + eval $cp_or_ln " ${PWD}/bash/bashrc $HOME/.bashrc" + eval $cp_or_ln " ${PWD}/bash/bash_aliases $HOME/.bash_aliases" + eval $cp_or_ln " ${PWD}/bash/inputrc $HOME/.inputrc" +fi -# zathura +if prompt "vim"; then + # `~/.vimrc` takes priority over `~/.vim/vimrc`. Remove the former if it + # exists. + # + # In windows it's `%userprofile%/vimfiles/` + + VIMFILES="$HOME/.vim" + mkdir -p $VIMFILES/{undo,swap,backup,plugins} + chmod 0700 $VIMFILES/swap + + eval $cp_or_ln " ${PWD}/vim/vimrc $VIMFILES/vimrc" + eval $cp_or_ln " ${PWD}/vim/fun.vim $VIMFILES/fun.vim" +fi -mkdir -p $XDG_CONFIG_HOME/zathura -eval $cp_or_ln " ${PWD}/other/zathurarc $XDG_CONFIG_HOME/zathura/zathurarc" +# Directorywise +if prompt "nvim"; then + eval $cp_or_ln " ${PWD}/nvim $XDG_CONFIG_HOME/nvim" +fi -# tmux +if prompt "git"; then + [ -d $XDG_CONFIG_HOME/git ] || mkdir -p $XDG_CONFIG_HOME/git + eval $cp_or_ln " ${PWD}/git/ignore $XDG_CONFIG_HOME/git/ignore" + eval $cp_or_ln " ${PWD}/git/config $XDG_CONFIG_HOME/git/config" + eval $cp_or_ln " ${PWD}/git/git-prompt.sh $HOME/.git-prompt.sh" +fi -eval $cp_or_ln " ${PWD}/tmux/tmux.conf $HOME/.tmux.conf" -eval $cp_or_ln " ${PWD}/tmux/tmux.conf.local $HOME/.tmux.conf.local" -# mpd, ncmpc -# (TODO) +if prompt "zathura"; then + eval $cp_or_ln " ${PWD}/zathura $XDG_CONFIG_HOME/zathura" +fi -# done +if prompt "tmux"; then + eval $cp_or_ln " ${PWD}/tmux/tmux.conf $HOME/.tmux.conf" + eval $cp_or_ln " ${PWD}/tmux/tmux.conf.local $HOME/.tmux.conf.local" +fi echo "all done :)" -- cgit v1.2.3