From f9239201a42b9a23802bb8cb65044c7ebe1d2f17 Mon Sep 17 00:00:00 2001 From: Artem Sheremet Date: Sun, 3 Jan 2021 21:30:39 +0100 Subject: [PATCH] Merge config with Crostini and improve compat --- .bash_logout | 7 + .bashrc | 34 ++- .config/systemd/user/code-server.service | 2 +- .profile | 18 +- .sommelierrc | 13 + .bash_colors => .term_color_shell_constants | 0 bin/colorgcc | 254 -------------------- 7 files changed, 61 insertions(+), 267 deletions(-) create mode 100644 .bash_logout create mode 100644 .sommelierrc rename .bash_colors => .term_color_shell_constants (100%) delete mode 100755 bin/colorgcc diff --git a/.bash_logout b/.bash_logout new file mode 100644 index 0000000..de4f5f7 --- /dev/null +++ b/.bash_logout @@ -0,0 +1,7 @@ +# ~/.bash_logout: executed by bash(1) when login shell exits. + +# when leaving the console clear the screen to increase privacy + +if [ "$SHLVL" = 1 ]; then + [ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q +fi diff --git a/.bashrc b/.bashrc index b33a088..a539fc1 100644 --- a/.bashrc +++ b/.bashrc @@ -1,6 +1,8 @@ -. /etc/profile -# colors -. ~/.bash_colors +# ~/.bashrc: executed by bash(1) for non-login shells. +# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) +# for examples + +. ~/.term_color_shell_constants # bash history with time export HISTTIMEFORMAT="%F %T " @@ -9,7 +11,9 @@ export HISTTIMEFORMAT="%F %T " 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) +# don't put duplicate lines or lines starting with space in the history. +# See bash(1) for more options +HISTCONTROL=ignoreboth HISTSIZE=100000 HISTFILESIZE=5000000 PROMPT_DIRTRIM=5 @@ -18,6 +22,9 @@ PROMPT_DIRTRIM=5 shopt -s checkwinsize # make less more friendly for non-text input files, see lesspipe(1) [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" +# If set, the pattern "**" used in a pathname expansion context will +# match all files and zero or more directories and subdirectories. +shopt -s globstar ## ## prompt games @@ -104,16 +111,21 @@ export NCURSES_NO_UTF8_ACS=1 # file associations! export WINEDLLOVERRIDES=winemenubuilder.exe=d -if [[ "$OSTYPE" == "darwin"* ]]; then +# colored GCC warnings and errors +export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' + +# 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 -hF --color=auto' +else export CLICOLOR=1 alias ls='ls -hF' -else - alias ls='ls -hF --color=auto' - # treat directory name commands as cd. bash is super old on Mac and - # does not support this option. - shopt -s autocd fi -alias pgrep='pgrep -lf' + +# treat directory name commands as cd, may not be supported in old bash version. +shopt -s autocd 2>/dev/null || true + alias crontab='crontab -i' alias gmake='make' alias nc='nc -vv' diff --git a/.config/systemd/user/code-server.service b/.config/systemd/user/code-server.service index 6d4e30a..3e63261 100644 --- a/.config/systemd/user/code-server.service +++ b/.config/systemd/user/code-server.service @@ -2,7 +2,7 @@ Description=VSCode Server [Service] -ExecStart=code-server --auth none --user-data-dir %h/.config/Code --extensions-dir %h/.vscode/extensions +ExecStart=%h/pkg/code-server/code-server --auth none --user-data-dir %h/.config/Code --extensions-dir %h/.vscode/extensions [Install] WantedBy=default.target diff --git a/.profile b/.profile index 4b18bd1..f9a84c1 100644 --- a/.profile +++ b/.profile @@ -1 +1,17 @@ -source $HOME/.bashrc +# ~/.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 diff --git a/.sommelierrc b/.sommelierrc new file mode 100644 index 0000000..544b748 --- /dev/null +++ b/.sommelierrc @@ -0,0 +1,13 @@ +# Copyright 2020 The Chromium OS Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +# +# Use this file to customize per-user sommelier options. +# +# For documentation, see: +# https://chromium.googlesource.com/chromiumos/platform2/+/HEAD/vm_tools/sommelier/ + +# Example: Set default X resources at startup. +#if [ -f ~/.Xresources ]; then +# xrdb -merge ~/.Xresources +#fi diff --git a/.bash_colors b/.term_color_shell_constants similarity index 100% rename from .bash_colors rename to .term_color_shell_constants diff --git a/bin/colorgcc b/bin/colorgcc deleted file mode 100755 index 3cc7899..0000000 --- a/bin/colorgcc +++ /dev/null @@ -1,254 +0,0 @@ -#! /usr/bin/perl -w - -# -# colorgcc -# -# Version: 1.3.2 -# -# $Id: colorgcc,v 1.10 1999/04/29 17:15:52 jamoyers Exp $ -# -# A wrapper to colorize the output from compilers whose messages -# match the "gcc" format. -# -# Requires the ANSIColor module from CPAN. -# -# Usage: -# -# In a directory that occurs in your PATH _before_ the directory -# where the compiler lives, create a softlink to colorgcc for -# each compiler you want to colorize: -# -# g++ -> colorgcc -# gcc -> colorgcc -# cc -> colorgcc -# etc. -# -# That's it. When "g++" is invoked, colorgcc is run instead. -# colorgcc looks at the program name to figure out which compiler to run. -# -# The default settings can be overridden with ~/.colorgccrc. -# See the comments in the sample .colorgccrc for more information. -# -# Note: -# -# colorgcc will only emit color codes if: -# -# (1) Its STDOUT is a tty and -# (2) the value of $TERM is not listed in the "nocolor" option. -# -# If colorgcc colorizes the output, the compiler's STDERR will be -# combined with STDOUT. Otherwise, colorgcc just passes the output from -# the compiler through without modification. -# -# Author: Jamie Moyers -# Started: April 20, 1999 -# Licence: GNU Public License -# -# Credits: -# -# I got the idea for this from a script called "color_cvs": -# color_cvs .03 Adrian Likins -# -# (Scott Harrington) -# Much improved handling of compiler command line arguments. -# exec compiler when not colorizing to preserve STDOUT, STDERR. -# Fixed my STDIN kludge. -# -# (Elias S. G. Carotti) -# Corrected handling of text like -DPACKAGE=\"Package\" -# Spotted return code bug. -# -# (Erwin S. Andreasen) -# (Steve Churchill) -# Return code bug fixes. -# -# (Rik Hemsley) -# Found STDIN bug. -# -# Changes: -# -# 1.3.2 Better handling of command line arguments to compiler. -# -# If we aren't colorizing output, we just exec the compiler which -# preserves the original STDOUT and STDERR. -# -# Removed STDIN kludge. STDIN being passed correctly now. -# -# 1.3.1 Added kludge to copy STDIN to the compiler's STDIN. -# -# 1.3.0 Now correctly returns (I hope) the return code of the compiler -# process as its own. -# -# 1.2.1 Applied patch to handle text similar to -DPACKAGE=\"Package\". -# -# 1.2.0 Added tty check. If STDOUT is not a tty, don't do color. -# -# 1.1.0 Added the "nocolor" option to turn off the color if the terminal type -# ($TERM) is listed. -# -# 1.0.0 Initial Version - -use Term::ANSIColor; -use IPC::Open3; - -sub initDefaults -{ - $compilerPaths{"gcc"} = "/usr/bin/gcc"; - $compilerPaths{"g++"} = "/usr/bin/g++"; - $compilerPaths{"cc"} = "/usr/bin/cc"; - $compilerPaths{"c++"} = "/usr/bin/c++"; - - $nocolor{"dumb"} = "true"; - - $colors{"srcColor"} = color("cyan"); - $colors{"introColor"} = color("blue"); - - $colors{"warningFileNameColor"} = color("yellow"); - $colors{"warningNumberColor"} = color("yellow"); - $colors{"warningMessageColor"} = color("yellow"); - - $colors{"errorFileNameColor"} = color("bold red"); - $colors{"errorNumberColor"} = color("bold red"); - $colors{"errorMessageColor"} = color("bold red"); -} - -sub loadPreferences -{ -# Usage: loadPreferences("filename"); - - my($filename) = @_; - - open(PREFS, "<$filename") || return; - - while() - { - next if (m/^\#.*/); # It's a comment. - next if (!m/(.*):\s*(.*)/); # It's not of the form "foo: bar". - - $option = $1; - $value = $2; - - if ($option =~ m/cc|c\+\+|gcc|g\+\+/) - { - $compilerPaths{$option} = $value; - } - elsif ($option eq "nocolor") - { - # The nocolor option lists terminal types, separated by - # spaces, not to do color on. - foreach $termtype (split(/\s+/, $value)) - { - $nocolor{$termtype} = "true"; - } - } - else - { - $colors{$option} = color($value); - } - } - close(PREFS); -} - -sub srcscan -{ -# Usage: srcscan($text, $normalColor) -# $text -- the text to colorize -# $normalColor -- The escape sequence to use for non-source text. - -# Looks for text between ` and ', and colors it srcColor. - - my($line, $normalColor) = @_; - - my($srcon) = color("reset") . $colors{"srcColor"}; - my($srcoff) = color("reset") . $normalColor; - - $line = $normalColor . $line; - - # This substitute replaces `foo' with `AfooB' where A is the escape - # sequence that turns on the the desired source color, and B is the - # escape sequence that returns to $normalColor. - $line =~ s/\`(.*?)\'/\`$srcon$1$srcoff\'/g; - - print($line, color("reset")); -} - -# -# Main program -# - -# Set up default values for colors and compilers. -initDefaults(); - -# Read the configuration file, if there is one. -$configFile = $ENV{"HOME"} . "/.colorgccrc"; -if (-f $configFile) -{ - loadPreferences($configFile); -} - -# Figure out which compiler to invoke based on our program name. -$0 =~ m%.*/(.*)$%; -$progName = $1 || $0; - -$compiler = $compilerPaths{$progName} || $compilerPaths{"gcc"}; - -# Get the terminal type. -$terminal = $ENV{"TERM"} || "dumb"; - -# If it's in the list of terminal types not to color, or if -# we're writing to something that's not a tty, don't do color. -if (! -t STDOUT || $nocolor{$terminal}) -{ - exec $compiler, @ARGV - or die("Couldn't exec"); -} - -# Keep the pid of the compiler process so we can get its return -# code and use that as our return code. -$compiler_pid = open3('<&STDIN', \*GCCOUT, '', $compiler, @ARGV); - -# Colorize the output from the compiler. -while() -{ - if (m/^(.*?):([0-9]+):(.*)$/) # filename:lineno:message - { - $field1 = $1 || ""; - $field2 = $2 || ""; - $field3 = $3 || ""; - - if ($field3 =~ m/\s+warning:.*/) - { - # Warning - print($colors{"warningFileNameColor"}, "$field1:", color("reset")); - print($colors{"warningNumberColor"}, "$field2:", color("reset")); - srcscan($field3, $colors{"warningMessageColor"}); - } - else - { - # Error - print($colors{"errorFileNameColor"}, "$field1:", color("reset")); - print($colors{"errorNumberColor"}, "$field2:", color("reset")); - srcscan($field3, $colors{"errorMessageColor"}); - } - print("\n"); - } - elsif (m/^(.*?):(.+):$/) # filename:message: - { - # No line number, treat as an "introductory" line of text. - srcscan($_, $colors{"introColor"}); - } - else # Anything else. - { - # Doesn't seem to be a warning or an error. Print normally. - print(color("reset"), $_); - } -} - -# Get the return code of the compiler and exit with that. -waitpid($compiler_pid, 0); -exit ($? >> 8); - - - - -