Customize dotfiles for Parch

This commit is contained in:
komeil Parseh 2023-02-16 12:27:43 +03:30
parent 5b406261f7
commit b11f233fec
No known key found for this signature in database
GPG key ID: 1928AF673B1C4255
14 changed files with 273 additions and 330 deletions

13
.editorconfig Normal file
View file

@ -0,0 +1,13 @@
root = true
[*]
indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true
end_of_line = lf
charset = utf-8
max_line_length = 88
[*.{yml,yaml,json,js,css,html}]
indent_size = 2

14
LICENSE
View file

@ -1,8 +1,6 @@
LICENSE
MIT License
The MIT License
Copyright (c) 2009-2016 thoughtbot, inc.
Copyright (c) 2023 Parchlinux
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -11,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -1,260 +0,0 @@
Los dotfiles de thoughtbot
==========================
![prompt](http://images.thoughtbot.com/thoughtbot-dotfiles-prompt.png)
Requerimientos
--------------
Establece zsh como tu shell de inicio de sesión:
chsh -s $(which zsh)
Instalar
--------
Clona en tu laptop:
git clone git@github.com:thoughtbot/dotfiles.git ~/dotfiles
(o [haz un fork y mantenlo actualizado](http://robots.thoughtbot.com/keeping-a-github-fork-updated)).
Instala [rcm](https://github.com/thoughtbot/rcm):
brew install rcm
Instala los dotfiles:
env RCRC=$HOME/dotfiles/rcrc rcup
Después de la instalación inicial, puedes ejecutarlo sin establecer la variable `RCRC`
(`rcup` establecerá un enlace simbólico (symlink) del repo `rcrc` hacia `~/.rcrc` para futuras
ejecuciones de `rcup`). [Ve el ejemplo](https://github.com/thoughtbot/dotfiles/blob/master/rcrc).
Este comando creará enlaces simbólicos (symlinks) para los archivos de configuración en tu
directorio principal.
Establecer la variable de entorno le dice a `rcup` que use las opciones de
configuración preestablecidas:
* Excluye los archivos `README.md`, `README-ES.md` y `LICENSE`, que son parte
del repositorio `dotfiles`, pero no necesitan enlazarse simbólicamente.
* Le da precedencia a las modificaciones personales que por defecto están en
`~/dotfiles-local`
* Por favor configura el archivo `rcrc` en caso de que quieras hacer
modificaciones personales en un directorio distinto.
Actualizar
----------
De vez en cuando deberías descargar las actualizaciones de estos dotfiles, y ejectuar
rcup
para ligar cualquier nuevo archivo e instalar los nuevos plugins de vim. **Nota** _Debes_ ejecutar
`rcup` después de descargar para asegurarte que todos los archivos de los plugins
estén instalados adecuadamente. Puedes ejecutar `rcup` con seguridad muchas veces
para actualizar pronto y muy seguido!
Haz tus propias modificaciones
------------------------------
Crea un directorio para tus modificaciones personales:
mkdir ~/dotfiles-local
Pon tus modificaciones en `~/dotfiles-local` anexado con `.local`:
* `~/dotfiles-local/aliases.local`
* `~/dotfiles-local/git_template.local/*`
* `~/dotfiles-local/gitconfig.local`
* `~/dotfiles-local/psqlrc.local` (proveemos `.psqlrc.local` en blanco para prevenir que `psql`
arroje un error, pero debes sobreescribir el archivo con tu propia copia)
* `~/dotfiles-local/tmux.conf.local`
* `~/dotfiles-local/vimrc.local`
* `~/dotfiles-local/vimrc.bundles.local`
* `~/dotfiles-local/zshrc.local`
* `~/dotfiles-local/zsh/configs/*`
Por ejemplo, tu `~/dotfiles-local/aliases.local` tal vez se vea así:
# Productivity
alias todo='$EDITOR ~/.todo'
Tu `~/dotfiles-local/gitconfig.local` tal vez se vea así:
[alias]
l = log --pretty=colored
[pretty]
colored = format:%Cred%h%Creset %s %Cgreen(%cr) %C(bold blue)%an%Creset
[user]
name = Dan Croak
email = dan@thoughtbot.com
Tu `~/dotfiles-local/vimrc.local` tal vez se vea así:
" Color scheme
colorscheme github
highlight NonText guibg=#060606
highlight Folded guibg=#0A0A0A guifg=#9090D0
Si prefieres prevenir la instalación de un plugin predeterminado de vim en `.vimrc.bundles`,
puedes ignorarlo sacándolo con `UnPlug` en tu `~/.vimrc.bundles.local`.
" Don't install vim-scripts/tComment
UnPlug 'tComment'
`UnPlug` puede ser usado para instalar tu propio fork de un plugin o para instalar
un plugin compartido con opciones personalizadas distintas.
" Only load vim-coffee-script if a Coffeescript buffer is created
UnPlug 'vim-coffee-script'
Plug 'kchmck/vim-coffee-script', { 'for': 'coffee' }
" Use a personal fork of vim-run-interactive
UnPlug 'vim-run-interactive'
Plug '$HOME/plugins/vim-run-interactive'
Para extender tus `git` hooks, crea scripts ejecutables en
`~/dotfiles-local/git_template.local/hooks/*` files.
Tu `~/dotfiles-local/zshrc.local` tal vez se vea así:
# load pyenv if available
if command -v pyenv &>/dev/null ; then
eval "$(pyenv init -)"
fi
Tu `~/dotfiles-local/vimrc.bundles.local` tal vez se vea así:
Plug 'Lokaltog/vim-powerline'
Plug 'stephenmckinney/vim-solarized-powerline'
Configuraciones de zsh
----------------------
Configuraciones adicionales para zsh pueden ir en el directorio `~/dotfiles-local/zsh/configs`. Este
tiene dos subdirectorios especiales: `pre` para archivos que deben ser cargados primero y `post`
para archivos que deben cargarse al final.
Por ejemplo, `~/dotfiles-local/zsh/configs/pre/virtualenv` hace uso de varias características
de shell que tal vez se vean afectadas por tu configuración, por lo tanto cárgalo primero:
# Load the virtualenv wrapper
. /usr/local/bin/virtualenvwrapper.sh
Establecer una vinculación clave puede ocurrir en `~/dotfiles-local/zsh/configs/keys`:
# Grep anywhere with ^G
bindkey -s '^G' ' | grep '
Algunos cambios, como `chpwd`, deben ocurrir en `~/dotfiles-local/zsh/configs/post/chpwd`:
# Show the entries in a directory whenever you cd in
function chpwd {
ls
}
Este directorio está a la mano para combinar dotfiles de múltiples equipos; un equipo
puede agregar el archivo `virtualenv`, otro el archivo `keys` y un tercero el archivo `chpwd`.
El archivo `~/dotfiles-local/zshrc.local` se carga después de `~/dotfiles-local/zsh/configs`.
Configuraciones de vim
----------------------
Similar al directorio de configuración para zsh descrito arriba, vim
automáticamente descarga los archivos en el directorio `~/dotfiles-local/vim/plugin`. Sin embargo, este no
tiene el mismo soporte para los subdirectorios `pre` ni `post` que tiene nuestro `zshrc`.
Este es un ejemplo `~/dotfiles-local/vim/plugin/c.vim`. Se carga cada vez que inicia vim,
sin importar de nombre del archivo:
# Indent C programs according to BSD style(9)
set cinoptions=:0,t0,+4,(4
autocmd BufNewFile,BufRead *.[ch] setlocal sw=0 ts=8 noet
¿Qué viene incluido?
-----------------
Configuración [vim](http://www.vim.org/):
* [fzf](https://github.com/junegunn/fzf.vim) para hallazgo difuso de archivos/buffer/tags.
* [Rails.vim](https://github.com/tpope/vim-rails) para una mejor navegación de la estructura
de archivos de Rails via `gf` y `:A` (alterno), `:Rextract` parciales,`:Rinvert` migraciones, etc.
* Ejecuta muchos tipos de pruebas [desde vim]([https://github.com/janko-m/vim-test)
* Establece `<leader>` a un sólo espacio.
* Navega entre los últimos dos archivos con espacio-espacio
* Resaltado de sintaxis para Markdown, HTML, JavaScript, Ruby, Go, Elixir, y más.
* Usa [Ag](https://github.com/ggreer/the_silver_searcher) en lugar de Grep cuando esté disponible.
* Map `<leader>ct` para re-indexar [Exuberant Ctags](http://ctags.sourceforge.net/).
* Usa [vim-mkdir](https://github.com/pbrisbin/vim-mkdir) para crear automáticamente directorios
no existentes antes de escribir el buffer.
* Usa [vim-plug](https://github.com/junegunn/vim-plug) para administrar plugins.
[tmux](http://robots.thoughtbot.com/a-tmux-crash-course)
configuración:
* Mejora la resolición del color.
* Eliminar desechos administrativos(bombre de sesión, nombre de host, tiempo) en la barra de estatus.
* Establece el prefijo a `Ctrl+s`
* Suaviza el color de la barra de estatus de un verde chillante a un gris claro.
Configuración para [git](http://git-scm.com/):
* Agrega el alias `create-branch` para crear branches.
* Agrega el alias `delete-branch` para borrar branches.
* Agrega el alias `merge-branch` para fusionar los branches en master.
* Agrega el alias `up` para buscar y rebasar `origin/master` en el branch.
Usa `git up -i` para rebases interactivos.
* Agrega el hook `post-{checkout,commit,merge}` para re-indexar tus ctags.
* Agrega `pre-commit` y `prepare-commit-msg` stubs que delegan hacia tu
configuración local.
* Agrega el alias `trust-bin` para anexar el `bin/` de un proyecto al `$PATH`.
Configuración de [Ruby](https://www.ruby-lang.org/en/):
* Agrega binstubs confiables al `PATH`.
* Descarga el administrador de versiones ASDF.
Alias de Shell y scripts:
* `b` para `bundle`.
* `g` sin argumentos es `git status` y con argumentos funciona como `git`.
* `migrate` para `bin/rails db:migrate db:rollback && bin/rails db:migrate db:test:prepare`.
* `mcd` para crear un directorio e ir a él.
* `replace foo bar **/*.rb` para buscar y reemplazar en una lista dada de archivos.
* `tat` para adjuntar a una sesión de tmux llamada igual que el directorio actual.
* `v` para `$VISUAL`.
Gracias
-------
Gracias [Contribuyentes](https://github.com/thoughtbot/dotfiles/contributors)!
Además, gracias a Corey Haines, Gary Bernhardt, y otros por compartir sus dotfiles
y otros scripts de shell que derivaron en la inspiración para los artículos
en este proyecto.
Licencia
--------
dotfiles está protegida por copyright © 2009-2017 thoughtbot. Es un software gratis, y tal vez
redistribuido bajo los términos especificados en el archivo de la [`LICENCIA`]
[`LICENCIA`]: /LICENSE
Acerca de thoughtbot
--------------------
![thoughtbot](http://presskit.thoughtbot.com/images/thoughtbot-logo-for-readmes.svg)
dotfiles es mantenido y creado por thoughtbot, inc.
Los nombres y los logos de thoughtbot son marca registrada de thoughtbot, inc.
Amamos el código de fuente abiarta!
Ve [nuestros otros proyectos][community].
Estamos [disponibles para ser contratados][hire].
[community]: https://thoughtbot.com/community?utm_source=github
[hire]: https://thoughtbot.com/hire-us?utm_source=github

View file

@ -1,6 +1,10 @@
thoughtbot dotfiles
Dotfiles
===================
> A part of these dotfiles is based on the dotfiles of the **[Thoughtbot]** organization and we made changes to it. Thanks to the **[Thoughtbot]** organization.
[Thoughtbot]: https://github.com/Thoughtbot
![prompt](http://images.thoughtbot.com/thoughtbot-dotfiles-prompt.png)
Requirements
@ -15,7 +19,7 @@ Install
Clone onto your laptop:
git clone git@github.com:thoughtbot/dotfiles.git ~/dotfiles
git clone git@github.com:parchlinux/dotfiles.git ~/dotfiles
(Or, [fork and keep your fork
updated](http://robots.thoughtbot.com/keeping-a-github-fork-updated)).
@ -31,13 +35,13 @@ Install the dotfiles:
After the initial installation, you can run `rcup` without the one-time variable
`RCRC` being set (`rcup` will symlink the repo's `rcrc` to `~/.rcrc` for future
runs of `rcup`). [See
example](https://github.com/thoughtbot/dotfiles/blob/master/rcrc).
example](https://github.com/parchlinux/dotfiles/blob/master/rcrc).
This command will create symlinks for config files in your home directory.
Setting the `RCRC` environment variable tells `rcup` to use standard
configuration options:
* Exclude the `README.md`, `README-ES.md` and `LICENSE` files, which are part of
* Exclude the `README.md` and `LICENSE` files, which are part of
the `dotfiles` repository but do not need to be symlinked in.
* Give precedence to personal overrides which by default are placed in
`~/dotfiles-local`
@ -66,6 +70,7 @@ Create a directory for your personal customizations:
Put your customizations in `~/dotfiles-local` appended with `.local`:
* `~/dotfiles-local/aliases.local`
* `~/dotfiles-local/functions.local`
* `~/dotfiles-local/git_template.local/*`
* `~/dotfiles-local/gitconfig.local`
* `~/dotfiles-local/psqlrc.local` (we supply a blank `.psqlrc.local` to prevent `psql` from
@ -245,18 +250,3 @@ dotfiles is copyright © 2009-2018 thoughtbot. It is free software, and may be
redistributed under the terms specified in the [`LICENSE`] file.
[`LICENSE`]: /LICENSE
About thoughtbot
----------------
![thoughtbot](http://presskit.thoughtbot.com/images/thoughtbot-logo-for-readmes.svg)
dotfiles is maintained and funded by thoughtbot, inc.
The names and logos for thoughtbot are trademarks of thoughtbot, inc.
We love open source software!
See [our other projects][community].
We are [available for hire][hire].
[community]: https://thoughtbot.com/community?utm_source=github
[hire]: https://thoughtbot.com/hire-us?utm_source=github

66
local/aliases.local Normal file
View file

@ -0,0 +1,66 @@
#!/usr/bin/env zsh
## root privileges
alias doas="doas --"
## vim and emacs
alias vi=vim
alias em="/usr/bin/emacs -nw"
alias emacs="emacsclient -c -a 'emacs'"
## doomemacs
alias doomsync="~/.emacs.d/bin/doom sync"
alias doomdoctor="~/.emacs.d/bin/doom doctor"
alias doomupgrade="~/.emacs.d/bin/doom upgrade"
alias doompurge="~/.emacs.d/bin/doom purge"
## add color to grep(s)
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
## confirm before overwriting something
alias cp="cp -i"
alias mv='mv -i'
alias rm='rm -i'
# alias "l" to exa with icons
alias l='exa -lah --git --icons'
## cp/mv with progress bar
alias cpg="cpg -g"
alias mvg="mvg -g"
## human-readable sizes
alias free='free -h'
alias df='df -h'
alias du='du -h'
## xdg
alias open='xdg-open'
## Terminals' command
if [ -f `which kitty` ]; then
## show img in terminal
alias icat="kitty +kitten icat"
## connect via ssh
alias issh="kitty +kitten ssh"
fi
# youtube-dl
alias yta-aac="youtube-dl --extract-audio --audio-format aac "
alias yta-best="youtube-dl --extract-audio --audio-format best "
alias yta-flac="youtube-dl --extract-audio --audio-format flac "
alias yta-m4a="youtube-dl --extract-audio --audio-format m4a "
alias yta-mp3="youtube-dl --extract-audio --audio-format mp3 "
alias yta-opus="youtube-dl --extract-audio --audio-format opus "
alias yta-vorbis="youtube-dl --extract-audio --audio-format vorbis "
alias yta-wav="youtube-dl --extract-audio --audio-format wav "
alias ytv-best="youtube-dl -f bestvideo+bestaudio "
# switch between shells
alias tobash="sudo chsh $USER -s /bin/bash && echo 'Now log out.'"
alias tozsh="sudo chsh $USER -s /bin/zsh && echo 'Now log out.'"
alias tofish="sudo chsh $USER -s /bin/fish && echo 'Now log out.'"

6
local/zshrc.local Normal file
View file

@ -0,0 +1,6 @@
#!/usr/bin/env zsh
## BASH INSULTER (works in zsh though)
if [ -f /etc/bash.command-not-found ]; then
. /etc/bash.command-not-found
fi

21
zsh/aliases.zsh Normal file
View file

@ -0,0 +1,21 @@
# Unix
alias ll="ls -al"
alias ln="ln -v"
alias mkdir="mkdir -p"
alias e="$EDITOR"
alias v="$VISUAL"
# Bundler
alias b="bundle"
# Rails
alias migrate="bin/rails db:migrate db:rollback && bin/rails db:migrate db:test:prepare"
alias s="rspec"
# Pretty print the path
alias path='echo $PATH | tr -s ":" "\n"'
# Include custom aliases
if [[ -f ~/.aliases.local ]]; then
source ~/.aliases.local
fi

116
zsh/functions.zsh Normal file
View file

@ -0,0 +1,116 @@
##########################
####### functions ########
##########################
SAVEIFS=$IFS
IFS=$(echo -en "")
function extract {
if [ -z "$1" ]; then
# display usage if no parameters given
echo "Usage: extract <path/file_name>.<zip|rar|bz2|gz|tar|tbz2|tgz|Z|7z|xz|ex|tar.bz2|tar.gz|tar.xz>"
echo " extract <path/file_name_1.ext> [path/file_name_2.ext] [path/file_name_3.ext]"
else
for n in "$@"
do
if [ -f "$n" ] ; then
case "${n%,}" in
*.cbt|*.tar.bz2|*.tar.gz|*.tar.xz|*.tbz2|*.tgz|*.txz|*.tar)
tar xvf "$n" ;;
*.lzma) unlzma ./"$n" ;;
*.bz2) bunzip2 ./"$n" ;;
*.cbr|*.rar) unrar x -ad ./"$n" ;;
*.gz) gunzip ./"$n" ;;
*.cbz|*.epub|*.zip) unzip ./"$n" ;;
*.z) uncompress ./"$n" ;;
*.7z|*.arj|*.cab|*.cb7|*.chm|*.deb|*.dmg|*.iso|*.lzh|*.msi|*.pkg|*.rpm|*.udf|*.wim|*.xar)
7z x ./"$n" ;;
*.xz) unxz ./"$n" ;;
*.exe) cabextract ./"$n" ;;
*.cpio) cpio -id < ./"$n" ;;
*.cba|*.ace) unace x ./"$n" ;;
*)
echo "extract: '$n' - unknown archive method"
return 1
;;
esac
else
echo "'$n' - file does not exist"
return 1
fi
done
fi
}
# navigation
up () {
local d=""
local limit="$1"
# Default to limit of 1
if [ -z "$limit" ] || [ "$limit" -le 0 ]; then
limit=1
fi
for ((i=1;i<=limit;i++)); do
d="../$d"
done
# perform cd. Show error if cd fails
if ! cd "$d"; then
echo "Couldn't go up $limit dirs.";
fi
}
# python virtualenv
venv(){
if [ -f .venv/bin/activate ]; then
source .venv/bin/activate
else
virtualenv .venv && source .venv/bin/activate
fi
}
# Make directory and change into it.
function mcd() {
mkdir -p "$1" && cd "$1";
}
# Change file extensions recursively in current directory
#
# change-extension erb haml
function change-extension() {
foreach f (**/*.$1)
mv $f $f:r.$2
end
}
# Load .env file into shell session for environment variables
function envup() {
if [ -f .env ]; then
export $(sed '/^ *#/ d' .env)
else
echo 'No .env file found' 1>&2
return 1
fi
}
# No arguments: `git status`
# With arguments: acts like `git`
g() {
if [[ $# -gt 0 ]]; then
git "$@"
else
git status
fi
}
_git_delete_branch ()
{
__gitcomp "$(__git_heads)"
}
# Include custom functions
if [[ -f ~/.functions.local ]]; then
source ~/.functions.local
fi

View file

@ -1,4 +0,0 @@
_git_delete_branch ()
{
__gitcomp "$(__git_heads)"
}

View file

@ -1,9 +0,0 @@
# Change file extensions recursively in current directory
#
# change-extension erb haml
function change-extension() {
foreach f (**/*.$1)
mv $f $f:r.$2
end
}

View file

@ -1,10 +0,0 @@
# Load .env file into shell session for environment variables
function envup() {
if [ -f .env ]; then
export $(sed '/^ *#/ d' .env)
else
echo 'No .env file found' 1>&2
return 1
fi
}

View file

@ -1,9 +0,0 @@
# No arguments: `git status`
# With arguments: acts like `git`
g() {
if [[ $# -gt 0 ]]; then
git "$@"
else
git status
fi
}

View file

@ -1,5 +0,0 @@
# Make directory and change into it.
function mcd() {
mkdir -p "$1" && cd "$1";
}

42
zshrc
View file

@ -1,7 +1,37 @@
# load custom executable functions
for function in ~/.zsh/functions/*; do
source $function
done
#!/usr/bin/env zsh
ZSH_PATH=$HOME/.zsh
#########################
######### PATH ##########
#########################
if [ -d "$HOME/.bin" ] ;
then PATH="$HOME/.bin:$PATH"
fi
if [ -d "$HOME/.local/bin" ] ;
then PATH="$HOME/.local/bin:$PATH"
fi
if [ -d "$HOME/Applications" ] ;
then PATH="$HOME/Applications:$PATH"
fi
if [ -d "$HOME/.cargo/bin" ]
then PATH="$HOME/.cargo/bin:$PATH"
fi
# Comment this line out to enable default emacs-like bindings
bindkey -v
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
# functions
[[ -f "$ZSH_PATH/functions.zsh" ]] && source $ZSH_PATH/functions.zsh
# extra files in ~/.zsh/configs/pre , ~/.zsh/configs , and ~/.zsh/configs/post
# these are loaded first, second, and third, respectively.
@ -32,10 +62,10 @@ _load_settings() {
fi
fi
}
_load_settings "$HOME/.zsh/configs"
_load_settings "$ZSH_PATH/configs"
# Local config
[[ -f ~/.zshrc.local ]] && source ~/.zshrc.local
# aliases
[[ -f ~/.aliases ]] && source ~/.aliases
[[ -f "$ZSH_PATH/aliases.zsh" ]] && source "$ZSH_PATH/aliases.zsh"