commit 702b9bd25e1794fd7620ad667ad1f3ddb6887d81 Author: Hedy Li Date: Thu Dec 24 10:30:03 2020 +0000 i had to re init again nice diff --git a/.bash_profile b/.bash_profile new file mode 100644 index 0000000..db32acf --- /dev/null +++ b/.bash_profile @@ -0,0 +1,132 @@ +# ~/.bashrc: executed by bash(1) for non-login shells. +# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) +# for examples + +# 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\]\n\$ ' +else + PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\n\$ ' +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 -alF' +alias la='ls -A' +alias l='ls -CF' + +# Add an "alert" alias for long running commands. Use like so: +# sleep 10; alert +alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' + +# 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 +# Install Ruby Gems to ~/gems +export GEM_HOME="$HOME/gems" +export PATH="$HOME/gems/bin/:$PATH" + +# my aliases +alias x='exit' +alias clr='clear' +alias bashcrawl='cd ~/bashcrawl/bashcrawl-master/' + + +export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm +[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion + +export PATH="$HOME/.cargo/bin:$PATH" diff --git a/.bashrc b/.bashrc new file mode 100644 index 0000000..81b8857 --- /dev/null +++ b/.bashrc @@ -0,0 +1,124 @@ +# ~/.bashrc: executed by bash(1) for non-login shells. +# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) +# for examples + +# 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 -alF' + alias la='ls -A' + alias l='ls -CF' + + # Add an "alert" alias for long running commands. Use like so: + # sleep 10; alert + alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' + + # 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 + ']]]]' + +export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm +[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion + +[ -f ~/.fzf.bash ] && source ~/.fzf.bash diff --git a/.config/aerc/aerc.conf b/.config/aerc/aerc.conf new file mode 100644 index 0000000..fd5f192 --- /dev/null +++ b/.config/aerc/aerc.conf @@ -0,0 +1,189 @@ +# +# aerc main configuration + +[ui] +# +# Describes the format for each row in a mailbox view. This field is compatible +# with mutt's printf-like syntax. +# +# Default: %D %-17.17n %Z %s +index-format=%D %-17.17n %Z %s + +# +# See time.Time#Format at https://godoc.org/time#Time.Format +# +# Default: 2006-01-02 03:04 PM (ISO 8601 + 12 hour time) +timestamp-format=2006-01-02 03:04 PM + +# +# Width of the sidebar, including the border. +# +# Default: 20 +sidebar-width=20 + +# +# Message to display when viewing an empty folder. +# +# Default: (no messages) +empty-message=(no messages) + +# Message to display when no folders exists or are all filtered +# +# Default: (no folders) +empty-dirlist=(no folders) + +# Enable mouse events in the ui, e.g. clicking and scrolling with the mousewheel +# +# Default: false +mouse-enabled=false + +# +# Ring the bell when new messages are received +# +# Default: true +new-message-bell=true + +# Marker to show before a pinned tab's name. +# +# Default: ` +pinned-tab-marker='`' + +# Describes the format string to use for the directory list +# +# Default: %n %>r +dirlist-format=%n %>r + +# List of space-separated criteria to sort the messages by, see *sort* +# command in *aerc*(1) for reference. Prefixing a criterion with "-r " +# reverses that criterion. +# +# Example: "from -r date" +# +# Default: "" +sort= + +# Moves to next message when the current message is deleted +# +# Default: true +next-message-on-delete=true + +[viewer] +# +# Specifies the pager to use when displaying emails. Note that some filters +# may add ANSI codes to add color to rendered emails, so you may want to use a +# pager which supports ANSI codes. +# +# Default: less -R +pager=less -R + +# +# If an email offers several versions (multipart), you can configure which +# mimetype to prefer. For example, this can be used to prefer plaintext over +# html emails. +# +# Default: text/plain,text/html +alternatives=text/plain,text/html + +# +# Default setting to determine whether to show full headers or only parsed +# ones in message viewer. +# +# Default: false +show-headers=false + +# +# Layout of headers when viewing a message. To display multiple headers in the +# same row, separate them with a pipe, e.g. "From|To". Rows will be hidden if +# none of their specified headers are present in the message. +# +# Default: From|To,Cc|Bcc,Date,Subject +header-layout=From|To,Cc|Bcc,Date,Subject + +# Whether to always show the mimetype of an email, even when it is just a single part +# +# Default: false +always-show-mime=false + +# How long to wait after the last input before auto-completion is triggered. +# +# Default: 250ms +completion-delay=250ms + +# +# Global switch for completion popovers +# +# Default: true +completion-popovers=true + +[compose] +# +# Specifies the command to run the editor with. It will be shown in an embedded +# terminal, though it may also launch a graphical window if the environment +# supports it. Defaults to $EDITOR, or vi. +editor= + +# +# Default header fields to display when composing a message. To display +# multiple headers in the same row, separate them with a pipe, e.g. "To|From". +# +# Default: To|From,Subject +header-layout=To|From,Subject + +# +# Specifies the command to be used to tab-complete email addresses. Any +# occurrence of "%s" in the address-book-cmd will be replaced with what the +# user has typed so far. +# +# The command must output the completions to standard output, one completion +# per line. Each line must be tab-delimited, with an email address occurring as +# the first field. Only the email address field is required. The second field, +# if present, will be treated as the contact name. Additional fields are +# ignored. +address-book-cmd= + +[filters] +# +# Filters allow you to pipe an email body through a shell command to render +# certain emails differently, e.g. highlighting them with ANSI escape codes. +# +# The first filter which matches the email's mimetype will be used, so order +# them from most to least specific. +# +# You can also match on non-mimetypes, by prefixing with the header to match +# against (non-case-sensitive) and a comma, e.g. subject,text will match a +# subject which contains "text". Use header,~regex to match against a regex. +subject,~^\[PATCH=awk -f /usr/local/share/aerc/filters/hldiff +#text/html=/usr/local/share/aerc/filters/html +text/*=awk -f /usr/local/share/aerc/filters/plaintext +#image/*=catimg -w $(tput cols) - + +[triggers] +# +# Triggers specify commands to execute when certain events occur. +# +# Example: +# new-email=exec notify-send "New email from %n" "%s" + +# +# Executed when a new email arrives in the selected folder +new-email= + +[templates] +# Templates are used to populate email bodies automatically. +# + +# The directories where the templates are stored. It takes a colon-separated +# list of directories. +# +# default: /usr/local/share/aerc/templates/ +template-dirs=/usr/local/share/aerc/templates/ + +# The template to be used for quoted replies. +# +# default: quoted_reply +quoted-reply=quoted_reply + +# The template to be used for forward as body. +# +# default: forward_as_body +forwards=forward_as_body diff --git a/.config/aerc/binds.conf b/.config/aerc/binds.conf new file mode 100644 index 0000000..abfd77e --- /dev/null +++ b/.config/aerc/binds.conf @@ -0,0 +1,103 @@ +# Binds are of the form = +# To use '=' in a key sequence, substitute it with "Eq": "" +# If you wish to bind #, you can wrap the key sequence in quotes: "#" = quit + = :prev-tab + = :next-tab + = :term + +[messages] +q = :quit + +j = :next + = :next + = :next 50% + = :next 100% + = :next -s 100% + +k = :prev + = :prev + = :prev 50% + = :prev 100% + = :prev -s 100% +g = :select 0 +G = :select -1 + +J = :next-folder +K = :prev-folder + +v = :mark -t +V = :mark -v + + = :view +d = :prompt 'Really delete this message?' 'delete-message' +D = :delete +A = :archive flat + +C = :compose + +rr = :reply -a +rq = :reply -aq +Rr = :reply +Rq = :reply -q + +c = :cf +$ = :term +! = :term +| = :pipe + +/ = :search +\ = :filter +n = :next-result +N = :prev-result + +[view] +q = :close +| = :pipe +D = :delete +S = :save +A = :archive flat + +f = :forward +rr = :reply -a +rq = :reply -aq +Rr = :reply +Rq = :reply -q + +H = :toggle-headers + = :prev-part + = :next-part +J = :next +K = :prev + +[compose] +# Keybindings used when the embedded terminal is not selected in the compose +# view +$ex = + = :prev-field + = :next-field + = :next-field + +[compose::editor] +# Keybindings used when the embedded terminal is selected in the compose view +$noinherit = true +$ex = + = :prev-field + = :next-field + = :prev-tab + = :next-tab + +[compose::review] +# Keybindings used when reviewing a message to be sent +y = :send +n = :abort +p = :postpone +q = :abort +e = :edit +a = :attach + +[terminal] +$noinherit = true +$ex = + + = :prev-tab + = :next-tab diff --git a/.config/fish/config.fish b/.config/fish/config.fish new file mode 100644 index 0000000..de6a1e6 --- /dev/null +++ b/.config/fish/config.fish @@ -0,0 +1,4 @@ +bass 'export GEM_HOME=$HOME/gems' +bass 'export BROWSER=w3m' +set -g __fish_git_prompt_char_cleanstate "=" +umask 0002 diff --git a/.config/fish/functions/apt-up.fish b/.config/fish/functions/apt-up.fish new file mode 100644 index 0000000..1610a87 --- /dev/null +++ b/.config/fish/functions/apt-up.fish @@ -0,0 +1,6 @@ +function apt-up + sudo apt update && sudo apt upgrade -y + sudo apt-get dist-upgrade -y + sudo apt autoremove +end + diff --git a/.config/fish/functions/clr.fish b/.config/fish/functions/clr.fish new file mode 100644 index 0000000..891da6c --- /dev/null +++ b/.config/fish/functions/clr.fish @@ -0,0 +1,4 @@ +# Defined in - @ line 1 +function clr --wraps=clear --description 'alias clr=clear' + clear $argv; +end diff --git a/.config/fish/functions/cprac.fish b/.config/fish/functions/cprac.fish new file mode 100644 index 0000000..0b00c9b --- /dev/null +++ b/.config/fish/functions/cprac.fish @@ -0,0 +1,18 @@ +function cprac + if test -e /mnt/c/Users/hedyh/codeprac/ + set -gx cprac_path /mnt/c/Users/hedyh/codeprac/ + else + echo "codeprac path not found, please enter path: " + read -gx cprac_path + end + if string length -q -- $argv + if test -e $cprac_path$argv[1] + cd $cprac_path$argv[1] + else + cd $cprac_path/*/$argv[1]/ + end + else + cd $cprac_path + end +end + diff --git a/.config/fish/functions/cproj.fish b/.config/fish/functions/cproj.fish new file mode 100644 index 0000000..fba5114 --- /dev/null +++ b/.config/fish/functions/cproj.fish @@ -0,0 +1,14 @@ +function cproj + if test -e /mnt/c/Users/hedyh/codeproj/ + set -gx cproj_path /mnt/c/Users/hedyh/codeproj/ + else + echo "codeproj path not found, please enter path" + read -gx cproj_path + end + if string length -q -- $argv + cd $cproj_path$argv[1] + else + cd $cproj_path + end +end + diff --git a/.config/fish/functions/fish_greeting.fish b/.config/fish/functions/fish_greeting.fish new file mode 100644 index 0000000..8115ec1 --- /dev/null +++ b/.config/fish/functions/fish_greeting.fish @@ -0,0 +1,3 @@ +function fish_greeting + echo lol +end diff --git a/.config/fish/functions/fish_prompt.1588078327.copy b/.config/fish/functions/fish_prompt.1588078327.copy new file mode 100644 index 0000000..c4caae0 --- /dev/null +++ b/.config/fish/functions/fish_prompt.1588078327.copy @@ -0,0 +1,84 @@ +function fish_prompt --description 'Write out the prompt' + set -l last_pipestatus $pipestatus + + if not set -q __fish_git_prompt_show_informative_status + set -g __fish_git_prompt_show_informative_status 1 + end + if not set -q __fish_git_prompt_hide_untrackedfiles + set -g __fish_git_prompt_hide_untrackedfiles 1 + end + if not set -q __fish_git_prompt_color_branch + set -g __fish_git_prompt_color_branch magenta --bold + end + if not set -q __fish_git_prompt_showupstream + set -g __fish_git_prompt_showupstream "informative" + end + if not set -q __fish_git_prompt_char_upstream_ahead + set -g __fish_git_prompt_char_upstream_ahead "↑" + end + if not set -q __fish_git_prompt_char_upstream_behind + set -g __fish_git_prompt_char_upstream_behind "↓" + end + if not set -q __fish_git_prompt_char_upstream_prefix + set -g __fish_git_prompt_char_upstream_prefix "" + end + if not set -q __fish_git_prompt_char_stagedstate + set -g __fish_git_prompt_char_stagedstate "●" + end + if not set -q __fish_git_prompt_char_dirtystate + set -g __fish_git_prompt_char_dirtystate "✚" + end + if not set -q __fish_git_prompt_char_untrackedfiles + set -g __fish_git_prompt_char_untrackedfiles "…" + end + if not set -q __fish_git_prompt_char_invalidstate + set -g __fish_git_prompt_char_invalidstate "✖" + end + if not set -q __fish_git_prompt_char_cleanstate + set -g __fish_git_prompt_char_cleanstate "✔" + end + if not set -q __fish_git_prompt_color_dirtystate + set -g __fish_git_prompt_color_dirtystate blue + end + if not set -q __fish_git_prompt_color_stagedstate + set -g __fish_git_prompt_color_stagedstate yellow + end + if not set -q __fish_git_prompt_color_invalidstate + set -g __fish_git_prompt_color_invalidstate red + end + if not set -q __fish_git_prompt_color_untrackedfiles + set -g __fish_git_prompt_color_untrackedfiles $fish_color_normal + end + if not set -q __fish_git_prompt_color_cleanstate + set -g __fish_git_prompt_color_cleanstate green --bold + end + + set -l color_cwd + set -l prefix + set -l suffix + switch "$USER" + case root toor + if set -q fish_color_cwd_root + set color_cwd $fish_color_cwd_root + else + set color_cwd $fish_color_cwd + end + set suffix '#' + case '*' + set color_cwd $fish_color_cwd + set suffix '$' + end + + # PWD + set_color $color_cwd + echo -n (prompt_pwd) + set_color normal + + printf '%s ' (fish_vcs_prompt) + + set -l pipestatus_string (__fish_print_pipestatus "[" "] " "|" (set_color $fish_color_status) (set_color --bold $fish_color_status) $last_pipestatus) + echo -n $pipestatus_string + set_color normal + + echo -n "$suffix " +end diff --git a/.config/fish/functions/fish_prompt.fish b/.config/fish/functions/fish_prompt.fish new file mode 100644 index 0000000..96653cb --- /dev/null +++ b/.config/fish/functions/fish_prompt.fish @@ -0,0 +1,84 @@ +function fish_prompt --description 'Write out the prompt' + set -l last_pipestatus $pipestatus + + if not set -q __fish_git_prompt_show_informative_status + set -g __fish_git_prompt_show_informative_status 1 + end + if not set -q __fish_git_prompt_hide_untrackedfiles + set -g __fish_git_prompt_hide_untrackedfiles 1 + end + if not set -q __fish_git_prompt_color_branch + set -g __fish_git_prompt_color_branch magenta --bold + end + if not set -q __fish_git_prompt_showupstream + set -g __fish_git_prompt_showupstream "informative" + end + if not set -q __fish_git_prompt_char_upstream_ahead + set -g __fish_git_prompt_char_upstream_ahead "↑" + end + if not set -q __fish_git_prompt_char_upstream_behind + set -g __fish_git_prompt_char_upstream_behind "↓" + end + if not set -q __fish_git_prompt_char_upstream_prefix + set -g __fish_git_prompt_char_upstream_prefix "" + end + if not set -q __fish_git_prompt_char_stagedstate + set -g __fish_git_prompt_char_stagedstate "●" + end + if not set -q __fish_git_prompt_char_dirtystate + set -g __fish_git_prompt_char_dirtystate "✚" + end + if not set -q __fish_git_prompt_char_untrackedfiles + set -g __fish_git_prompt_char_untrackedfiles "…" + end + if not set -q __fish_git_prompt_char_invalidstate + set -g __fish_git_prompt_char_invalidstate "✖" + end + if not set -q __fish_git_prompt_char_cleanstate + set -g __fish_git_prompt_char_cleanstate "=" + end + if not set -q __fish_git_prompt_color_dirtystate + set -g __fish_git_prompt_color_dirtystate blue + end + if not set -q __fish_git_prompt_color_stagedstate + set -g __fish_git_prompt_color_stagedstate yellow + end + if not set -q __fish_git_prompt_color_invalidstate + set -g __fish_git_prompt_color_invalidstate red + end + if not set -q __fish_git_prompt_color_untrackedfiles + set -g __fish_git_prompt_color_untrackedfiles $fish_color_normal + end + if not set -q __fish_git_prompt_color_cleanstate + set -g __fish_git_prompt_color_cleanstate green --bold + end + + set -l color_cwd + set -l prefix + set -l suffix + switch "$USER" + case root toor + if set -q fish_color_cwd_root + set color_cwd $fish_color_cwd_root + else + set color_cwd $fish_color_cwd + end + set suffix '#' + case '*' + set color_cwd $fish_color_cwd + set suffix '$' + end + + # PWD + set_color $color_cwd + echo -n (prompt_pwd) + set_color normal + + printf '%s ' (fish_vcs_prompt) + + set -l pipestatus_string (__fish_print_pipestatus "[" "] " "|" (set_color $fish_color_status) (set_color --bold $fish_color_status) $last_pipestatus) + echo -n $pipestatus_string + set_color normal + + echo -n "$suffix " +end diff --git a/.config/fish/functions/getpyjoke.fish b/.config/fish/functions/getpyjoke.fish new file mode 100644 index 0000000..6908e43 --- /dev/null +++ b/.config/fish/functions/getpyjoke.fish @@ -0,0 +1,4 @@ +# Defined in - @ line 1 +function getpyjoke --wraps=python3\ -c\ \'import\ pyjokes\;\ print\(pyjokes.get_joke\(\)\)\' --description alias\ getpyjoke=python3\ -c\ \'import\ pyjokes\;\ print\(pyjokes.get_joke\(\)\)\' + python3 -c 'import pyjokes; print(pyjokes.get_joke())' $argv; +end diff --git a/.config/fish/functions/gitsimhis.fish b/.config/fish/functions/gitsimhis.fish new file mode 100644 index 0000000..cbd2afb --- /dev/null +++ b/.config/fish/functions/gitsimhis.fish @@ -0,0 +1,17 @@ +function gitsimhis + cd $argv[1] + if read_confirm 'Everything in this directory will be replaced. Do you want to continue? ' + rm -rf * + else + echo 'Aborting...' + return 1 + end + + echo '1' > a + git init && git add . && git commit -m '1' + echo '2' >> a + git add . && git commit -m '2' + echo '3' >> a + git add . && git commit -m '3' +end + diff --git a/.config/fish/functions/hellofish.fish b/.config/fish/functions/hellofish.fish new file mode 100644 index 0000000..5c860fa --- /dev/null +++ b/.config/fish/functions/hellofish.fish @@ -0,0 +1,4 @@ +function hellofish + +end + diff --git a/.config/fish/functions/la.fish b/.config/fish/functions/la.fish new file mode 100644 index 0000000..e7315ee --- /dev/null +++ b/.config/fish/functions/la.fish @@ -0,0 +1,3 @@ +function la --description 'List contents of directory, including hidden files in directory.' + ls -ah $argv +end diff --git a/.config/fish/functions/ll.fish b/.config/fish/functions/ll.fish new file mode 100644 index 0000000..662c3e9 --- /dev/null +++ b/.config/fish/functions/ll.fish @@ -0,0 +1,3 @@ +function ll +exa -lahg --git -t modified $argv +end diff --git a/.config/fish/functions/nvm.fish b/.config/fish/functions/nvm.fish new file mode 100644 index 0000000..43f7033 --- /dev/null +++ b/.config/fish/functions/nvm.fish @@ -0,0 +1,4 @@ +function nvm + bass source ~/.nvm/nvm.sh --no-use ';' nvm $argv +end + diff --git a/.config/fish/functions/q.fish b/.config/fish/functions/q.fish new file mode 100644 index 0000000..ddac583 --- /dev/null +++ b/.config/fish/functions/q.fish @@ -0,0 +1,4 @@ +# Defined in - @ line 1 +function q --wraps=qalc --description 'alias q=qalc' + qalc $argv; +end diff --git a/.config/fish/functions/read_confirm.fish b/.config/fish/functions/read_confirm.fish new file mode 100644 index 0000000..4043aeb --- /dev/null +++ b/.config/fish/functions/read_confirm.fish @@ -0,0 +1,13 @@ +function read_confirm + while true + read -l -P "$argv[1] [y/N] " confirm + + switch $confirm + case Y y + return 0 + case '' N n + return 1 + end + end +end + diff --git a/.config/fish/functions/rm.fish b/.config/fish/functions/rm.fish new file mode 100644 index 0000000..d574c4a --- /dev/null +++ b/.config/fish/functions/rm.fish @@ -0,0 +1,4 @@ +# Defined in - @ line 1 +function rm --wraps=trash --description 'alias rm=trash' + trash $argv; +end diff --git a/.config/fish/functions/td.fish b/.config/fish/functions/td.fish new file mode 100644 index 0000000..ecb4321 --- /dev/null +++ b/.config/fish/functions/td.fish @@ -0,0 +1,4 @@ +# Defined in - @ line 1 +function td --wraps=termdown --description 'alias td=termdown' + termdown $argv; +end diff --git a/.config/fish/functions/x.fish b/.config/fish/functions/x.fish new file mode 100644 index 0000000..51fa9a9 --- /dev/null +++ b/.config/fish/functions/x.fish @@ -0,0 +1,9 @@ +# Defined in - @ line 1 +function x + if test -e ~/.git_creds + if read_confirm 'gitlock?' + gitlock + end + end + exit $argv; +end diff --git a/.config/fish/functions/xo.fish b/.config/fish/functions/xo.fish new file mode 100644 index 0000000..959e016 --- /dev/null +++ b/.config/fish/functions/xo.fish @@ -0,0 +1,7 @@ +# Defined in - @ line 1 +function xo + if test -e ~/.git_creds && read_confirm 'gitlock?' + gitlock + end + exit 0 $argv; +end diff --git a/.config/fish/functions/y.fish b/.config/fish/functions/y.fish new file mode 100644 index 0000000..4753fc9 --- /dev/null +++ b/.config/fish/functions/y.fish @@ -0,0 +1,4 @@ +# Defined in - @ line 1 +function y --wraps=yadm --description 'alias y=yadm' + yadm $argv; +end diff --git a/.config/nvim/coc-settings.json b/.config/nvim/coc-settings.json new file mode 100644 index 0000000..bbbf4dd --- /dev/null +++ b/.config/nvim/coc-settings.json @@ -0,0 +1,3 @@ +{ + "coc.preferences.hoverTarget": "float" +} diff --git a/.config/nvim/ftplugin/fish.vim b/.config/nvim/ftplugin/fish.vim new file mode 100644 index 0000000..5ea07dc --- /dev/null +++ b/.config/nvim/ftplugin/fish.vim @@ -0,0 +1,12 @@ +" Set up :make to use fish for syntax checking. +compiler fish + +" set indent size +set shiftwidth=4 + +" Set this to have long lines wrap inside comments. +setlocal textwidth=79 + +" Enable folding of block structures in fish. +setlocal foldmethod=expr + diff --git a/.config/nvim/functions.vim b/.config/nvim/functions.vim new file mode 100644 index 0000000..e3d4411 --- /dev/null +++ b/.config/nvim/functions.vim @@ -0,0 +1,9 @@ +function! IsWSL() + if has("unix") + let lines = readfile("/proc/version") + if lines[0] =~ "Microsoft" + return 1 + endif + endif + return 0 +endfunction diff --git a/.config/nvim/general.vim b/.config/nvim/general.vim new file mode 100644 index 0000000..c9c4d74 --- /dev/null +++ b/.config/nvim/general.vim @@ -0,0 +1,99 @@ +"""""""""""""""""" +" General settings +" """""""""""""" + +set number +set mouse=a " allow mouse for all +set hlsearch " highlight search +set showcmd " show incomplete commands +set wildmenu " command line's tab complete in a menu +set cursorline " highlight cursor line +set noerrorbells " no beeps +set visualbell " flash screen instead +set title " set window title to file name +set autoindent +set softtabstop=2 " indent by 2 spaces when with tab +set tabstop=4 " show existing tab with 4 spaces width +set shiftwidth=4 +set incsearch " find next match while typing search +set scrolloff=6 " screen lines to keep above and below cursor +set sidescrolloff=8 " screen columns to keep on left and right of cursor +set confirm " display confirmation when closing unsaved file +set encoding=utf-8 " set encoding with Unicode +set showmatch " match brackets when text indecator is over it +set mat=2 " how mny tenths of second to blink when matching brackets +set inccommand=nosplit " neovim only + +" settings required from coc +set hidden +set cmdheight=2 +set updatetime=300 +set shortmess+=c +" Always show the signcolumn, otherwise it would shift the text each time +" diagnostics appear/become resolved. +if has("patch-8.1.1564") + " Recently vim can merge signcolumn and number column into one + set signcolumn=number +else + set signcolumn=yes +endif + + + + +set laststatus=2 " show status line +"set statusline=%F%m%r%h%w%=(%{&ff}/%Y)\ (line\ %l\/%L\ \|\ col\ %c) + +set whichwrap+=<,>,h,l + +"" fold settings +set foldenable +set foldlevelstart=10 +set foldnestmax=10 +set foldmethod=manual +set foldcolumn=2 + + +" set the swp, backup and undo settings +set noswapfile +set nobackup nowritebackup +set undodir=~/.local/share/nvim/undodir/ +set undofile +" +"" Ignore compiled files +set wildignore=*.o,*~,*.pyc +if has("win16") || has("win32") + set wildignore+=.git\*,.hg\*,.svn\* +else + set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store +endif + +" Return to last edit position when opening files (You want +" this!) +au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif +"au ColorScheme * hi Normal ctermbg=None + +"" highlight extra whitespace +match ErrorMsg '\s\+$' + +" setting the shell for fish to sh +"if &shell =~# 'fish$' +" set shell=bash +"endif +" + +if IsWSL() + let g:clipboard = { + \ 'name': 'WSLClip', + \ 'copy': { + \ '+': 'clip.exe', + \ '*': 'clip.exe', + \ }, + \ 'paste': { + \ '+': 'pbpaste', + \ '*': 'pbpaste', + \ }, + \ 'cache_enabled': 0, + \ } +endif + diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim new file mode 100644 index 0000000..1987e1d --- /dev/null +++ b/.config/nvim/init.vim @@ -0,0 +1,8 @@ +set nocompatible +let mapleader=";" " setting leader key to ';' + +source $HOME/.config/nvim/functions.vim +source $HOME/.config/nvim/general.vim +source $HOME/.config/nvim/mappings.vim +source $HOME/.config/nvim/plugins.vim + diff --git a/.config/nvim/mappings.vim b/.config/nvim/mappings.vim new file mode 100644 index 0000000..8b93f4d --- /dev/null +++ b/.config/nvim/mappings.vim @@ -0,0 +1,70 @@ +""""""""""" +" Mappings +"""""""""" +" leader mappings +nnoremap rn :set relativenumber! +nnoremap z zR +nnoremap w :w +nnoremap x :wqa +nnoremap q :qa + +" no highlight - when finished search +nnoremap nh :noh +" paste shortcut below +" must be recursive bcus "+p is aldy mapped above (in WSLYank - paste) +nmap pa "+p +nnoremap rg :registers + +" other mappings +" dot command in visual mode +vnoremap . :normal. + +nnoremap Q :q +" move visual selection +vnoremap J :m '>+1gv=gv +vnoremap K :m '<-2gv=gv + +noremap :m+1== +noremap :m-2== + +noremap :t.== +noremap :t.-1== + +" Visual mode pressing * or # searches for the current selection +" Super useful! From an idea by Michael Naumann +vnoremap * :call VisualSelection('', '')/=@/ +vnoremap # :call VisualSelection('', '')?=@/" + +" Smart way to move between windows +noremap j +noremap k +noremap h +noremap l + +" managing buffers +nnoremap bd :bd +nnoremap bn :bn +nnoremap bp :b + +" Useful mappings for managing tabs +noremap tn :tabnew +noremap to :tabonly +noremap tc :tabclose +noremap tm :tabmove +noremap t :tabnext +noremap bn :bnext +noremap bp :bprev + +" terminal mappings +noremap :split term://fishi +noremap t :split term://fishi +tnoremap + +" command mode mappings +cnoremap PlugInstall +cnoremap Format + +" my commands +command! ReloadConfig so $HOME/.config/nvim/init.vim +nnoremap rc :ReloadConfig + diff --git a/.config/nvim/plugins.vim b/.config/nvim/plugins.vim new file mode 100644 index 0000000..c2abd26 --- /dev/null +++ b/.config/nvim/plugins.vim @@ -0,0 +1,154 @@ +call plug#begin(stdpath('data') . '/plugged') + +Plug 'dracula/vim', {'name': 'dracula'} " dracula color theme +Plug 'preservim/nerdtree' +Plug 'Xuyuanp/nerdtree-git-plugin' +Plug 'prettier/vim-prettier', { 'do': 'npm install' } +Plug 'Yggdroot/indentLine' " indentLine plugin +Plug 'stautob/vim-fish' " fish support for vim +Plug 'jiangmiao/auto-pairs' " auto insert and del quotes in pairs +Plug 'tpope/vim-surround' " quoting and parenthesizing plugin +Plug 'preservim/nerdcommenter' " commenting made simple +Plug 'vim-airline/vim-airline' " airline plugin for status bar +Plug 'mbbill/undotree' " undo tree +Plug 'bling/vim-bufferline' " buffer line +Plug 'tpope/vim-fugitive' +Plug 'ctrlpvim/ctrlp.vim' +Plug 'airblade/vim-gitgutter' +Plug 'majutsushi/tagbar' +Plug 'jreybert/vimagit' +Plug 'neoclide/coc.nvim', {'branch': 'release'} +Plug 'adelarsq/vim-hackernews' +Plug 'laurentgoudet/vim-howdoi' +Plug 'wakatime/vim-wakatime' " wakatime for vim + +call plug#end() + +let g:dracula_colorterm = 0 +colorscheme dracula + +" airline integrations +let g:airline#extensions#tagbar#enabled = 1 + +" open current dir in nerdtree +noremap nf :NERDTreeFind +" open nerdtree when openning a dir in vim +let NERDTreeWinSize = 20 +autocmd vimenter * :NERDTree % +noremap n :NERDTreeToggle % + +" NerdTree Git plugin +let g:NERDTreeGitStatusIndicatorMapCustom = { + \ "Modified" : "M", + \ "Staged" : "A", + \ "Untracked" : "?", + \ "Renamed" : "R", + \ "Unmerged" : "═", + \ "Deleted" : "D", + \ "Dirty" : "X", + \ "Clean" : "✔︎", + \ 'Ignored' : 'i', + \ "Unknown" : "??" + \ } + + +" tagbar +nnoremap tt :TagbarToggle + +" coc-yank +nnoremap y :CocList -A --normal yank + + +" coc settings + +" Use tab for trigger completion with characters ahead and navigate. +" NOTE: Use command ':verbose imap ' to make sure tab is not mapped by +" other plugin before putting this into your config. +inoremap + \ pumvisible() ? "\" : + \ check_back_space() ? "\" : + \ coc#refresh() +inoremap pumvisible() ? "\" : "\" + +function! s:check_back_space() abort + let col = col('.') - 1 + return !col || getline('.')[col - 1] =~# '\s' +endfunction + +" Use to trigger completion. +inoremap coc#refresh() + +" Use to confirm completion, `u` means break undo chain at current +" position. Coc only does snippet and additional edit on confirm. +" could be remapped by other vim plugin, try `:verbose imap `. +if exists('*complete_info') + inoremap complete_info()["selected"] != "-1" ? "\" : "\u\" +else + inoremap pumvisible() ? "\" : "\u\" +endif + +" Use `[g` and `]g` to navigate diagnostics +nmap [g (coc-diagnostic-prev) +nmap ]g (coc-diagnostic-next) + +" GoTo code navigation. +nmap gd (coc-definition) +nmap gy (coc-type-definition) +nmap gi (coc-implementation) +nmap gr (coc-references) + +" Use K to show documentation in preview window. +nnoremap K :call show_documentation() + +function! s:show_documentation() + if (index(['vim','help'], &filetype) >= 0) + execute 'h '.expand('') + else + call CocAction('doHover') + endif +endfunction + +" Highlight the symbol and its references when holding the cursor. +autocmd CursorHold * silent call CocActionAsync('highlight') + +" Symbol renaming. +nmap (coc-rename) + +" Formatting selected code. +xmap f (coc-format-selected) +nmap f (coc-format-selected) + + +" Add `:Format` command to format current buffer. +command! -nargs=0 Format :call CocAction('format') + +" Add `:Fold` command to fold current buffer. +command! -nargs=? Fold :call CocAction('fold', ) + +" Add `:OR` command for organize imports of the current buffer. +command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport') + +" Mappings using CoCList: +" Show all diagnostics. +nnoremap a :CocList diagnostics +" Manage extensions. +nnoremap e :CocList extensions +" Show commands. +nnoremap c :CocList commands +" Find symbol of current document. +nnoremap o :CocList outline +" Search workspace symbols. +nnoremap s :CocList -I symbols +" Do default action for next item. +nnoremap j :CocNext +" Do default action for previous item. +nnoremap k :CocPrev +" Resume latest coc list. +nnoremap p :CocListResume + +" coc-bookmark +nmap bj (coc-bookmark-next) +nmap bk (coc-bookmark-prev) +nmap bt (coc-bookmark-toggle) +nmap ba (coc-bookmark-annotate) + diff --git a/.gitconfig b/.gitconfig new file mode 100644 index 0000000..dacf7fd --- /dev/null +++ b/.gitconfig @@ -0,0 +1,41 @@ +[core] + editor = nvim + autocrlf = input + excludesfile = /home/hedy/.gitignore_global + +[user] + name = Hedy Li + email = hedyhyry@gmail.com + +[alias] + st = status + cm = commit + br = branch + ls-alias = config --get-regexp alias + llog = log --oneline + sst = status -s + ch = checkout + chb = checkout -b + mylog = log --pretty=format:'%C(yellow)%h %C(bold blue)%an, %C(green)%ar: %C(white)"%s"' + lgraph = log --oneline --graph --decorate --all + brd = branch -d + l = log --oneline + fame = !python3 -m gitfame + +[credential] + helper = store --file="$HOME/.git_creds" + helper = cache --timeout 90000 + +[help] + autocorrect = 30 +[pull] + rebase = false +[sendemail] + smtpserver = smtp.gmail.com + smtpuser = hedyhyry@gmail.com + smtpencryption = tls + smtpserverport = 587 + annotate = yes + +[include] + path = ~/.gitconfig-priv diff --git a/.gitignore_global b/.gitignore_global new file mode 100644 index 0000000..a9fbecd --- /dev/null +++ b/.gitignore_global @@ -0,0 +1 @@ +.vim/ diff --git a/.irbrc b/.irbrc new file mode 100644 index 0000000..b1d6737 --- /dev/null +++ b/.irbrc @@ -0,0 +1 @@ +IRB.conf[:PROMPT_MODE] = :SIMPLE diff --git a/.profile b/.profile new file mode 100644 index 0000000..2b83a62 --- /dev/null +++ b/.profile @@ -0,0 +1,30 @@ +# ~/.profile: executed by the command interpreter for login shells. +# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login +# exists. +# see /usr/share/doc/bash/examples/startup-files for examples. +# the files are located in the bash-doc package. + +# the default umask is set in /etc/profile; for setting the umask +# for ssh logins, install and configure the libpam-umask package. +#umask 022 + +# if running bash +if [ -n "$BASH_VERSION" ]; then + # include .bashrc if it exists + if [ -f "$HOME/.bashrc" ]; then + . "$HOME/.bashrc" + fi +fi + +# 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 +eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv) + +export PATH="$HOME/.cargo/bin:$PATH" diff --git a/.vimrc b/.vimrc new file mode 100644 index 0000000..0cf3310 --- /dev/null +++ b/.vimrc @@ -0,0 +1,183 @@ +set nocompatible + +"""""""""""""""" +" Vundle Plugins +"""""""""""""""" +filetype off +set rtp+=~/.vim/bundle/Vundle.vim +call vundle#begin() + +Plugin 'VundleVim/Vundle.vim' +Plugin 'dracula/vim', {'name': 'dracula'} " dracula color theme +Plugin 'stautob/vim-fish' " fish support for vim +Plugin 'jiangmiao/auto-pairs' " auto insert and del quotes in pairs +Plugin 'tpope/vim-surround' " quoting and parenthesizing plugin +Plugin 'preservim/nerdcommenter' " commenting made simple +Plugin 'bling/vim-bufferline' " buffer line +Plugin 'preservim/nerdtree' " NERDTree :) + + + +call vundle#end() +filetype plugin indent on +" Brief help +" :PluginList - lists configured plugins +" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate +" :PluginSearch foo - searches for foo; append `!` to refresh local cache +" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal +" see :h vundle for more details or wiki for FAQ + +" end of vundle stuff + + +"""""""""""""""""" +" General settings +"""""""""""""""""" +colorscheme dracula + +let mapleader=";" " setting leader key to ';' +set number +syntax on +set mouse=a " allow mouse for all +set undofile " save undo to a file +set hlsearch " highlight search +set showcmd " show incomplete commands +set wildmenu " command line's tab complete in a menu +set cursorline " highlight cursor line +set noerrorbells " no beeps +set visualbell " flash screen instead +set title " set window title to file name +set autoindent +set softtabstop=2 " indent by 2 spaces when with tab +set tabstop=4 " show existing tab with 4 spaces width +set shiftwidth=4 +set wrap " dont wrap +set incsearch " find next match while typing search +set linebreak " wrap lines at convenient points +set scrolloff=6 " screen lines to keep above and below cursor +set sidescrolloff=8 " screen columns to keep on left and right of cursor +set confirm " display confirmation when closing unsaved file +set encoding=utf-8 " set encoding with Unicode +set lazyredraw " don't redraw when exe macros +set showmatch " match brackets when text indecator is over it +set mat=2 " how mny tenths of second to blink when matching brackets + +set laststatus=2 " show status line +set statusline=%F%m%r%h%w%=(%{&ff}/%Y)\ (line\ %l\/%L\ \|\ col\ %c) + +" Configure backspace so it acts as it should act +set backspace=eol,start,indent +set whichwrap+=<,>,h,l + +" fold settings +set foldenable +set foldlevelstart=10 +set foldnestmax=10 +set foldmethod=manual +set foldcolumn=2 + + +"set the swp, backup and undo settings +set noswapfile +set nobackup nowritebackup +set undodir=~/.vim/undodir +set undofile + +" Ignore compiled files +set wildignore=*.o,*~,*.pyc +if has("win16") || has("win32") + set wildignore+=.git\*,.hg\*,.svn\* +else + set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store +endif + +" Return to last edit position when opening files (You want this!) +au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif + +" highlight extra whitespace +match ErrorMsg '\s\+$' + +""""""""""" +" Mappings +"""""""""" +" enabling clipboard syncing in WSL +source $HOME/iswsl.vim +if IsWSL() + let s:clip = '/mnt/c/Windows/System32/clip.exe' + if executable(s:clip) + augroup WSLYank + autocmd! + autocmd TextYankPost * call system('echo '.shellescape(join(v:event.regcontents, "\")).' | '.s:clip) + augroup END + end + map "=p :r !powershell.exe -Command Get-Clipboard + map! = :r !powershell.exe -Command Get-Clipboard + noremap "+p :exe 'norm a'.system('/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -Command Get-Clipboard') +endif + +" leader mappings +nnoremap rn :set relativenumber! +nnoremap z zR +nnoremap w :w +nnoremap x :wqa +nnoremap q :qa +noremap n :NERDTreeToggle % +" no highlight - when finished search +nnoremap nh :noh +" paste shortcut below +" must be recursive bcus "+p is aldy mapped above (in WSLYank - paste) +nmap pa "+p +nnoremap rg :registers + +" other mappings +" dot command in visual mode +vnoremap . :normal. +nnoremap Q :q +" move visual selection +vnoremap J :m '>+1gv=gv +vnoremap K :m '<-2gv=gv + +if IsWSL() + execute "set =\ej" + execute "set =\ek" + execute "set =\eJ" + execute "set =\eK" +endif + +nnoremap :m+1== +nnoremap :m-2== + +nnoremap :t.== +nnoremap :t.-1== + +" Visual mode pressing * or # searches for the current selection +" Super useful! From an idea by Michael Naumann +vnoremap * :call VisualSelection('', '')/=@/ +vnoremap # :call VisualSelection('', '')?=@/" + +" Smart way to move between windows +map j +map k +map h +map l + +" Useful mappings for managing tabs +map tn :tabnew +map to :tabonly +map tc :tabclose +map tm :tabmove +map t :tabnext +map bn :bnext +map bp :bprev + +noremap n :NERDTreeToggle % + + +"""""""""""""""" +" other settings +"""""""""""""""" +" setting the shell for fish to sh +"if &shell =~# 'fish$' +" set shell=bash +"endif + diff --git a/README.md b/README.md new file mode 100644 index 0000000..8048c57 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# dotfiles +Welcome, these are for Ubuntu/Debian and WSL diff --git a/bin/ccopy b/bin/ccopy new file mode 100755 index 0000000..1bd3b8b --- /dev/null +++ b/bin/ccopy @@ -0,0 +1,9 @@ +#!/bin/bash + +# my own copy script + +echo '$1' > ~/clipped.txt +echo $1 | clip.exe + +exit 0 + diff --git a/bin/cpaste b/bin/cpaste new file mode 100755 index 0000000..4e6d29e --- /dev/null +++ b/bin/cpaste @@ -0,0 +1,10 @@ +#!/bin/bash + +# my own paste from clipboard script + +powershell.exe Get-Clipboard | sed 's/\r$//' | sed -z '$ s/\n$//' > ~/clipped.txt + +cat ~/clipped.txt + +exit 0 + diff --git a/bin/has b/bin/has new file mode 100755 index 0000000..5c034fc --- /dev/null +++ b/bin/has @@ -0,0 +1,297 @@ +#!/usr/bin/env bash +## source: https://github.com/kdabir/has + +## To add more tools, search for "__detect" function in this file + +## Important so that version is not extracted for failed commands (not found) +set -o pipefail + +readonly BINARY_NAME="has" +readonly VERSION="v1.5.0" + +## constants - symbols for success failure +if [[ -z $TERM ]]; then + $TERM="xterm" +fi +readonly txtreset="$(tput -T $TERM sgr0)" +readonly txtbold="$(tput -T $TERM bold)" +readonly txtblack="$(tput -T $TERM setaf 0)" +readonly txtred="$(tput -T $TERM setaf 1)" +readonly txtgreen="$(tput -T $TERM setaf 2)" +readonly txtyellow="$(tput -T $TERM setaf 3)" +readonly txtblue="$(tput -T $TERM setaf 4)" +readonly txtpurple="$(tput -T $TERM setaf 5)" +readonly txtcyan="$(tput -T $TERM setaf 6)" +readonly txtwhite="$(tput -T $TERM setaf 7)" +# unicode "✗" +readonly fancyx='\342\234\227' +# unicode "✓" +readonly checkmark='\342\234\223' +# PASS="\e[1m\e[38;5;2m✔\e[m" +# FAIL="\e[1m\e[38;5;1m✘\e[m" +readonly PASS="${txtbold}${txtgreen}${checkmark}${txtreset}" +readonly FAIL="${txtbold}${txtred}${fancyx}${txtreset}" + +## These variables are used to keep track of passed and failed commands +OK=0 +KO=0 + +## Regex to extract simple version - extracts numeric sem-ver style versions +REGEX_SIMPLE_VERSION="([[:digit:]]+\.?){2,3}" + +## name of RC file that can contain list of tools to be checked +RC_FILE=".hasrc" + +# try to extract version by executing "${1}" with "${2}" arg +# command name to be executed is dynamically passed to this function as ${1} +# arg to ${1} is passed in ${2} +__dynamic_detect(){ + cmd="${1}" + params="${2}" + version=$( eval "${cmd}" "${params}" "2>&1" | grep -Eo "${REGEX_SIMPLE_VERSION}" | head -1) + status=$? +} + +# commands that use `--version` flag +__dynamic_detect--version(){ + __dynamic_detect "${1}" "--version" +} + +# commands that use `-version` flag +__dynamic_detect-version(){ + __dynamic_detect "${1}" "-version" +} + +# commands that use `-v` flag +__dynamic_detect-v(){ + __dynamic_detect "${1}" "-v" +} + +# commands that use `-V` flag +__dynamic_detect-V(){ + __dynamic_detect "${1}" "-V" +} + +# commands that use `version` argument +__dynamic_detect-arg_version(){ + __dynamic_detect "${1}" "version" +} + +## the main function +__detect(){ + name="${1}" + + # setup aliases - maps commonly used name to exact command name + case ${name} in + golang ) command="go" ;; + jre ) command="java" ;; + jdk ) command="javac" ;; + nodejs ) command="node" ;; + goreplay ) command="gor" ;; + httpie ) command="http" ;; + homebrew ) command="brew" ;; + awsebcli ) command="eb" ;; + awscli ) command="aws" ;; + postgresql ) command="psql" ;; + *coreutils|linux*utils) command="gnu_coreutils" ;; + * ) command=${name} ;; + esac + + case "${command}" in + + # commands that need --version flag + + ## Shells + bash|zsh) __dynamic_detect--version "${command}" ;; + + ## VCS + git|hg|svn|bzr) __dynamic_detect--version "${command}" ;; + + ## Http + curl|wget|http) __dynamic_detect--version "${command}" ;; + + ## Editors + vim|emacs|nano) __dynamic_detect--version "${command}" ;; + subl|code) __dynamic_detect--version "${command}" ;; + + ## File system search and navigation + jq) __dynamic_detect--version "${command}" ;; + ag|ack|rg) __dynamic_detect--version "${command}" ;; + tree|autojump) __dynamic_detect--version "${command}" ;; + + ## package mangers + apt|apt-get|aptitude) __dynamic_detect--version "${command}" ;; + brew) __dynamic_detect--version "${command}" ;; + + ## System tools + sed|awk|grep|file|sudo) __dynamic_detect--version "${command}" ;; + gzip|xz|unar|bzip2) __dynamic_detect--version "${command}" ;; + tar|pv) __dynamic_detect--version "${command}" ;; + + # Container runtimes + docker|podman) __dynamic_detect--version "${command}" ;; + + ## Database CLI + psql) __dynamic_detect--version "${command}" ;; + + ## Scripting Language / runtime + ruby|R|python|python3) __dynamic_detect--version "${command}" ;; + perl|perl6|php|php5) __dynamic_detect--version "${command}" ;; + groovy|node) __dynamic_detect--version "${command}" ;; + + ## Compile + gcc|make|bats) __dynamic_detect--version "${command}" ;; + + ## Build tools + lein|gradle|mvn) __dynamic_detect--version "${command}" ;; + grunt|brunch) __dynamic_detect--version "${command}" ;; + gem|rake|bundle) __dynamic_detect--version "${command}" ;; + npm|yarn) __dynamic_detect--version "${command}" ;; + + + ## Cloud Tools + aws|eb|sls|gcloud) __dynamic_detect--version "${command}" ;; + heroku) __dynamic_detect--version "${command}" ;; + netlify) __dynamic_detect--version "${command}" ;; + netlifyctl) __dynamic_detect-arg_version "${command}" ;; + + ## Hashicorp Tools + terraform|packer) __dynamic_detect--version "${command}" ;; + vagrant|consul) __dynamic_detect--version "${command}" ;; + nomad) __dynamic_detect--version "${command}" ;; + + # commands that need -v flag + unzip) __dynamic_detect-v "${command}" ;; + + # commands that need -V flag + ab) __dynamic_detect-V "${command}" ;; + + # commands that need -version flag + ant) __dynamic_detect-version "${command}" ;; + java|javac|scala|kotlin) __dynamic_detect-version "${command}" ;; + + # commands that need version arg + go|hugo) __dynamic_detect-arg_version "${command}" ;; + + ## Example of commands that need custom processing + + ## TODO cleanup, currently need to add extra space in regex, otherwise the time gets selected + gulp) + version=$( gulp --version 2>&1| grep -Eo " ${REGEX_SIMPLE_VERSION}" | head -1) + status=$? + ;; + + ## gor returns version but does not return normal status code, hence needs custom processing + gor) + version=$( gor version 2>&1 | grep -Eo "${REGEX_SIMPLE_VERSION}" | head -1) + if [ $? -eq 1 ]; then status=0; else status=127; fi + ;; + + sbt) + version=$( sbt about 2>&1 | grep -Eo "([[:digit:]]{1,4}\.){2}[[:digit:]]{1,4}" | head -1) + status=$? + ;; + + ## use 'readlink' to test for GNU coreutils + # readlink (GNU coreutils) 8.28 + gnu_coreutils) __dynamic_detect--version readlink ;; + + ## hub uses --version but version string is on second line, or third if HUB_VERBOSE set + hub) + version=$( HUB_VERBOSE='' hub --version 2>&1 | sed -n 2p | grep -Eo "${REGEX_SIMPLE_VERSION}" | head -1) + status=$? + ;; + + ## zip uses -v but version string is on second line + zip) + version=$( zip -v 2>&1 | sed -n 2p | grep -Eo "${REGEX_SIMPLE_VERSION}" | head -1) + status=$? + ;; + + has) + version=$( has 2>&1 | grep -Eo "${REGEX_SIMPLE_VERSION}" | head -1) + status=$? + ;; + + *) + ## Can allow dynamic checking here, i.e. checking commands that are not listed above + if [[ "${HAS_ALLOW_UNSAFE}" == "y" ]]; then + __dynamic_detect--version "${command}" + ## fallback checking based on status!=127 (127 means command not found) + ## TODO can check other type of supported version-checks if status was not 127 + else + ## -1 is special way to tell command is not supported/whitelisted by `has` + status="-1" + fi + ;; + esac + + if [ "$status" -eq "-1" ]; then ## When unsafe processing is not allowed, the -1 signifies + printf '%b %s not understood\n' "${FAIL}" "${command}" > "$OUTPUT" + KO=$(( KO+1 )) + + elif [ ${status} -eq 127 ]; then ## command not installed + printf '%b %s\n' "${FAIL}" "${command}" > "$OUTPUT" + KO=$(( KO+1 )) + + elif [ ${status} -eq 0 ] || [ ${status} -eq 141 ]; then ## successfully executed + printf "%b %s %b\n" "${PASS}" "${command}" "${txtbold}${txtyellow}${version}${txtreset}" > "$OUTPUT" + OK=$(( OK+1 )) + + else ## as long as its not 127, command is there, but we might not have been able to extract version + printf '%b %s\n' "${PASS}" "${command}" > "$OUTPUT" + OK=$(( OK+1 )) + fi +} #end __detect + +OPTIND=1 +OUTPUT=/dev/stdout + +while getopts "q" opt; do + case "$opt" in + q) QUIET="true" + OUTPUT=/dev/null + ;; + esac +done + +shift $((OPTIND-1)) + +if [ -s "${RC_FILE}" ]; then + HASRC="true" +fi + +# if HASRC is not set AND no arguments passed to script +if [[ -z "${HASRC}" ]] && [ "$#" -eq 0 ]; then + # print help + printf '%s %s\n' "${BINARY_NAME}" "${VERSION}" > "$OUTPUT" + printf 'USAGE:\t %s [-q] ..\n' "${BINARY_NAME}" > "$OUTPUT" + printf 'EXAMPLE: %s git curl node\n' "${BINARY_NAME}" > "$OUTPUT" + +else + # for each cli-arg + for cmd in "$@"; do + __detect "${cmd}" + done + + ## display found / total + # echo ${OK} / $(($OK+$KO)) + + ## if HASRC has been set + if [[ -n "${HASRC}" ]]; then + ## for all + while read -r line; do + __detect "${line}" + done <<<"$( grep -Ev "^\s*(#|$)" "${RC_FILE}" )" + fi + + ## max status code that can be returned + MAX_STATUS_CODE=126 + + if [[ "${KO}" -gt "${MAX_STATUS_CODE}" ]]; then + exit "${MAX_STATUS_CODE}" + else + exit "${KO}" + fi + +fi diff --git a/bin/pbcopy b/bin/pbcopy new file mode 100755 index 0000000..51b50b1 --- /dev/null +++ b/bin/pbcopy @@ -0,0 +1,8 @@ +#!/bin/bash + +# the pbcopy script + +tee | clip.exe + +exit 0 + diff --git a/bin/pbpaste b/bin/pbpaste new file mode 100755 index 0000000..b32521f --- /dev/null +++ b/bin/pbpaste @@ -0,0 +1,8 @@ +#!/bin/bash + +# the pbpaste script + +powershell.exe Get-Clipboard | sed 's/\r$//' | sed -z '$ s/\n$//' + +exit 0 + diff --git a/bin/pyhello b/bin/pyhello new file mode 100755 index 0000000..a99df8b --- /dev/null +++ b/bin/pyhello @@ -0,0 +1,2 @@ +#!/usr/bin/python3 +print('Hello! ') diff --git a/bin/test b/bin/test new file mode 100755 index 0000000..68d8222 --- /dev/null +++ b/bin/test @@ -0,0 +1,2 @@ +#!/bin/bash +echo hi diff --git a/iswsl.vim b/iswsl.vim new file mode 100644 index 0000000..e3d4411 --- /dev/null +++ b/iswsl.vim @@ -0,0 +1,9 @@ +function! IsWSL() + if has("unix") + let lines = readfile("/proc/version") + if lines[0] =~ "Microsoft" + return 1 + endif + endif + return 0 +endfunction