Various dotfiles I use and want to have available elsewhere. Probably a lot of this is Ubuntu-only so handle with care if you re-use aliases etc. :-)
.bash*
settings for bash (prompt, aliases, functions).inputrc
settings for keyboard input (like case insensitive completion).vimrc
settings for vim (not vi; mappings, functions etc.).screenrc
settings for screen (not tmux yet).ackrc
settings for ack (or ack-grep how it's called in Debian repositories).git*
default settings and ignores for git.profile
commands to execute after login (basic system information).pam_environment
user environment locale settings with one assignment expression per line (I prefer english/utf-8 messages with german numbers and dates etc.)
Clone the repository to a folder of your choice and copy wanted or all files:
git clone --depth=1 git://github.com/graste/dotfiles-etc.git
cd dotfiles-etc && ./copy-files.sh [all]
Without installed git
you can try to use curl
or wget
:
curl -#L https://github.com/graste/dotfiles-etc/tarball/master | tar -xzv --strip-components 1
Screenshot with a glimpse of vim status line, screen status line and the bash prompt with exit code coloring and git status information:
# <time> <history-id> <exit-code> (<git-branch> <git-branch-tracking>|<git-local-status>) <path> $
#
mitigates execution of accidental pastes in the command line<time>
as often long running commands are not called with thetime
bash builtin<history-id>
to execute earlier commands via!<history-id>
when seeing one in the scrollback buffer<exit-code>
shell exit code of last command (color in bold red if it's not zero)(<git-branch> <git-branch-tracking>|<git-local-status>)
displays detailed useful information about the git repository in the current working directory (not displayed if not in a git directory)<git-branch>
name of the currently checked out branch<git-branch-tracking>
number of commits ahead/behind of remote<git-local-status>
number of staged/modified/conflicted/untracked files
<path>
current working directory shortened viaPROMPT_DIRTRIM=3
environment variable and colored according to user permissions- in green: user owns directory
- in yellow: user is allowed to write in directory
- in red: user is not allowed to write in directory
You can disable the git
part of the prompt by exporting USE_GIT_IN_PROMPT=no
:
# 18:11:01 0 (master|✚ 1) ~/projects/graste/dotfiles-etc $ export USE_GIT_IN_PROMPT=no
# 18:11:03 0 ~/projects/graste/dotfiles-etc $
- RTFM: Bash Reference Manual
echo $-
: list shell options - if it contains ani
the shell is interactive (that is: no script but user input)- normal bash startup order is (first wins):
/etc/profile
,~/.bash_profile
,~/.bash_login
and~/.profile
- typically
~/.bash_profile
executes~/.bashrc
(not vice versa) ~/.bash_profile
is executed for login shells while~/.bashrc
is executed for interactive non-login shells- to really execute
~/.bash_profile
start bash with a-l
or--login
option - put bash unspecific things in
~/.profile
as switching shells becomes easier - bash specific settings should be set in
~/.bashrc
(as it may not be your login shell)
p
printh
head - remove a trailing file name component, leaving only the headt
tail - remove all leading file name components, leaving the tailr
remove a trailing suffix of the form .xxx, leaving the basenamee
remove all but the trailing suffixs
substitue strings (replace first match)gs
global substitute (replace all matches)&
repeat the previous substitution- word modifiers are stackable
- words are whitespace delimited
!!
repeat last command from history!foo
repeat last command beginning withfoo
!foo:p
print last command beginning withfoo
- it adds to the history as well, thus you cann use!!
directly if the command looks good!N
execute the command with numberN
!-N
execute the commandN
commands ago!$
reuse the 'end' of the last command (reuse the last word)!$:p
print last argument from previous command (:p
is aword modifier
)!*
reuse all arguments from previous command!#:1
reuse second argument from current command (ls foo !#:1
=>ls foo foo
)^error^correction
correct and execute previous command (replace and execute)- given the command
cat /usr/local/share/doc/foo/bar.baz
:cd !$:h
change to directory (:h
removesbar.baz
)cat !-2$:t
openbar.baz
as that is the tail of the 2nd last commandmkdir !-3$:t:r
create directorybar
(:t
removes tailing path and:r
removes the.baz
extension)
!!:s/foo/bar/
execute last command with the firstfoo
occurrence replaced bybar
!!:gs/foo/bar/
execute last command with all occurrences offoo
replaced bybar
!!:s/foo/&.bar/
- execute the last command with the firstfoo
replaced by.bar
<alt+.>
to insert last argument on current cursor position (repeatable)<ctrl+w>
erase word<ctrl+u>
erase from cursor to beginning of the line<ctrl+a>
move the cursor to the beginning of the line<ctrl+e>
move the curor to the end of the line
cp filename{,-old}
copyfilename
tofilename-old
cp filename{-v1,-v2}
copyfilename-v1
tofilename-v2
touch foo{1,2,3}bar
create filesfoo1bar
,foo2bar
andfoo3bar
- multiple brace expansions can be used together and nested (not that that would be readable)
|&
===2>&1 |
: standard error of command1 is connected to command2's standard input through the pipeset
commandset -o
: list currently configured shell optionsset -o variable_name
: set optionset +o variable_name
: unset optionset +e ; command_that_might_fail_but_we_want_to_ignore_it ; set -e
===command_that_might_fail_but_we_want_to_ignore_it || true
shopt
commandshopt -p
: list of some of the currently configured variables that control optional behaviourshopt -s option_name
: enable/set optionshopt -u option_name
: disable/unset option
echo $SHLVL
: get subshell level (toplevel is 1)- default time format:
TIMEFORMAT=$'\nreal\t%3lR\nuser\t%3lU\nsys\t%3lS'
- diff two file listings via process substitution:
diff <(ls -1a ./dir1) <(ls -1a ./dir2)
or usediff -bur dir1 dir2
~/.profile
for whole session settings like programs to run on log in and the start of the display manager. May be used for environment variable definitions.~/.bashrc
for bash specific settings like alias and function definitions, shell options and prompt settings.~/.inputrc
for key bindings and other input related settings.~/.bash_profile
can be used instead of~/.profile
, but you also need to include~/.bashrc
if the shell is interactive.
See e.g. Unix shell initialization for a short introduction on different shells and their startup files.
The ~/.pam_environment
file contains session-wide user-environment locale settings with one assignment expression per line. To activate changes to this file one has to re-login.
LANG
basic language setting used by applications on the system (may be overridden by more specific locale environment variables)LC_CTYPE
character set used to display and input textLC_NUMERIC
how non-monetary numeric values are formatted on screenLC_TIME
how date and time values are formattedLC_COLLATE
how to sort various information items (e.g. sort command behaviour)LC_MONETARY
how monetary numeric values are formattedLC_MESSAGES
language to display messages to the end userLC_PAPER
definitions of paper formats and standardsLC_NAME
how names are formattedLC_ADDRESS
how to display address informationLC_TELEPHONE
how telephone numbers are structuredLC_MEASUREMENT
what units of measurement are usedLC_IDENTIFICATION
metadata about the locale informationLC_ALL
override over all the other locale environment variables (applications use this variable if it's set, regardless of other variables' values)
pathogen
is used to handle plugins, syntax highlighting etc. For details see .vim/bundle
.
For syntax checking with syntastic
the following (ubuntu) packages may be useful:
sudo apt-get install pylint tidy libxml2-utils make puppet-lint
- for other (nodejs based) linters (see here for nodejs install or use chris lea PPA on older Ubuntu):
-
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
-sudo apt-get install -y nodejs npm
-npm install -g less sass sass-lint jshint js-yaml csslint jsonlint dockerfile_lint markdownlint-cli
(.bashrc
exportsNPM_CONFIG_PREFIX=~/.npm-global
) - for
vim-php-namespace
to work, exuberant-ctags is necessary.sudo apt-get install exuberant-ctags
sudo apt-get install software-properties-common python-software-properties python g++ make python-pygments
gem install ruby-lint puppet-lint flog scss_lint haml_lint
Generate ctags completion files in your project's root folder like this:
ctags -nR --PHP-kinds=+cf --exclude='.git' --exclude='*.phar' --exclude="*.min.js" --regex-php='/^[ \t]*trait[ \t]+([a-z0_9_]+)/\1/t,traits/i' -f tags .
There's a bash function called create-ctags
that may be called in project directories to create a tags
file (see .bash/functions.sh
).
- The customized git status information prompt was adapted from: https://github.com/magicmonty/bash-git-prompt
- various dotfiles of other people (e.g. bash functions
calc
,json
,gz
,unidecode
,escape
from @mathiasbynens) bin/git-open
bin/twig-lint
bin/phpcs