Ver Fonte

feat(Personal): Add personal files

Signed-off-by: Jeremy MAURO <jeremy.mauro@gmail.com>
Jeremy MAURO há 2 anos atrás
pai
commit
386c3c41e0

+ 114 - 0
bashrc.d/00_debian_skel.bash

@@ -0,0 +1,114 @@
+# ~/.bashrc: executed by bash(1) for non-login shells.
+# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
+# for examples
+# NOTE: This file is taken from '/etc/skel'
+
+# If not running interactively, don't do anything
+case $- in
+    *i*) ;;
+      *) return;;
+esac
+
+# don't put duplicate lines or lines starting with space in the history.
+# See bash(1) for more options
+HISTCONTROL=ignoreboth
+
+# append to the history file, don't overwrite it
+shopt -s histappend
+
+# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
+HISTSIZE=1000
+HISTFILESIZE=2000
+
+# check the window size after each command and, if necessary,
+# update the values of LINES and COLUMNS.
+shopt -s checkwinsize
+
+# If set, the pattern "**" used in a pathname expansion context will
+# match all files and zero or more directories and subdirectories.
+#shopt -s globstar
+
+# make less more friendly for non-text input files, see lesspipe(1)
+#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
+
+# set variable identifying the chroot you work in (used in the prompt below)
+if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
+    debian_chroot=$(cat /etc/debian_chroot)
+fi
+
+# set a fancy prompt (non-color, unless we know we "want" color)
+case "$TERM" in
+    xterm-color|*-256color) color_prompt=yes;;
+esac
+
+# uncomment for a colored prompt, if the terminal has the capability; turned
+# off by default to not distract the user: the focus in a terminal window
+# should be on the output of commands, not on the prompt
+#force_color_prompt=yes
+
+if [ -n "$force_color_prompt" ]; then
+    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
+	# We have color support; assume it's compliant with Ecma-48
+	# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
+	# a case would tend to support setf rather than setaf.)
+	color_prompt=yes
+    else
+	color_prompt=
+    fi
+fi
+
+if [ "$color_prompt" = yes ]; then
+    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
+else
+    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
+fi
+unset color_prompt force_color_prompt
+
+# If this is an xterm set the title to user@host:dir
+case "$TERM" in
+xterm*|rxvt*)
+    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
+    ;;
+*)
+    ;;
+esac
+
+# enable color support of ls and also add handy aliases
+if [ -x /usr/bin/dircolors ]; then
+    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
+    alias ls='ls --color=auto'
+    #alias dir='dir --color=auto'
+    #alias vdir='vdir --color=auto'
+
+    #alias grep='grep --color=auto'
+    #alias fgrep='fgrep --color=auto'
+    #alias egrep='egrep --color=auto'
+fi
+
+# colored GCC warnings and errors
+#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
+
+# some more ls aliases
+#alias ll='ls -l'
+#alias la='ls -A'
+#alias l='ls -CF'
+
+# Alias definitions.
+# You may want to put all your additions into a separate file like
+# ~/.bash_aliases, instead of adding them here directly.
+# See /usr/share/doc/bash-doc/examples in the bash-doc package.
+
+if [ -f ~/.bash_aliases ]; then
+    . ~/.bash_aliases
+fi
+
+# enable programmable completion features (you don't need to enable
+# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
+# sources /etc/bash.bashrc).
+if ! shopt -oq posix; then
+  if [ -f /usr/share/bash-completion/bash_completion ]; then
+    . /usr/share/bash-completion/bash_completion
+  elif [ -f /etc/bash_completion ]; then
+    . /etc/bash_completion
+  fi
+fi

+ 57 - 0
bashrc.d/00_superseed_debian.bash

@@ -0,0 +1,57 @@
+HISTFILESIZE=2000000
+
+# If set, the pattern "**" used in a pathname expansion context will
+# match all files and zero or more directories and subdirectories.
+#shopt -s globstar
+
+# make less more friendly for non-text input files, see lesspipe(1)
+[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
+
+# uncomment for a colored prompt, if the terminal has the capability; turned
+# off by default to not distract the user: the focus in a terminal window
+# should be on the output of commands, not on the prompt
+force_color_prompt=yes
+
+if [ -n "$force_color_prompt" ]; then
+    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
+	# We have color support; assume it's compliant with Ecma-48
+	# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
+	# a case would tend to support setf rather than setaf.)
+	color_prompt=yes
+    else
+	color_prompt=
+    fi
+fi
+
+if [ "$color_prompt" = yes ]; then
+    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
+else
+    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
+fi
+unset color_prompt force_color_prompt
+
+# If this is an xterm set the title to user@host:dir
+case "$TERM" in
+xterm*|rxvt*)
+    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
+    ;;
+*)
+    ;;
+esac
+
+# enable color support of ls and also add handy aliases
+if [ -x /usr/bin/dircolors ]; then
+    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
+    alias ls='ls --color=auto'
+    alias dir='dir --color=auto'
+    alias vdir='vdir --color=auto'
+
+    alias grep='grep --color=auto'
+    alias fgrep='fgrep --color=auto'
+    alias egrep='egrep --color=auto'
+fi
+
+# some more ls aliases
+alias ll='ls -l'
+alias la='ls -A'
+alias l='ls -CF'

+ 14 - 0
bashrc.d/01_mcfly.bash

@@ -0,0 +1,14 @@
+# Customization for mcfly tools:
+# Ref: https://github.com/cantino/mcfly
+
+# Set VIM Key Scheme
+export MCFLY_KEY_SCHEME=vim
+
+# Results Count
+export MCFLY_RESULTS=50
+
+# Result sorting (RANK vs LAST_RUN)
+export MCFLY_RESULTS_SORT=LAST_RUN
+
+# Loads mcfly
+eval "$(mcfly init bash)"

+ 8 - 0
bashrc.d/01_zoxide.bash

@@ -0,0 +1,8 @@
+# zoxide is a smarter cd command, inspired by z and autojump.
+# Ref: https://github.com/ajeetdsouza/zoxide
+
+# Specifies the directory in which the database is stored.
+export _ZO_DATA_DIR=${XDG_DATA_HOME}
+
+# Launches zoxide
+eval "$(zoxide init bash --cmd cd)"

+ 4 - 0
bashrc.d/02_direnv.bash

@@ -0,0 +1,4 @@
+# direnv is an extension for your shell. It augments existing shells with a new feature that can load and unload environment variables depending on the current directory.
+
+# Hook installation
+eval "$(direnv hook bash)"

+ 8 - 0
bashrc.d/03_powerline.bash

@@ -0,0 +1,8 @@
+# Powerline is a statusline plugin for vim, and provides statuslines and prompts for several other applications, including zsh, bash, tmux, IPython, Awesome, i3 and Qtile.
+# Ref: https://powerline.readthedocs.io/en/latest/index.html
+
+powerline-daemon -q
+POWERLINE_BASH_CONTINUATION=1
+POWERLINE_BASH_SELECT=1
+. /usr/share/powerline/bindings/bash/powerline.sh
+

+ 36 - 0
bashrc.d/05_colors.bash

@@ -0,0 +1,36 @@
+# Ref: https://misc.flogisoft.com/bash/tip_colors_and_formatting
+NF="\e[0m"
+BLACK="\e[30m"
+BLUE="\e[34m"
+CYAN="\e[36m"
+DARK_GRAY="\e[90m"
+GREEN="\e[32m"
+LIGHT_BLUE="\e[94m"
+LIGHT_CYAN="\e[96m"
+LIGHT_GRAY="\e[37m"
+LIGHT_GREEN="\e[92m"
+LIGHT_MAGENTA="\e[95m"
+LIGHT_RED="\e[91m"
+LIGHT_YELLOW="\e[93m"
+MAGENTA="\e[35m"
+RED="\e[31m"
+YELLOW="\e[33m"
+WHITE="\e[97m"
+
+export NF \
+  BLACK \
+  BLUE \
+  CYAN \
+  DARK_GRAY \
+  GREEN \
+  MAGENTA \
+  LIGHT_BLUE \
+  LIGHT_CYAN \
+  LIGHT_GRAY \
+  LIGHT_GREEN \
+  LIGHT_MAGENTA \
+  LIGHT_RED \
+  LIGHT_YELLOW \
+  RED \
+  YELLOW \
+  WHITE

+ 9 - 0
bashrc.d/10_ruby.bash

@@ -0,0 +1,9 @@
+# Set ruby environment
+if [ ! -v RENV_ORIG_PATH ] && [ -d ${HOME}/repo/renv ]; then
+  . ${HOME}/repo/renv/renv.sh
+  renv
+fi
+
+if [ -d ${HOME}/repo/bundler-exec ]; then
+  . ${HOME}/repo/bundler-exec/bundler-exec.sh
+fi

+ 1 - 0
login.d/00_editor.sh

@@ -0,0 +1 @@
+../rc.d/00_editor.sh

+ 1 - 0
login.d/00_systemd_user.sh

@@ -0,0 +1 @@
+../rc.d/00_systemd_user.sh

+ 3 - 0
rc.d/00_editor.sh

@@ -0,0 +1,3 @@
+EDITOR=${EDITOR:-vi}
+
+export EDITOR

+ 3 - 0
rc.d/00_golang.sh

@@ -0,0 +1,3 @@
+GOPATH=${GOPATH:-${HOME}/go}
+
+export GOPATH=${HOME}/go

+ 9 - 0
rc.d/00_path.sh

@@ -0,0 +1,9 @@
+# set PATH so it includes user's private bin if it exists
+if [ -d "${HOME}/bin" ] ; then
+    PATH="${HOME}/bin:${PATH}"
+fi
+
+# set PATH so it includes user's private bin if it exists
+if [ -d "${HOME}/.local/bin" ] ; then
+    PATH="${HOME}/.local/bin:${PATH}"
+fi

+ 18 - 0
rc.d/00_systemd_user.sh

@@ -0,0 +1,18 @@
+# Environment variable:
+# ref:	https://www.shell-tips.com/bash/environment-variables/#the-user-id-and-group-variables-uid-euid-and-groups
+#       https://wiki.archlinux.org/title/XDG_Base_Directory
+#				https://wiki.archlinux.org/title/Systemd/User#Environment_variables
+#       https://wiki.archlinux.org/title/Environment_variables#Globally
+#       https://in.waw.pl/~zbyszek/blog/environmentd.html
+
+XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-${HOME}/.config}
+XDG_CACHE_HOME=${XDG_CACHE_HOME:-${HOME}/.cache}
+XDG_DATA_HOME=${XDG_DATA_HOME:-${HOME}/.local/share}
+XDG_STATE_HOME=${XDG_STATE_HOME:-${HOME}/.local/state}
+XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR:-/run/user/${UID}}
+
+export XDG_CONFIG_HOME \
+  XDG_CACHE_HOME \
+  XDG_DATA_HOME \
+  XDG_STATE_HOME \
+  XDG_RUNTIME_DIR

+ 67 - 0
rc.d/01_ssh_agent.sh

@@ -0,0 +1,67 @@
+# Ref: https://stackoverflow.com/a/34332776
+#      https://docs.github.com/en/authentication/connecting-to-github-with-ssh/working-with-ssh-key-passphrases#auto-launching-ssh-agent-on-git-for-windows
+#      https://web.archive.org/web/20210506080335/https://mah.everybody.org/docs/ssh
+
+SSH_ENV="${HOME}/.ssh/.agent_env"
+
+function start_agent {
+    echo -n "Initialising new SSH agent..."
+
+    eval `/usr/bin/ssh-agent`
+    echo 'export SSH_AUTH_SOCK'=${SSH_AUTH_SOCK} >  ${SSH_ENV}
+    echo 'export SSH_AGENT_PID'=${SSH_AGENT_PID} >> ${SSH_ENV}
+
+    echo "succeeded"
+    chmod 600 "${SSH_ENV}"
+    . "${SSH_ENV}" > /dev/null
+    add_key
+}
+
+function add_key {
+  /usr/bin/ssh-add -t 86400 $(list_keys)
+}
+
+function list_keys {
+  PRIV_KEYS=""
+  for file in ${HOME}/.ssh/id_*
+  do
+    if grep -q 'PRIVATE' ${file}; then
+      PRIV_KEYS="${PRIV_KEYS} ${file}"
+    fi
+  done
+
+  echo "${PRIV_KEYS}"
+}
+
+# Source SSH settings, if applicable
+if [ -f "${SSH_ENV}" ]; then
+    . "${SSH_ENV}" > /dev/null
+    # agent_run_state: 0=agent running w/ key; 1=agent w/o key; 2=agent not running
+    agent_run_state=$(/usr/bin/ssh-add -l &> /dev/null; echo $?)
+
+    if [ $agent_run_state -eq 2 ]; then
+      start_agent
+    elif [ $agent_run_state -eq 1 ]; then
+      add_key
+    fi
+else
+    start_agent;
+fi
+
+# Create our own hardlink to the socket (with random name)
+MYSOCK=/tmp/ssh_agent.${RANDOM}.sock
+ln --no-target-directory ${SSH_AUTH_SOCK} ${MYSOCK}
+export SSH_AUTH_SOCK=${MYSOCK}
+
+end_agent()
+{
+    # if we are the last holder of a hardlink, then kill the agent
+    nhard=$(ls -l ${SSH_AUTH_SOCK} | awk '{print $2}')
+    if [[ "${nhard}" -eq 2 ]]; then
+        rm ${SSH_ENV}
+        /usr/bin/ssh-agent -k
+    fi
+    rm ${SSH_AUTH_SOCK}
+}
+
+trap end_agent EXIT