From 8dc16ca9816e8849af7fa59b8660da8c2119e9e4 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Mon, 27 May 2024 09:01:23 -0700 Subject: [PATCH] Let people own their own basic configs Just call for defaults, then overwrite --- {dotfiles => defaults/bash}/aliases | 0 defaults/bash/init | 5 ++++ defaults/bash/inputrc | 41 ++++++++++++++++++++++++++ {dotfiles => defaults/bash}/prompt | 0 defaults/bash/rc | 4 +++ defaults/bash/shell | 12 ++++++++ dotfiles/bashrc | 28 ++---------------- dotfiles/exports | 1 - dotfiles/inputrc | 45 +---------------------------- install/dotfiles.sh | 28 +++++------------- 10 files changed, 73 insertions(+), 91 deletions(-) rename {dotfiles => defaults/bash}/aliases (100%) create mode 100644 defaults/bash/init create mode 100644 defaults/bash/inputrc rename {dotfiles => defaults/bash}/prompt (100%) create mode 100644 defaults/bash/rc create mode 100644 defaults/bash/shell delete mode 100644 dotfiles/exports diff --git a/dotfiles/aliases b/defaults/bash/aliases similarity index 100% rename from dotfiles/aliases rename to defaults/bash/aliases diff --git a/defaults/bash/init b/defaults/bash/init new file mode 100644 index 0000000..f3fff3f --- /dev/null +++ b/defaults/bash/init @@ -0,0 +1,5 @@ +eval "$(rbenv init - bash)" +eval "$(nodenv init -)" +eval "$(zoxide init bash)" +eval "$(zellij setup --generate-auto-start bash)" +source /usr/share/doc/fzf/examples/key-bindings.bash diff --git a/defaults/bash/inputrc b/defaults/bash/inputrc new file mode 100644 index 0000000..6e4bb8a --- /dev/null +++ b/defaults/bash/inputrc @@ -0,0 +1,41 @@ +set meta-flag on +set input-meta on +set output-meta on +set convert-meta off +set completion-ignore-case on +set completion-prefix-display-length 2 +set show-all-if-ambiguous on +set show-all-if-unmodified on + +# Arrow keys match what you've typed so far against your command history +"\e[A": history-search-backward +"\e[B": history-search-forward +"\e[C": forward-char +"\e[D": backward-char + +# Immediately add a trailing slash when autocompleting symlinks to directories +set mark-symlinked-directories on + +# Do not autocomplete hidden files unless the pattern explicitly begins with a dot +set match-hidden-files off + +# Show all autocomplete results at once +set page-completions off + +# If there are more than 200 possible completions for a word, ask to show them all +set completion-query-items 200 + +# Show extra file information when completing, like `ls -F` does +set visible-stats on + +$if Bash + # Be more intelligent when autocompleting by also looking at the text after + # the cursor. For example, when the current line is "cd ~/src/mozil", and + # the cursor is on the "z", pressing Tab will not autocomplete it to "cd + # ~/src/mozillail", but to "cd ~/src/mozilla". (This is supported by the + # Readline used by Bash 4.) + set skip-completed-text on + + # Coloring for Bash 4 tab completions. + set colored-stats on +$endif diff --git a/dotfiles/prompt b/defaults/bash/prompt similarity index 100% rename from dotfiles/prompt rename to defaults/bash/prompt diff --git a/defaults/bash/rc b/defaults/bash/rc new file mode 100644 index 0000000..b368047 --- /dev/null +++ b/defaults/bash/rc @@ -0,0 +1,4 @@ +source ~/.local/share/omakub/defaults/bash/shell +source ~/.local/share/omakub/defaults/bash/aliases +source ~/.local/share/omakub/defaults/bash/prompt +source ~/.local/share/omakub/defaults/bash/init diff --git a/defaults/bash/shell b/defaults/bash/shell new file mode 100644 index 0000000..9cca8ac --- /dev/null +++ b/defaults/bash/shell @@ -0,0 +1,12 @@ +# History control +shopt -s histappend +HISTCONTROL=ignoreboth +HISTSIZE=32768 +HISTFILESIZE="${HISTSIZE}" + +# Autocompletion +source /usr/share/bash-completion/bash_completion + +# Set complete path +export PATH="./bin:$HOME/.local/bin:$HOME/.local/share/omakub/bin:$HOME/.rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin" +set +h diff --git a/dotfiles/bashrc b/dotfiles/bashrc index 53a8136..f594d08 100644 --- a/dotfiles/bashrc +++ b/dotfiles/bashrc @@ -1,26 +1,4 @@ -# History control -shopt -s histappend -HISTCONTROL=ignoreboth -HISTSIZE=32768 -HISTFILESIZE="${HISTSIZE}" +source ~/.local/share/omakub/defaults/bash/rc -# Autocompletion -source /usr/share/bash-completion/bash_completion - -# Set complete path -export PATH="./bin:$HOME/.rbenv/bin:$HOME/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin" -set +h - -# Load configuration first from omabox, then local overwrites -for file in ~/.{prompt,exports,aliases}; do - [ -r "$file" ] && [ -f "$file" ] && source "$file" - [ -r "$file.local" ] && [ -f "$file.local" ] && source "$file.local" -done -unset file - -# Run iniitializers -eval "$(rbenv init - bash)" -eval "$(nodenv init -)" -eval "$(zoxide init bash)" -eval "$(zellij setup --generate-auto-start bash)" -source /usr/share/doc/fzf/examples/key-bindings.bash +# Editor used by CLI +export EDITOR="nvim" diff --git a/dotfiles/exports b/dotfiles/exports deleted file mode 100644 index 5f2f08d..0000000 --- a/dotfiles/exports +++ /dev/null @@ -1 +0,0 @@ -export EDITOR="nvim" diff --git a/dotfiles/inputrc b/dotfiles/inputrc index fd98447..443dea1 100644 --- a/dotfiles/inputrc +++ b/dotfiles/inputrc @@ -1,44 +1 @@ -set meta-flag on -set input-meta on -set output-meta on -set convert-meta off -set completion-ignore-case on -set completion-prefix-display-length 2 -set show-all-if-ambiguous on -set show-all-if-unmodified on - -# Arrow keys match what you've typed so far against your command history -"\e[A": history-search-backward -"\e[B": history-search-forward -"\e[C": forward-char -"\e[D": backward-char - -# Immediately add a trailing slash when autocompleting symlinks to directories -set mark-symlinked-directories on - -# Do not autocomplete hidden files unless the pattern explicitly begins with a dot -set match-hidden-files off - -# Show all autocomplete results at once -set page-completions off - -# If there are more than 200 possible completions for a word, ask to show them all -set completion-query-items 200 - -# Show extra file information when completing, like `ls -F` does -set visible-stats on - -$if Bash - # Be more intelligent when autocompleting by also looking at the text after - # the cursor. For example, when the current line is "cd ~/src/mozil", and - # the cursor is on the "z", pressing Tab will not autocomplete it to "cd - # ~/src/mozillail", but to "cd ~/src/mozilla". (This is supported by the - # Readline used by Bash 4.) - set skip-completed-text on - - # Coloring for Bash 4 tab completions. - set colored-stats on -$endif - -# End with local overrides -$include ~/.inputrc.local +$include ~/.local/share/omakub/defaults/bash/inputrc diff --git a/install/dotfiles.sh b/install/dotfiles.sh index 6356347..61ad36c 100644 --- a/install/dotfiles.sh +++ b/install/dotfiles.sh @@ -1,36 +1,22 @@ # Ensure .config exists mkdir -p ~/.config -# Link all dotfiles +# Copy all dotfiles for entry in ~/.local/share/omakub/dotfiles/*; do - # Link all root files as .file in ~/ + # Copy all root files as .file in ~/ # Any existing files will be renamed .bak if [ -f $entry ]; then target=~/."$(basename $entry)" - - if [ -e $target ] && [ "$(readlink $target)" != $entry ]; then - mv $target $target.bak - fi - - if [ ! -e $target ]; then - ln -s $entry $target - fi - - touch $entry.local + [ -e $target ] && mv $target $target.bak + cp $entry $target fi - # Link all directories in ~/.config/ + # Copy all directories in ~/.config/ # Any existing directories will be renamed .bak if [ -d $entry ]; then target=~/.config/"$(basename $entry)" - - if [ -e $target ] && [ "$(readlink "$target")" != $entry ]; then - mv $target $target.bak - fi - - if [ ! -e $target ]; then - ln -s $entry $target - fi + [ -e $target ] && mv $target $target.bak + cp -R $entry $target fi done unset entry