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).inputrcsettings for keyboard input (like case insensitive completion).vimrcsettings for vim (not vi; mappings, functions etc.).screenrcsettings for screen (not tmux yet).ackrcsettings for ack (or ack-grep how it's called in Debian repositories).git*default settings and ignores for git.profilecommands to execute after login (basic system information).pam_environmentuser 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 thetimebash 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=3environment 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 anithe shell is interactive (that is: no script but user input)- normal bash startup order is (first wins):
/etc/profile,~/.bash_profile,~/.bash_loginand~/.profile - typically
~/.bash_profileexecutes~/.bashrc(not vice versa) ~/.bash_profileis executed for login shells while~/.bashrcis executed for interactive non-login shells- to really execute
~/.bash_profilestart bash with a-lor--loginoption - put bash unspecific things in
~/.profileas switching shells becomes easier - bash specific settings should be set in
~/.bashrc(as it may not be your login shell)
pprinthhead - remove a trailing file name component, leaving only the headttail - remove all leading file name components, leaving the tailrremove a trailing suffix of the form .xxx, leaving the basenameeremove all but the trailing suffixssubstitue strings (replace first match)gsglobal substitute (replace all matches)&repeat the previous substitution- word modifiers are stackable
- words are whitespace delimited
!!repeat last command from history!foorepeat last command beginning withfoo!foo:pprint last command beginning withfoo- it adds to the history as well, thus you cann use!!directly if the command looks good!Nexecute the command with numberN!-Nexecute the commandNcommands ago!$reuse the 'end' of the last command (reuse the last word)!$:pprint last argument from previous command (:pis aword modifier)!*reuse all arguments from previous command!#:1reuse second argument from current command (ls foo !#:1=>ls foo foo)^error^correctioncorrect and execute previous command (replace and execute)- given the command
cat /usr/local/share/doc/foo/bar.baz:cd !$:hchange to directory (:hremovesbar.baz)cat !-2$:topenbar.bazas that is the tail of the 2nd last commandmkdir !-3$:t:rcreate directorybar(:tremoves tailing path and:rremoves the.bazextension)
!!:s/foo/bar/execute last command with the firstfoooccurrence replaced bybar!!:gs/foo/bar/execute last command with all occurrences offooreplaced bybar!!:s/foo/&.bar/- execute the last command with the firstfooreplaced 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}copyfilenametofilename-oldcp filename{-v1,-v2}copyfilename-v1tofilename-v2touch foo{1,2,3}barcreate filesfoo1bar,foo2barandfoo3bar- 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 pipesetcommandset -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
shoptcommandshopt -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
~/.profilefor whole session settings like programs to run on log in and the start of the display manager. May be used for environment variable definitions.~/.bashrcfor bash specific settings like alias and function definitions, shell options and prompt settings.~/.inputrcfor key bindings and other input related settings.~/.bash_profilecan be used instead of~/.profile, but you also need to include~/.bashrcif 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.
LANGbasic language setting used by applications on the system (may be overridden by more specific locale environment variables)LC_CTYPEcharacter set used to display and input textLC_NUMERIChow non-monetary numeric values are formatted on screenLC_TIMEhow date and time values are formattedLC_COLLATEhow to sort various information items (e.g. sort command behaviour)LC_MONETARYhow monetary numeric values are formattedLC_MESSAGESlanguage to display messages to the end userLC_PAPERdefinitions of paper formats and standardsLC_NAMEhow names are formattedLC_ADDRESShow to display address informationLC_TELEPHONEhow telephone numbers are structuredLC_MEASUREMENTwhat units of measurement are usedLC_IDENTIFICATIONmetadata about the locale informationLC_ALLoverride 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(.bashrcexportsNPM_CONFIG_PREFIX=~/.npm-global) - for
vim-php-namespaceto 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-pygmentsgem 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,escapefrom @mathiasbynens) bin/git-openbin/twig-lintbin/phpcs
