diff --git a/.editorconfig b/.editorconfig index ed5ceb6b8..db90ae889 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,5 +1,6 @@ # For more information about the configurations used -# in this file, please see the EditorConfig documentation: +# in this file, please see the EditorConfig documentation. +# # http://editorconfig.org root = true @@ -18,7 +19,7 @@ trim_trailing_whitespace = true [*.md] -# Markdown uses the trailing whitespaces +# Markdown uses the trailing whitespaces. # https://daringfireball.net/projects/markdown/syntax#block trim_trailing_whitespace = false diff --git a/.gitattributes b/.gitattributes index 885cf1b95..4e8d6eaec 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,4 @@ -# Automatically normalize line endings for all text-based files +# Automatically normalize line endings for all text-based files. # https://git-scm.com/docs/gitattributes#_end_of_line_conversion * text=auto diff --git a/.travis.yml b/.travis.yml index 643e58450..780ecfe23 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ # For more information about the configurations used -# in this file, please see the Travis CI documentation: +# in this file, please see the Travis CI documentation. +# # https://docs.travis-ci.com before_install: diff --git a/src/bin/clean-whiteboard-photos b/src/bin/clean-whiteboard-photos index 778eafb40..39753a4cf 100755 --- a/src/bin/clean-whiteboard-photos +++ b/src/bin/clean-whiteboard-photos @@ -32,7 +32,7 @@ clean_whiteboard_photos() { main() { - # Check if ImageMagick's convert command-line tool is installed + # Check if ImageMagick's convert command-line tool is installed. if ! command -v "convert" $> /dev/null; then printf "Please install ImageMagick's 'convert' command-line tool!" diff --git a/src/bin/get-compression-heatmap b/src/bin/get-compression-heatmap index dea15e9a9..e8f73419c 100755 --- a/src/bin/get-compression-heatmap +++ b/src/bin/get-compression-heatmap @@ -53,18 +53,18 @@ create_heatmap_for_webpage() { --header "Accept-Encoding: gzip, deflate" --header "Cache-Control: no-cache" # Prevent intermediate # proxies from caching - # the response + # the response. --location # If the page was moved # to a different location, - # redo the request + # redo the request. --max-time 150 --show-error --silent --user-agent "Mozilla/5.0 Gecko" # Send a fake UA string # for sites that sniff # it instead of using the - # Accept-Encoding header + # Accept-Encoding header. ) local tmpFile="$(create_tmp_file)" @@ -73,7 +73,7 @@ create_heatmap_for_webpage() { # Try to get the compressed version of the page, and if the # page isn't served compressed, `create_heatmap_for_file` will - # take care of compressing it + # take care of compressing it. curl "${CURL_DEFAULT_OPTIONS[@]}" "$1" &> /dev/null 1> "$tmpFile" \ && create_heatmap_for_file "$tmpFile" "$2" @@ -117,8 +117,8 @@ get_script_path() { open_image() { - # The order of the following checks matters - # as on Ubuntu there is also a utility called `open` + # The order of the following checks matters as + # on Ubuntu there is also a utility called `open`. if cmd_exists "xdg-open"; then xdg-open "$1" @@ -175,7 +175,7 @@ main() { # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Check if the current command - # line argument is a local file + # line argument is a local file. if [ -f "$1" ]; then @@ -185,7 +185,7 @@ main() { create_heatmap_for_png "$1" "$imageFile" fi - # If it's not, assume it is a URL + # If it's not, assume it is a URL. else create_heatmap_for_webpage "$1" "$imageFile" @@ -199,7 +199,7 @@ main() { # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Opening too many images really - # quickly makes macOS' Preview crash + # quickly makes macOS' Preview crash. sleep 0.2 diff --git a/src/bin/get-content-encoding b/src/bin/get-content-encoding index 57f18fee8..6e7c043cb 100755 --- a/src/bin/get-content-encoding +++ b/src/bin/get-content-encoding @@ -23,17 +23,17 @@ declare -r -a CURL_DEFAULT_OPTIONS=( --connect-timeout 30 --header "Accept-Encoding: br, gzip, deflate, lzma, sdch" --header "Cache-Control: no-cache" # Prevent intermediate proxies - # from caching the response + # from caching the response. --location # If the page was moved to a # different location, redo the - # request + # request. --max-time 150 --show-error --silent --user-agent "Mozilla/5.0 Gecko" # Send a fake UA string for sites # that sniff it instead of using - # the Accept-Encoding header + # the Accept-Encoding header. ) # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -48,21 +48,23 @@ check_for_sdch() { declare i="" declare url="$2" - # Check if the server advertised any dictionaries + # Check if the server advertised any dictionaries. + dicts="$( printf "%s" "$currentHeaders" | grep -i "Get-Dictionary:" | cut -d':' -f2 | sed s/,/\ /g )" - # If it does, check to see if it really supports SDCH + # If it does, check to see if it really supports SDCH. + if [ -n "$dicts" ]; then for i in $dicts; do dict="" - # Check if the dictionary location is specified as a path, - # and if it is, construct it's URL from the host name of the - # referrer URL + # Check if the dictionary location is specified as + # a path, and if it is, construct it's URL from the + # host name of the referrer URL. [[ "$i" != http* ]] \ && dict="$( printf "%s" "$url" | @@ -71,7 +73,7 @@ check_for_sdch() { dict="$dict$i" # Request the dictionaries from the server and - # construct the `Avail-Dictionary` header value + # construct the `Avail-Dictionary` header value. # # [ The user agent identifier for a dictionary is defined # as the URL-safe base64 encoding (as described in RFC @@ -90,7 +92,7 @@ check_for_sdch() { done # Redo the request (advertising the available dictionaries) - # and replace the old resulted headers with the new ones + # and replace the old resulted headers with the new ones. printf "%s" "$( curl "${CURL_DEFAULT_OPTIONS[@]}" \ -H "Avail-Dictionary: $availDicts" \ @@ -118,18 +120,18 @@ get_content_encoding() { "$url" )" \ && ( \ - # Iterate over the headers of all redirects + # Iterate over the headers of all redirects. while [ -n "$headers" ]; do - # Get headers for the "current" URL + # Get headers for the "current" URL. currentHeaders="$( printf "%s" "$headers" | sed -n '1,/^HTTP/p' )" - # Remove the headers for the "current" URL + # Remove the headers for the "current" URL. headers="${headers/"$currentHeaders"/}" currentHeaders="$(check_for_sdch "$currentHeaders" "$url")" - # Get the value of the `Content-Encoding` header + # Get the value of the `Content-Encoding` header. encoding="$( printf "%s" "$currentHeaders" | grep -i "Content-Encoding:" | cut -d' ' -f2 | @@ -137,7 +139,7 @@ get_content_encoding() { tr -d "\n" | sed 's/,$//' )" - # Print the output for the "current" URL + # Print the output for the "current" URL. [ -n "$encoding" ] && encoding="[$encoding]" if [ "$url" != "$1" ]; then @@ -148,7 +150,8 @@ get_content_encoding() { indent=" ↳ " fi - # Get the next URL from the series of redirects + + # Get the next URL from the series of redirects. tmp="$url" url="$( printf "%s" "$currentHeaders" | grep -i "Location" | @@ -156,7 +159,7 @@ get_content_encoding() { sed 's/^ *//' | tr -d '\r' )" - # In case the `Location` header is specified as a path + # In case the `Location` header is specified as a path. [[ "$url" != http* ]] && url="$tmp$url" done @@ -167,7 +170,7 @@ get_content_encoding() { main() { - # Check if `cURL` is installed + # Check if `cURL` is installed. if ! command -v "curl" &> /dev/null; then printf "cURL is required, please install it!\n" diff --git a/src/bin/server b/src/bin/server index eb8ed30f7..1aabc56ad 100755 --- a/src/bin/server +++ b/src/bin/server @@ -6,8 +6,8 @@ cmd_exists() { open_url() { - # The order of the following checks matters - # as on Ubuntu there is also a utility called `open` + # The order of the following checks matters as + # on Ubuntu there is also a utility called `open`. if cmd_exists "xdg-open"; then xdg-open "$1" @@ -28,7 +28,7 @@ main() { # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Wait for the server to be available, and once - # it is, open its address in the default browser + # it is, open its address in the default browser. while [ $i -lt $MAX_NUMBER_OF_TRIES ]; do if [ "$(lsof -i -nP | grep "$port" | grep -i "python")" != "" ]; then @@ -41,7 +41,7 @@ main() { # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Start server + # Start server. "$(dirname "${BASH_SOURCE[0]}")/server.py" "$port" diff --git a/src/bin/server.py b/src/bin/server.py index 1f7216166..bd2da3f0f 100755 --- a/src/bin/server.py +++ b/src/bin/server.py @@ -10,7 +10,7 @@ except ImportError: # In Python 3 the 'SimpleHTTPServer' - # module has been merged into 'http.server' + # module has been merged into 'http.server'. import http.server as server import socketserver @@ -21,23 +21,23 @@ map = handler.extensions_map port = int(sys.argv[1]) -# Set default Content-Type to 'text/plain' +# Set default Content-Type to 'text/plain'. map[""] = "text/plain" # Serve everything as UTF-8 (although not technically -# correct, this doesn't break anything for binary files) +# correct, this doesn't break anything for binary files). for key, value in map.items(): map[key] = value + "; charset=utf-8" # Create but don't automatically bind socket -# (the 'allow_reuse_address' option needs to be set first) +# (the 'allow_reuse_address' option needs to be set first). httpd = socketserver.ThreadingTCPServer(("localhost", port), handler, False) -# Prevent 'cannot bind to address' errors on restart +# Prevent 'cannot bind to address' errors on restart. # https://brokenbad.com/address-reuse-in-pythons-socketserver/ httpd.allow_reuse_address = True -# Manually bind socket and start the server +# Manually bind socket and start the server. httpd.server_bind() httpd.server_activate() print("Serving content on port: ", port) diff --git a/src/git/gitattributes b/src/git/gitattributes index b7674b00e..416549be6 100644 --- a/src/git/gitattributes +++ b/src/git/gitattributes @@ -1,4 +1,4 @@ -# Automatically normalize line endings for all text-based files +# Automatically normalize line endings for all text-based files. # https://git-scm.com/docs/gitattributes#_end_of_line_conversion # # * text=auto diff --git a/src/git/gitconfig b/src/git/gitconfig index c368534fa..6eebea207 100644 --- a/src/git/gitconfig +++ b/src/git/gitconfig @@ -3,23 +3,23 @@ a = commit --amend br = branch c = commit - ca = !git add -A && git commit # Commit all changes + ca = !git add -A && git commit # Commit all changes. co = checkout cp = cherry-pick d = diff dc = diff --cached - g = log --graph --pretty=custom # Show custom graph - l = log --pretty=custom # Show custom log - lc = shortlog --summary --numbered # List contributors + g = log --graph --pretty=custom # Show custom graph. + l = log --pretty=custom # Show custom log. + lc = shortlog --summary --numbered # List contributors. p = push r = rebase - rlc = reset --hard HEAD~1 # Remove last commit + rlc = reset --hard HEAD~1 # Remove last commit. s = status - ulc = reset --soft HEAD~1 # Undo last commit + ulc = reset --soft HEAD~1 # Undo last commit. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Find commits by source code + # Find commits by source code. cc = "!f() { \ git log --pretty=custom --decorate --date=short -S\"$1\"; \ @@ -27,7 +27,7 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Find commits by commit message + # Find commits by commit message. cm = "!f() { \ git log --pretty=custom --decorate --date=short --grep=\"$1\"; \ @@ -35,7 +35,7 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Credit an author on the latest commit + # Credit an author on the latest commit. credit = "!f() { \ if [ -n \"$1\" ] && [ -n \"$2\" ]; then \ @@ -45,7 +45,7 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # List remote branches + # List remote branches. lrb = "!f() { \ remote="${1:-origin}"; \ @@ -55,7 +55,7 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Merge GitHub pull request on top of the current branch or, - # if a branch name is specified, on top of the specified branch + # if a branch name is specified, on top of the specified branch. mpr = "!f() { \ declare currentBranch=\"$(git symbolic-ref --short HEAD)\"; \ @@ -74,7 +74,7 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Remove the tag with the specified tag name if - # exists and tag the latest commit with that name + # exists and tag the latest commit with that name. retag = "!f() { \ git tag -d "$1" &> /dev/null; \ @@ -111,14 +111,14 @@ [commit] - # Sign commits using GPG + # Sign commits using GPG. # https://help.github.com/articles/signing-commits-using-gpg/ gpgsign = true [diff "bin"] - # Use `hexdump` to diff binary files + # Use `hexdump` to diff binary files. textconv = hexdump -v -C @@ -135,24 +135,24 @@ [push] # Make `git push` automatically push relevant - # annotated tags when pushing branches out + # annotated tags when pushing branches out. followTags = true [user] - # Don't guess the user's identity + # Don't guess the user's identity. # https://github.com/git/git/blob/90f7b16b3adc78d4bbabbd426fb69aa78c714f71/Documentation/config.txt#L2847-L2855 useConfigOnly = true [include] - # Load local configs + # Load local configs. # https://git-scm.com/docs/git-config#_includes # - # Note: The following needs to remain at the end of this file in - # order to allow any of the above configs to be overwritten - # by the local ones + # [!] The following needs to remain at the end of this file in + # order to allow any of the above configs to be overwritten + # by the local ones path = ~/.gitconfig.local diff --git a/src/git/gitignore b/src/git/gitignore index c513d870c..689853f18 100644 --- a/src/git/gitignore +++ b/src/git/gitignore @@ -12,7 +12,7 @@ # | Miscellaneous | # ---------------------------------------------------------------------- -# Node.js & npm +# Node.js & npm. node_modules npm-debug.log diff --git a/src/shell/aliases/bash_aliases b/src/shell/aliases/bash_aliases index bd73a5143..4cab2cdf7 100644 --- a/src/shell/aliases/bash_aliases +++ b/src/shell/aliases/bash_aliases @@ -22,6 +22,6 @@ alias rm="rm -rf --" # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Load OS specific aliases +# Load OS specific aliases. . "aliases/$OS/bash_aliases" diff --git a/src/shell/aliases/macos/bash_aliases b/src/shell/aliases/macos/bash_aliases index b41f44723..dbe0aaa9d 100644 --- a/src/shell/aliases/macos/bash_aliases +++ b/src/shell/aliases/macos/bash_aliases @@ -2,14 +2,13 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Clear DNS cache +# Lock screen. -alias clear-dns-cache="sudo dscacheutil -flushcache; \ - sudo killall -HUP mDNSResponder" +alias afk="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend" # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Homebrew +# Shorter commands for `Homebrew`. alias brewd="brew doctor" alias brewi="brew install" @@ -22,8 +21,15 @@ alias brewu="brew update \ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# Clear DNS cache. + +alias clear-dns-cache="sudo dscacheutil -flushcache; \ + sudo killall -HUP mDNSResponder" + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + # Empty the trash, the main HDD and on all mounted volumes, -# and clear Apple’s system logs to improve shell startup speed +# and clear Apple’s system logs to improve shell startup speed. alias empty-trash="sudo rm -frv /Volumes/*/.Trashes; \ sudo rm -frv ~/.Trash; \ @@ -32,7 +38,7 @@ alias empty-trash="sudo rm -frv /Volumes/*/.Trashes; \ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Hide/Show desktop icons +# Hide/Show desktop icons. alias hide-desktop-icons="defaults write com.apple.finder CreateDesktop -bool false \ && killall Finder" @@ -42,7 +48,7 @@ alias show-desktop-icons="defaults write com.apple.finder CreateDesktop -bool tr # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Hide/Show hidden files in Finder +# Hide/Show hidden files in Finder. alias hide-hidden-files="defaults write com.apple.finder AppleShowAllFiles -bool false \ && killall Finder" @@ -52,25 +58,19 @@ alias show-hidden-files="defaults write com.apple.finder AppleShowAllFiles -bool # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Lock screen - -alias afk="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend" - -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Get local IP +# Get local IP. alias local-ip="ipconfig getifaddr en1" # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Open +# Open from the terminal. alias o="open" # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Update +# Update applications and CLTs. alias u="sudo softwareupdate --install --all \ && brew update \ diff --git a/src/shell/aliases/ubuntu/bash_aliases b/src/shell/aliases/ubuntu/bash_aliases index 7f9282169..7693f6560 100644 --- a/src/shell/aliases/ubuntu/bash_aliases +++ b/src/shell/aliases/ubuntu/bash_aliases @@ -2,7 +2,13 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Advanced Packaging Tool +# Lock screen. + +alias afk="gnome-screensaver-command --lock" + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# Shorter commands for the `Advanced Packaging Tool` alias apti="sudo apt-get install" alias aptr="sudo apt-get remove" @@ -12,20 +18,20 @@ alias aptu="sudo apt-get update \ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Empty Trash +# Empty trash. alias empty-trash="rm -rf ~/.local/share/Trash/files/*" # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Hide/Show desktop icons +# Hide/Show desktop icons. alias hide-desktop-icons="gsettings set org.gnome.desktop.background show-desktop-icons false" alias show-desktop-icons="gsettings set org.gnome.desktop.background show-desktop-icons true" # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Get local IP +# Get local IP. alias local-ip="ifconfig \ | grep 'inet addr' \ @@ -35,19 +41,13 @@ alias local-ip="ifconfig \ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Lock screen - -alias afk="gnome-screensaver-command --lock" - -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Open +# Open from the terminal. alias o="xdg-open" # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Update +# Update applications and CLTs. alias u="sudo apt-get update \ && sudo apt-get upgrade \ diff --git a/src/shell/autocomplete/macos/bash_autocomplete b/src/shell/autocomplete/macos/bash_autocomplete index a3b7ca322..43696312d 100644 --- a/src/shell/autocomplete/macos/bash_autocomplete +++ b/src/shell/autocomplete/macos/bash_autocomplete @@ -5,12 +5,16 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -if [ -f "$(brew --prefix)/share/bash-completion/bash_completion" ]; then +declare -r BASH_COMPLETION_PATH="$(brew --prefix 2> /dev/null)/share/bash-completion/bash_completion" - # Use latest `bash-completion` - . "$(brew --prefix)/share/bash-completion/bash_completion" +if [ -f "$BASH_COMPLETION_PATH" ]; then + + # Use the latest `bash-completion`. + + . "$BASH_COMPLETION_PATH" + + # Make Bash complete the `g` alias just like it does `git`. - # Make Bash complete the `g` alias just like it does `git` complete -o default -o nospace -F _git g fi diff --git a/src/shell/bash_exports b/src/shell/bash_exports index c003f19ef..63c4124ce 100644 --- a/src/shell/bash_exports +++ b/src/shell/bash_exports @@ -1,49 +1,78 @@ #!/bin/bash -# Shell Variables -# http://linux.die.net/man/1/bash +# Bash Variables. +# https://www.gnu.org/software/bash/manual/html_node/Bash-Variables.html # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Make vim the default editor +# Make `vim` the default editor. + export EDITOR="vim" -# Ignore commands that start with spaces and duplicates +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# Ignore commands that start with spaces and duplicates. + export HISTCONTROL=ignoreboth +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + # Increase the maximum number of lines of history -# persisted in the Bash history file (default value is 500) +# persisted in the history file (default value is 500). + export HISTFILESIZE=10000 -# Don't add certain commands to the history file +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# Don't add certain commands to the history file. + export HISTIGNORE="&:[bf]g:c:clear:history:exit:q:pwd:* --help" -# Increase the maximum number of commands recorded in the -# command history (default value is 500) +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# Increase the maximum number of commands recorded +# in the command history (default value is 500). + export HISTSIZE=10000 -# Prefer US English and use UTF-8 encoding +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# Prefer US English and use UTF-8 encoding. + export LANG="en_US" export LC_ALL="en_US.UTF-8" -# Use custom `less` colors for man pages -# https://www.gnu.org/software/termutils/manual/termutils-2.0/html_chapter/tput_1.html -export LESS_TERMCAP_md=$'\e[1;32m' # begin bold mode -export LESS_TERMCAP_me=$'\e[0m' # end bold mode -#export LESS_TERMCAP_us=$'\e[4;32m' # begin underscore mode -#export LESS_TERMCAP_ue=$'\e[0m' # end underscore mode +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# Use custom `less` colors for `man` pages. + +export LESS_TERMCAP_md=$'\e[1;32m' # Begin bold mode. +export LESS_TERMCAP_me=$'\e[0m' # End bold mode. + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# Don't clear the screen after quitting a `man` page. -# Don't clear the screen after quitting a man page export MANPAGER="less -X" +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + # Increase the maximum number of lines of history persisted -# in the `Node` REPL history file (default value is 1000) -# https://github.com/nodejs/node/blob/a85f4b5ce5791caf8caa9b31970313c6183a5499/doc/api/repl.markdown#persistent-history +# in the `Node` REPL history file (default value is 1000). +# +# https://github.com/nodejs/node/blob/c948877688ff2b6a37f2c88724b656aae495c7b2/doc/api/repl.md#persistent-history + export NODE_REPL_HISTORY_SIZE=10000 +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + # Make new shells get the history lines from all previous -# shells instead of the default "last window closed" history +# shells instead of the default "last window closed" history. + export PROMPT_COMMAND="history -a; $PROMPT_COMMAND" -# Make Python use UTF-8 encoding for output to stdin/stdout/stderr +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# Make Python use UTF-8 encoding for output to stdin/stdout/stderr. + export PYTHONIOENCODING="UTF-8" diff --git a/src/shell/bash_functions b/src/shell/bash_functions index f663675d5..e5385a043 100644 --- a/src/shell/bash_functions +++ b/src/shell/bash_functions @@ -2,7 +2,7 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Simple Calculator +# Simple Calculator. ? () { @@ -14,11 +14,14 @@ # (large numbers are printed on multiple lines) if [[ "$result" == *.* ]]; then - # Improve the output for decimal numbers + + # Improve the output for decimal numbers. + printf "%s" "$result" | - sed -e "s/^\./0./" # add "0" for cases like ".5"` \ - -e "s/^-\./-0./" # add "0" for cases like "-.5"`\ - -e "s/0*$//;s/\.$//" # remove tailing zeros + sed -e "s/^\./0./" # Add "0" for cases like ".5".` \ + -e "s/^-\./-0./" # Add "0" for cases like "-.5".`\ + -e "s/0*$//;s/\.$//" # Remove tailing zeros. + else printf "%s" "$result" fi @@ -29,7 +32,7 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Create data URI from a file +# Create data URI from a file. datauri() { @@ -54,7 +57,7 @@ datauri() { # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Delete files that match a certain pattern from the current directory +# Delete files that match a certain pattern from the current directory. delete-files() { local q="${1:-*.DS_Store}" @@ -63,7 +66,7 @@ delete-files() { # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Get gzip information (gzipped file size + reduction size) +# Get gzip information (gzipped file size + reduction size). gz() { @@ -99,7 +102,7 @@ gz() { # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Human readable file size -# (because `du -h` doesn't cut it for me) +# (because `du -h` doesn't cut it for me). hrfs() { @@ -133,7 +136,7 @@ hrfs() { # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Create new directories and enter the first one +# Create new directories and enter the first one. mkd() { if [ -n "$*" ]; then @@ -149,7 +152,7 @@ mkd() { # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Search history +# Search history. qh() { # ┌─ enable colors for pipe @@ -162,7 +165,7 @@ qh() { # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Search for text within the current directory +# Search for text within the current directory. qt() { grep -ir --color=always "$*" . | less -RX diff --git a/src/shell/bash_logout b/src/shell/bash_logout index 0689768bc..dba1c71ae 100644 --- a/src/shell/bash_logout +++ b/src/shell/bash_logout @@ -1,6 +1,6 @@ #!/bin/bash -# Clear console on exit +# Clear console on exit. [ "$SHLVL" == 1 ] \ && clear &> /dev/null diff --git a/src/shell/bash_options b/src/shell/bash_options index a2cfffe04..23d3bfc99 100644 --- a/src/shell/bash_options +++ b/src/shell/bash_options @@ -1,36 +1,61 @@ #!/bin/bash -# Shell Options +# Bash options. # https://www.gnu.org/software/bash/manual/bashref.html#The-Shopt-Builtin # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Automatically prepend `cd` to directory names +# Automatically prepend `cd` to directory names. + shopt -s autocd -# Autocorrect typos in path names when using the `cd` command +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# Autocorrect typos in path names when using the `cd` command. + shopt -s cdspell +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + # Check the window size after each command and, if necessary, update -# the values of `LINES` and `COLUMNS` +# the values of `LINES` and `COLUMNS`. + shopt -s checkwinsize -# Save all lines of a multiple-line command in the same history entry +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# Save all lines of a multiple-line command in the same history entry. + shopt -s cmdhist -# Include filenames beginning with a "." in the filename expansion +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# Include filenames beginning with a "." in the filename expansion. + shopt -s dotglob -# Use extended pattern matching features +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# Use extended pattern matching features. + shopt -s extglob -# Append to the history file rather then overwriting it +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# Append to the history file rather then overwriting it. + shopt -s histappend +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + # Do not attempt to search the PATH for possible completions when -# completion is attempted on an empty line +# completion is attempted on an empty line. + shopt -s no_empty_cmd_completion +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + # Match filenames in a case-insensitive fashion when performing -# filename expansion +# filename expansion. + shopt -s nocaseglob diff --git a/src/shell/bash_profile b/src/shell/bash_profile index 3db150a12..81dd25e3b 100644 --- a/src/shell/bash_profile +++ b/src/shell/bash_profile @@ -13,8 +13,8 @@ source_bash_files() { "bash_functions" "bash_options" "bash_prompt" - "bash.local" # for local settings that should - # not be under version control + "bash.local" # For local settings that should + # not be under version control. ) local file="" @@ -52,7 +52,7 @@ unset -f source_bash_files # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Clear system messages (e.g.: system copyright notice, the -# date and time of the last login, the message of the day, etc.) +# Clear system messages (system copyright notice, the date +# and time of the last login, the message of the day, etc.). clear diff --git a/src/shell/bash_prompt b/src/shell/bash_prompt index 003af0109..d1593d0b2 100644 --- a/src/shell/bash_prompt +++ b/src/shell/bash_prompt @@ -13,7 +13,7 @@ enable_color_support() { # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Load OS specific color support + # Load OS specific color support. . "colors/$OS/bash_colors" @@ -22,9 +22,9 @@ enable_color_support() { # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # [!] Don't break this function into smaller, more specialized ones -# as you will only pollute the global space even more (this function +# as you will only pollute the global space even more. This function # cannot be unset because it's called every time the prompt string -# is shown) +# is shown. get_git_repository_details() { @@ -33,7 +33,7 @@ get_git_repository_details() { # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Check if the current directory is in a Git repository + # Check if the current directory is in a Git repository. ! git rev-parse &>/dev/null \ && return @@ -41,14 +41,14 @@ get_git_repository_details() { # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Check if in `.git/` directory (some of the following - # checks don't make sense/won't work in the `.git` directory) + # checks don't make sense/won't work in the `.git` directory). [ "$(git rev-parse --is-inside-git-dir)" == "true" ] \ && return # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Check for uncommitted changes in the index + # Check for uncommitted changes in the index. if ! git diff --quiet --ignore-submodules --cached; then tmp="$tmp+"; @@ -56,7 +56,7 @@ get_git_repository_details() { # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Check for unstaged changes + # Check for unstaged changes. if ! git diff-files --quiet --ignore-submodules --; then tmp="$tmp!"; @@ -64,7 +64,7 @@ get_git_repository_details() { # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Check for untracked files + # Check for untracked files. if [ -n "$(git ls-files --others --exclude-standard)" ]; then tmp="$tmp?"; @@ -72,7 +72,7 @@ get_git_repository_details() { # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Check for stashed files + # Check for stashed files. if git rev-parse --verify refs/stash &>/dev/null; then tmp="$tmp$"; @@ -115,12 +115,12 @@ set_prompts() { if [ -x /usr/bin/tput ] && tput setaf 1 &> /dev/null; then - tput sgr0 # Reset colors + tput sgr0 bold=$(tput bold) reset=$(tput sgr0) - # Solarized colors + # Solarized colors. # https://github.com/altercation/solarized/tree/master/iterm2-colors-solarized#the-values # black=$(tput setaf 0) @@ -152,7 +152,7 @@ set_prompts() { # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Prompt Statement variables + # Prompt Statement variables. # http://ss64.com/bash/syntax-prompt.html # ------------------------------------------------------------------ @@ -190,7 +190,7 @@ set_prompts() { # # The GNU `date` command has the `%N` interpreted sequence while # other implementations don't (on macOS `gdate` can be used instead - # of the native `date` if the `coreutils` package has been installed) + # of the native `date` if the `coreutils` package has been installed). # # local dateCmd="" # @@ -232,7 +232,7 @@ main # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Cleanup +# Cleanup. unset -f enable_color_support unset -f main diff --git a/src/shell/colors/macos/bash_colors b/src/shell/colors/macos/bash_colors index 1b29378b2..0bd14a29b 100644 --- a/src/shell/colors/macos/bash_colors +++ b/src/shell/colors/macos/bash_colors @@ -2,14 +2,14 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Set LSCOLORS (FreeBSD / macOS) +# Set LSCOLORS (FreeBSD / macOS). # -# - `ls` displays colors if the `-G` option is passed or if -# the `CLICOLOR` environment variable is set +# * `ls` displays colors if the `-G` option is passed or if +# the `CLICOLOR` environment variable is set. # -# - the actual colors are configured through the `LSCOLORS` +# * The actual colors are configured through the `LSCOLORS` # environment variable (built-in defaults are used if this -# variable is not set) +# variable is not set). LSCOLORS="" @@ -29,6 +29,6 @@ export LSCOLORS # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Enable color support +# Enable color support. alias ls="ls -G" diff --git a/src/shell/colors/ubuntu/bash_colors b/src/shell/colors/ubuntu/bash_colors index 2c2cdff05..8d59cb07f 100644 --- a/src/shell/colors/ubuntu/bash_colors +++ b/src/shell/colors/ubuntu/bash_colors @@ -2,34 +2,34 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Set LS_COLORS (GNU) +# Set LS_COLORS (GNU). # -# - `ls` displays colors if the `--color` option is passed +# - `ls` displays colors if the `--color` option is passed. # -# - the actual colors are configured through the `LS_COLORS` +# - The actual colors are configured through the `LS_COLORS` # environment variable (built-in defaults are used if this -# variable is not set) +# variable is not set). LS_COLORS="" -LS_COLORS+="no=0;39:" # global default -LS_COLORS+="di=0;36:" # directory -LS_COLORS+="ex=0;32:" # executable file -LS_COLORS+="fi=0;39:" # file -LS_COLORS+="ec=:" # non-filename text -LS_COLORS+="mi=1;31:" # non-existent file pointed to by a symlink -LS_COLORS+="ln=target:" # symbolic link -LS_COLORS+="or=31;01" # symbolic link pointing to a non-existent file +LS_COLORS+="no=0;39:" # Global default +LS_COLORS+="di=0;36:" # Directory +LS_COLORS+="ex=0;32:" # Executable file +LS_COLORS+="fi=0;39:" # File +LS_COLORS+="ec=:" # Non-filename text +LS_COLORS+="mi=1;31:" # Non-existent file pointed to by a symlink +LS_COLORS+="ln=target:" # Symbolic link +LS_COLORS+="or=31;01" # Symbolic link pointing to a non-existent file export LS_COLORS # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Enable color support +# Enable color support. if [ -x /usr/bin/dircolors ]; then - if test -r ~/.dircolors; then + if test -r ~/.dircolorS; then eval "$(dircolors -b ~/.dircolors)" else eval "$(dircolors -b)" diff --git a/src/shell/curlrc b/src/shell/curlrc index c35f9c2ab..ffb63ba6f 100644 --- a/src/shell/curlrc +++ b/src/shell/curlrc @@ -1,19 +1,32 @@ -# cURL configuration options +# cURL configuration options. # https://curl.haxx.se/docs/manpage.html # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Limit the time (in seconds) the connection is allowed to take +# Limit the time (in seconds) the connection is allowed to take. + connect-timeout = 60 -# Follow HTTP redirects +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# Follow HTTP redirects. + location -# Display progress as a simple progress bar +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# Display progress as a simple progress bar. + progress-bar -# Show error messages +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# Show error messages. + show-error -# Send a fake UA string for the HTTP servers that sniff it +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# Send a fake UA string for the HTTP servers that sniff it. + user-agent = "Mozilla/5.0 Gecko" diff --git a/src/shell/inputrc b/src/shell/inputrc index 1f379f01a..6e5ca26ab 100644 --- a/src/shell/inputrc +++ b/src/shell/inputrc @@ -1,15 +1,22 @@ #!/bin/bash -# Readline library configuration options +# Readline library configuration options. # http://ss64.com/bash/syntax-inputrc.html # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Disable beeping and window flashing +# Disable beeping and window flashing. + set bell-style none -# Use case-insensitive TAB autocompletion +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# Use case-insensitive TAB autocompletion. + set completion-ignore-case on -# Auto list TAB completions +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# Auto list TAB completions. + set show-all-if-ambiguous off diff --git a/src/shell/screenrc b/src/shell/screenrc index 5aa30b125..60779576f 100644 --- a/src/shell/screenrc +++ b/src/shell/screenrc @@ -3,12 +3,19 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Set the default character encoding to UTF-8 +# Set the default character encoding to UTF-8. + defutf8 on -# Disable the startup message +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# Disable the startup message. + startup_message off +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + # Increase the maximum number of lines contained -# in the scrollback buffer (defaults to 100) +# in the scrollback buffer (defaults to 100). + defscrollback 10000 diff --git a/src/vim/vimrc b/src/vim/vimrc index a173c86a4..a4e783d90 100644 --- a/src/vim/vimrc +++ b/src/vim/vimrc @@ -2,105 +2,105 @@ " | General Settings | " ---------------------------------------------------------------------- -set nocompatible " Don't make vim vi-compatibile +set nocompatible " Don't make Vim vi-compatibile. -syntax on " Enable syntax highlighting +syntax on " Enable syntax highlighting. if has("autocmd") filetype plugin indent on - " │ │ └──── Enable file type detection - " │ └───────── Enable loading of indent file - " └─────────────── Enable loading of plugin files + " │ │ └──── Enable file type detection. + " │ └───────── Enable loading of indent file. + " └─────────────── Enable loading of plugin files. endif -set autoindent " Copy indent to the new line +set autoindent " Copy indent to the new line. set backspace=indent " ┐ set backspace+=eol " │ Allow `backspace` -set backspace+=start " ┘ in insert mode +set backspace+=start " ┘ in insert mode. -set backupdir=~/.vim/backups " Set directory for backup files +set backupdir=~/.vim/backups " Set directory for backup files. set backupskip=/tmp/* " ┐ Don't create backups -set backupskip+=/private/tmp/* " ┘ for certain files +set backupskip+=/private/tmp/* " ┘ for certain files. set clipboard=unnamed " ┐ " │ Use the system clipboard -if has("unnamedplus") " │ as the default register +if has("unnamedplus") " │ as the default register. set clipboard+=unnamedplus " │ endif " ┘ set cpoptions+=$ " When making a change, don't " redisplay the line, and instead, " put a `$` sign at the end of - " the changed text + " the changed text. -set colorcolumn=73 " Highlight certain column(s) -set cursorline " Highlight the current line -set directory=~/.vim/swaps " Set directory for swap files -set encoding=utf-8 nobomb " Use UTF-8 without BOM -set history=5000 " Increase command line history -set hlsearch " Enable search highlighting -set ignorecase " Ignore case in search patterns +set colorcolumn=73 " Highlight certain column(s). +set cursorline " Highlight the current line. +set directory=~/.vim/swaps " Set directory for swap files. +set encoding=utf-8 nobomb " Use UTF-8 without BOM. +set history=5000 " Increase command line history. +set hlsearch " Enable search highlighting. +set ignorecase " Ignore case in search patterns. -set incsearch " Highlight search pattern as - " it is being typed +set incsearch " Highlight search pattern + " as it is being typed. -set laststatus=2 " Always show the status line +set laststatus=2 " Always show the status line. set lazyredraw " Do not redraw the screen while " executing macros, registers " and other commands that have - " not been typed + " not been typed. set listchars=tab:▸\ " ┐ set listchars+=trail:· " │ Use custom symbols to -set listchars+=eol:↴ " │ represent invisible characters +set listchars+=eol:↴ " │ represent invisible characters. set listchars+=nbsp:_ " ┘ -set magic " Enable extended regexp -set mousehide " Hide mouse pointer while typing -set noerrorbells " Disable error bells +set magic " Enable extended regexp. +set mousehide " Hide mouse pointer while typing. +set noerrorbells " Disable error bells. set nojoinspaces " When using the join command, " only insert a single space - " after a `.`, `?`, or `!` + " after a `.`, `?`, or `!`. -set nostartofline " Kept the cursor on the same column -set number " Show line number +set nostartofline " Kept the cursor on the same column. +set number " Show line number. set numberwidth=5 " Increase the minimal number of - " columns used for the `line number` + " columns used for the `line number`. -set report=0 " Report the number of lines changed -set ruler " Show cursor position +set report=0 " Report the number of lines changed. +set ruler " Show cursor position. set scrolloff=5 " When scrolling, keep the cursor " 5 lines below the top and 5 lines - " above the bottom of the screen + " above the bottom of the screen. -set shortmess=aAItW " Avoid all the hit-enter prompts -set showcmd " Show the command being typed -set showmode " Show current mode -set spelllang=en_us " Set the spellchecking language +set shortmess=aAItW " Avoid all the hit-enter prompts. +set showcmd " Show the command being typed. +set showmode " Show current mode. +set spelllang=en_us " Set the spellchecking language. set smartcase " Override `ignorecase` option " if the search pattern contains - " uppercase characters + " uppercase characters. set synmaxcol=2500 " Limit syntax highlighting (this " avoids the very slow redrawing - " when files contain long lines) + " when files contain long lines). set tabstop=4 " ┐ -set softtabstop=4 " │ Set global settings -set shiftwidth=4 " │ http://vimcasts.org/e/2 +set softtabstop=4 " │ Set global settings. +set shiftwidth=4 " │ set expandtab " ┘ -set ttyfast " Enable fast terminal connection -set undodir=~/.vim/undos " Set directory for undo files -set undofile " Automatically save undo history -set virtualedit=all " Allow cursor to be anywhere +set ttyfast " Enable fast terminal connection. +set undodir=~/.vim/undos " Set directory for undo files. +set undofile " Automatically save undo history. +set virtualedit=all " Allow cursor to be anywhere. set visualbell " ┐ set noerrorbells " │ Disable beeping and window flashing @@ -111,30 +111,38 @@ set wildmenu " Enable enhanced command-line " command mode, Vim will show the " possible matches just above the " command line with the first - " match highlighted) + " match highlighted). -set winminheight=0 " Allow windows to be squashed +set winminheight=0 " Allow windows to be squashed. " ---------------------------------------------------------------------- " | Plugins | " ---------------------------------------------------------------------- -" Use Vundle to manage the vim plugins -" https://github.com/gmarik/Vundle.vim +" Use Vundle to manage the Vim plugins. +" https://github.com/VundleVim/Vundle.vim + +" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - " Disable file type detection -" (required by Vundle) +" (this is required by Vundle). + filetype off -" Set the runtime path to include Vundle +" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +" Include Vundle in the runtime path. + set runtimepath+=~/.vim/plugins/Vundle.vim +" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + " Initialize Vundle and specify the path -" where the plugins should be installed +" where the plugins should be installed. + call vundle#begin("~/.vim/plugins") - " Let Vundle manage Vundle (this is important!) Plugin 'gmarik/Vundle.vim' Plugin 'altercation/vim-colors-solarized' @@ -165,6 +173,11 @@ call vundle#begin("~/.vim/plugins") call vundle#end() +" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +" Re-enable file type detection +" (disabling it was required by Vundle). + filetype on @@ -172,14 +185,14 @@ filetype on " | Plugins - Emmet | " ---------------------------------------------------------------------- -" Redefine trigger key for Emmet +" Redefine trigger key for Emmet. " http://docs.emmet.io/cheat-sheet/ let g:user_emmet_leader_key="" " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" Load custom Emmet snippets +" Load custom Emmet snippets. " http://docs.emmet.io/customization/snippets/ let g:user_emmet_settings = webapi#json#decode(join(readfile(expand("~/.vim/snippets/emmet.json")), "\n")) @@ -189,7 +202,7 @@ let g:user_emmet_settings = webapi#json#decode(join(readfile(expand("~/.vim/snip " | Plugins - Indent Guides | " ---------------------------------------------------------------------- -" Set custom indent colors +" Set custom indent colors. " https://github.com/nathanaelkane/vim-indent-guides#setting-custom-indent-colors let g:indent_guides_auto_colors = 0 @@ -207,7 +220,7 @@ autocmd VimEnter,Colorscheme * :hi IndentGuidesEven " | Plugins - Markdown | " ---------------------------------------------------------------------- -" Disable Folding +" Disable Folding. " https://github.com/plasticboy/vim-markdown#disable-folding let g:vim_markdown_folding_disabled=1 @@ -217,14 +230,14 @@ let g:vim_markdown_folding_disabled=1 " | Plugins - NeoComplCache | " ---------------------------------------------------------------------- -" Enable `neocomplcache` by default +" Enable `neocomplcache` by default. " https://github.com/Shougo/neocomplcache.vim#installation let g:neocomplcache_enable_at_startup=1 " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" Make `` autocomplete +" Make `` autocomplete. inoremap pumvisible() ? "\" : "\" @@ -233,13 +246,16 @@ inoremap pumvisible() ? "\" : "\" " | Plugins - Syntastic | " ---------------------------------------------------------------------- -" Inform Syntastic which checkers to use based on file types +" Inform Syntastic which checkers to use based on file types. " https://github.com/scrooloose/syntastic#3-faq let g:syntastic_html_checkers = [ "jshint" ] let g:syntastic_javascript_checkers = [ "jshint" ] -" Disable syntax checking by default +" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +" Disable syntax checking by default. + let g:syntastic_mode_map = { \ "active_filetypes": [], \ "mode": "passive", @@ -267,18 +283,26 @@ endfunction function! StripTrailingWhitespaces() - " Save last search and cursor position + " Save last search and cursor position. + let searchHistory = @/ let cursorLine = line(".") let cursorColumn = col(".") - " Strip trailing whitespaces + " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + " Strip trailing whitespaces. + %s/\s\+$//e - " Restore previous search history and cursor position + " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + " Restore previous search history and cursor position. + let @/ = searchHistory call cursor(cursorLine, cursorColumn) + endfunction " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -286,10 +310,13 @@ endfunction function! ToggleLimits() " [51,73] - " - git commit message + " + " * Git commit message " http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html + " " [81] - " - general use + " + " * general use if ( &colorcolumn == "73" ) set colorcolumn+=51,81 @@ -318,13 +345,13 @@ endfunction if has("autocmd") - " Autocommand Groups + " Autocommand Groups. " http://learnvimscriptthehardway.stevelosh.com/chapters/14.html " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - " Automatically reload the configurations from - " the `~/.vimrc` file whenever they are changed + " the `~/.vimrc` file whenever they are changed. augroup auto_reload_vim_configs @@ -335,30 +362,48 @@ if has("autocmd") " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - " Use relative line numbers + " Use relative line numbers. " http://jeffkreeftmeijer.com/2012/relative-line-numbers-in-vim-for-super-fast-movement/ augroup relative_line_numbers autocmd! - " Automatically switch to absolute line numbers when vim loses focus + " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + " Automatically switch to absolute + " line numbers when Vim loses focus. + autocmd FocusLost * :set number - " Automatically switch to relative line numbers when vim gains focus + " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + " Automatically switch to relative + " line numbers when Vim gains focus. + autocmd FocusGained * :set relativenumber - " Automatically switch to absolute line numbers when vim is in insert mode + " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + " Automatically switch to absolute + " line numbers when Vim is in insert mode. + autocmd InsertEnter * :set number - " Automatically switch to relative line numbers when vim is in normal mode + " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + " Automatically switch to relative + " line numbers when Vim is in normal mode. + autocmd InsertLeave * :set relativenumber + augroup END " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - " Automatically strip the trailing whitespaces when files are saved + " Automatically strip the trailing + " whitespaces when files are saved. augroup strip_trailing_whitespaces @@ -372,8 +417,10 @@ if has("autocmd") \ "mkd.markdown" \] - " Only strip the trailing whitespaces if the file type is - " not in the excluded file types list + " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + " Only strip the trailing whitespaces if + " the file type is not in the excluded list. autocmd! autocmd BufWritePre * if index(excludedFileTypes, &ft) < 0 | :call StripTrailingWhitespaces() @@ -387,13 +434,14 @@ endif " | Color Scheme | " ---------------------------------------------------------------------- -set t_Co=256 " Enable full-color support +set t_Co=256 " Enable full-color support. set background=dark " Use colors that look good - " on a dark background + " on a dark background. " Set custom configurations for when the -" Solarized theme is used from vim's Terminal mode +" Solarized theme is used from Vim's Terminal mode. +" " http://ethanschoonover.com/solarized/vim-colors-solarized#advanced-configuration if !has("gui_running") @@ -403,87 +451,102 @@ if !has("gui_running") let g:solarized_visibility = "high" endif -colorscheme solarized " Use custom color scheme +colorscheme solarized " Use custom color scheme. " ---------------------------------------------------------------------- " | Key Mappings | " ---------------------------------------------------------------------- -" Use a different mapleader (default is "\") +" Use a different mapleader (default is "\"). + let mapleader = "," " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" [,* ] Search and replace the word under the cursor +" [,* ] Search and replace the word under the cursor. + nmap * :%s/\<\>// " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" [,cc] Toggle code comments +" [,cc] Toggle code comments. " https://github.com/tomtom/tcomment_vim + map cc :TComment " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" [,cr] Calculate result +" [,cr] Calculate result. " http://vimcasts.org/e/56 + nmap cr 0yt=A=" " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" [,cs] Clear search +" [,cs] Clear search. + map cs :noh " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" [,h ] JSHint the code +" [,h ] JSHint the code. " https://github.com/Shutnik/jshint2.vim + nmap h :JSHint " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" [,l ] Toggle `set list` +" [,l ] Toggle `set list`. + nmap l :set list! " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" [,n ] Toggle `set relativenumber` +" [,n ] Toggle `set relativenumber`. + nmap n :call ToggleRelativeLineNumbers() " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" [,ss] Strip trailing whitespace +" [,ss] Strip trailing whitespace. + nmap ss :call StripTrailingWhitespaces() " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" [,t ] Toggle NERDTree +" [,t ] Toggle NERDTree. + map t :NERDTreeToggle " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" [,ti] Toggle indent +" [,ti] Toggle indent. + nmap ti IndentGuidesToggle " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" [,tl] Toggle show limits +" [,tl] Toggle show limits. + nmap tl :call ToggleLimits() " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" [,ts] Toggle Syntastic +" [,ts] Toggle Syntastic. + nmap ts :SyntasticToggleMode " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" [,v ] Make the opening of the `.vimrc` file easier +" [,v ] Make the opening of the `.vimrc` file easier. + nmap v :vsp $MYVIMRC " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" [,W ] Sudo write +" [,W ] Sudo write. + map W :w !sudo tee % @@ -527,8 +590,8 @@ highlight User1 set statusline= set statusline+=%1* " User1 highlight set statusline+=\ [%n] " Buffer number -set statusline+=\ %{GetGitBranchName()} " Git branch name -set statusline+=\ [%f] " Path to the file +set statusline+=\ %{GetGitBranchName()} " Git branch name +set statusline+=\ [%f] " File path set statusline+=%m " Modified flag set statusline+=%r " Readonly flag set statusline+=%h " Help file flag @@ -537,7 +600,7 @@ set statusline+=%y " File type set statusline+=[ set statusline+=%{&ff} " File format set statusline+=: -set statusline+=%{strlen(&fenc)?&fenc:'none'} " File encoding +set statusline+=%{strlen(&fenc)?&fenc:'none'} " File encoding set statusline+=] set statusline+=%= " Left/Right separator set statusline+=%c " File encoding @@ -556,11 +619,11 @@ set statusline+=\ (%P)\ " Percent through file " | Local Settings | " ---------------------------------------------------------------------- -" Load local settings if they exist +" Load local settings if they exist. " -" Note: The following needs to remain at the end of this file in -" order to allow any of the above settings to be overwritten -" by the local ones +" [!] The following needs to remain at the end of this file in +" order to allow any of the above settings to be overwritten +" by the local ones. if filereadable(glob("~/.vimrc.local")) source ~/.vimrc.local diff --git a/test/customize_environment.sh b/test/customize_environment.sh index aa46d60c0..f8fa12a82 100755 --- a/test/customize_environment.sh +++ b/test/customize_environment.sh @@ -15,7 +15,9 @@ if [ "$TRAVIS_OS_NAME" = "linux" ]; then # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Install `ShellCheck` (required for testing) + # Install `ShellCheck` + # (required for testing). + sudo apt-get install -qqy shellcheck # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -24,7 +26,9 @@ if [ "$TRAVIS_OS_NAME" = "linux" ]; then elif [ "$TRAVIS_OS_NAME" = "osx" ]; then - # Install `ShellCheck` (required for testing) + # Install `ShellCheck` + # (required for testing). + brew install shellcheck fi @@ -32,6 +36,6 @@ fi # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # To better simulate a clean OS install, remove certain things -# included by default by Travis CI +# included by default by Travis CI. rm -rf "$NVM_DIR" diff --git a/test/run_shellcheck.sh b/test/run_shellcheck.sh index 738b7415c..bb6c9f5e8 100755 --- a/test/run_shellcheck.sh +++ b/test/run_shellcheck.sh @@ -8,7 +8,7 @@ cd "$(dirname "${BASH_SOURCE[0]}")" \ main() { # ' At first you're like "shellcheck is awesome" but then you're - # like "wtf are we still using bash" ' + # like "wtf are we still using bash" '. # # (from: https://twitter.com/astarasikov/status/568825996532707330)