recentpopularlog in

kme : dotfiles   69

MartinHarding/macOSuckless: Scripts, commands, hacks, and tweaks to make macOS suck less.
<code class="language-bash">
# always show the detailed Print dialog
# source:
defaults write -g PMPrintingExpandedStateForPrint -bool TRUE

# Unhide Library folder
# (might require a restart)
chflags nohidden ~/Library

# Expand Save Panel by default
defaults write -g NSNavPanelExpandedStateForSaveMode -bool true
defaults write -g NSNavPanelExpandedStateForSaveMode2 -bool true

# Set Dock size and make it unchangeable
defaults write tilesize -int 48
defaults write size-immutable -bool true
killall Dock

# Dim Dock icon when application is hidden
defaults write showhidden -boolean true
killall Dock

# Add a blank space to the end of Dock
defaults write persistent-apps -array-add '{tile-data={}; tile-type="spacer-tile";}'
killall Dock

# Disable shadows on window screenshots
defaults write disable-shadow -bool true
killall SystemUIServer

# Disable animations when you open an application from the Dock.
defaults write launchanim -bool false

# disable bounce animation when application wants attention
# source:
defaults write no-bouncing -bool TRUE

# Make all animations faster that are used by Mission Control.
# (not sure if this does anything, actually)
defaults write expose-animation-duration -float 0.1

# Fixes an issue with some applications that have poor smoothing in Mojave when not running on Retina monitors.
# (not sure how much good this actually does)
defaults write -g CGFontRenderingFontSmoothingDisabled -bool NO
macos  osx  dotfiles  defaults  annoyances  movein  essential 
11 weeks ago by kme
ingydotnet/...: Dot Dot Dot |
Dot Dot Dot. Contribute to ingydotnet/... development by creating an account on GitHub.
dotfiles  configfiles  bash  shell 
january 2019 by kme
shell - What's the difference between .bashrc, .bash_profile, and .environment? - Stack Overflow |
The main difference with shell config files is that some are only read by "login" shells (eg. when you login from another host, or login at the text console of a local unix machine). these are the ones called, say, .login or .profile or .zlogin (depending on which shell you're using).

Then you have config files that are read by "interactive" shells (as in, ones connected to a terminal (or pseudo-terminal in the case of, say, a terminal emulator running under a windowing system). these are the ones with names like .bashrc, .tcshrc, .zshrc, etc.

bash complicates this in that .bashrc is only read by a shell that's both interactive and non-login, so you'll find most people end up telling their .bash_profile to also read .bashrc with something like

<code class="language-bash">
[[ -r ~/.bashrc ]] && . ~/.bashrc

Other shells behave differently - eg with zsh, .zshrc is always read for an interactive shell, whether it's a login one or not.

The manual page for bash explains the circumstances under which each file is read. Yes, behaviour is generally consistent between machines.

.profile is simply the login script filename originally used by /bin/sh. bash, being generally backwards-compatible with /bin/sh, will read .profile if one exists.
unix  linux  bash  loginscripts  dotfiles  newbie  questions  dammitbrain 
january 2018 by kme
How to install autojump for Fish – Code Yarns

Source the file in your fish configuration, by opening the file ~/.config/fish/ in an editor and adding these lines:


set --local AUTOJUMP_PATH $HOME/.autojump/share/autojump/
if test -e $AUTOJUMP_PATH
fish  autojump  shell  configfile  dotfiles  solution 
january 2017 by kme
[Configuring IPython]
Add 'c.TerminalInteractiveShell.confirm_exit = False' to $profile/ (courtesy
python  ipython  configuration  dotfiles  solution 
january 2017 by kme
SSH agent forwarding and screen
To have SSH within a screen session use the symlink, add the following line to ~/.screenrc:

setenv SSH_AUTH_SOCK $HOME/.ssh/ssh_auth_sock

To update the symlink we'll use the ~/.ssh/rc file which is executed by SSH on each connection. This can be any executable file, so something like the following script will do:

if test "$SSH_AUTH_SOCK" ; then
ln -sf $SSH_AUTH_SOCK ~/.ssh/ssh_auth_sock

Also, from the comments, the same thing can be done in a ~/.bashrc:

if [[ -n "$SSH_TTY" && -S "$SSH_AUTH_SOCK" ]]; then
ln -sf $SSH_AUTH_SOCK ~/.ssh/ssh_auth_sock

And for tmux (courtesy:
# fix ssh agent when tmux is detached
setenv -g SSH_AUTH_SOCK $HOME/.ssh/ssh_auth_sock
screen  tmux  ssh  ssh-agent  dotfiles  solution 
june 2016 by kme
linux - What useful things can one add to one's .bashrc? - Server Fault

There's a nice and simple linux command called "unp", the Unpacker that does this and more. – Sander Marechal May 10 '09 at 23:33

Newer versions of tar detect automatically the archive type, so can extract all supported formats by just 'tar xvf'. – Prof. Moriarty Jun 8 '10 at 17:47

@Sander dtrx isn't bad at that either. It makes sure the archive extracts to its own subdirectory. – Tobu Jul 2 '10 at 10:29

up() { cd $(eval printf '../'%.0s {1..$1}) && pwd; }

The 'folders' alias is great! I modified it slightly so that directories with spaces don't cause errors.

alias folders='find . -maxdepth 1 -type d -print0 | xargs -0 du -sk | sort -rn'
bashrc  customization  dotfiles  shell  movein  tipsandtricks  unarchive 
june 2016 by kme
Can I "export" functions in bash? - Unix & Linux Stack Exchange
This is why the 'module' shell function wasn't available to me within 'screen'; because it had been sourced from /etc/profile.d, and was therefore not available to subshells started from screen.
In Bash you can export function definitions to sub-shell with

export -f function_name

Functions are not exported to subprocesses. This is why there are files named .kshrc or .bashrc: To define functions that shoiuld be available in subshells also.
bash  solution  functions  configfiles  dotfiles 
march 2016 by kme
howto/bash-completion – MacPorts
You really do need to set the startup command in iTerm or whatever. I thought I was getting burned by MacPort's bash_completion package, but it needs a newer version of Bash than what's provided with OS X 10.11.whatever.
mac  osx  bash  completion  autocomplete  howto  dotfiles  solution 
march 2016 by kme
Linux command line tips: history and HISTIGNORE in Bash - TechRepublic -
Note that a literal tab may be required in the HISTIGNORE character set; or just use 'HISTCONTROL=ignorespace' as suggested in the comments.
Some people use this variable to keep their history file nice and tidy, by removing the commands that they're unlikely to bother recalling, such as ls, fg or exit. Another good tip comes from this page which includes the tip that if you add "[ \t]*" to your HISTIGNORE variable you can make any command be ignored by starting it with a space. Good if you need a little extra privacy for some commands.

I know this post is too old, but since it shows up in google search on "histignore", I have to add, that there's more-- em, 'built-in' way of ignoring commands that start with " ". So, instead of adding "[ \t]*" to HISTIGNORE, you can use HISTCONTROL=ignorespace. But actually I don't know if it makes any difference. Just makes your .bashrc more readable.
bash  security  dotfiles  history  solution 
november 2015 by kme
path - Which setup files should be used for setting up environment variables with bash? - Super User
Note that sometimes you'll see recommendations to either set environment variables in ~/.bashrc, or start a login shell in each terminal in a GUI environment. Both are bad ideas; one of the reasons is the problem you've experienced, namely that your environment variables were only available in programs started via a terminal, and not in programs started directly with an icon or menu or keyboard shortcut.
bash  shell  dotfiles  rcfiles  initfile  path  environmentvariables  wrongforsolong  solution 
may 2015 by kme
bash - Duplicate entries in $PATH a problem? - Unix & Linux Stack Exchange
Side note: .bashrc is not the right place to set $PATH or any other environment variable. Environment variables should be set in ~/.profile. See Which setup files should be used for setting up environment variables with bash?, Difference between .bashrc and .bash_profile.
bash  path  rcfiles  dotfiles  sysadmin  ohsothatswhy  wrongforsolong  solution 
may 2015 by kme
linux - What useful things can one add to one's .bashrc? - Server Fault
My version of the 'fawk' function from this article:
function fawk {
USAGE="usage: fawk [<awk_args>] <field_no>\n"
if [ $# -eq 0 ]; then
echo -e $USAGE >&2
#exit 1 # whoops! that would quit the shell!

# bail if the *last* argument isn't a number
if ! [ $last -eq $last ] &>/dev/null; then
echo "Last argument (awk field) must be numeric." >&2
echo -e $USAGE >&2;

if [ $# -gt 1 ]; then
rest=${@:1:$(( $# - 1 ))}
rest='' # just to be sure
awk $rest "{ print \$$last }"
bash  bashrc  recommendations  configfile  dotfiles  unix  sysadmin  tipsandtricks 
november 2014 by kme
Hide files on apache webserver Apache Web Server forum at WebmasterWorld
You could also create a directory inside your web/html directory and chmod it to 700. Place your files in that directory. That should make them inaccesible by web browsers.

Oh. Yeah. That would work, wouldn't it.
apache  git  versioncontrol  dotfiles  webmaster  solution 
october 2014 by kme
Deny access to .svn folders on Apache - Stack Overflow []
This actually seemed to work when placed in the top-level httpd config file, right next to the Files ~ "^\.ht" directive:

<code style="language-apache">
# Same for version control directories
<DirectoryMatch ".*\.(git|svn)/.*">
Order allow,deny
Deny from all
Satisfy All

I think the "Satisfy All" is key, otherwise an authenticated user might see the files anyway.

I also tried this one time:
<code style="language-apache">
RedirectMatch 404 /\\.svn(/|$)

and it worked okay in a .htaccess file.
apache  htaccess  svn  dotfiles  webmaster  configfile  security  solution 
october 2014 by kme
Rob Pike - Google+ - A lesson in shortcuts. Long ago, as the design of the Unix… -

A lesson in shortcuts.

Long ago, as the design of the Unix file system was being worked out, the entries . and .. appeared, to make navigation easier. I'm not sure but I believe .. went in during the Version 2 rewrite, when the file system became hierarchical (it had a very different structure early on).  When one typed ls, however, these files appeared, so either Ken or Dennis added a simple test to the program. It was in assembler then, but the code in question was equivalent to something like this:
   if (name[0] == '.') continue;
This statement was a little shorter than what it should have been, which is
   if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0) continue;
but hey, it was easy.

Two things resulted.

First, a bad precedent was set. A lot of other lazy programmers introduced bugs by making the same simplification. Actual files beginning with periods are often skipped when they should be counted.

Second, and much worse, the idea of a "hidden" or "dot" file was created. As a consequence, more lazy programmers started dropping files into everyone's home directory. I don't have all that much stuff installed on the machine I'm using to type this, but my home directory has about a hundred dot files and I don't even know what most of them are or whether they're still needed. Every file name evaluation that goes through my home directory is slowed down by this accumulated sludge.

I'm pretty sure the concept of a hidden file was an unintended consequence. It was certainly a mistake.

How many bugs and wasted CPU cycles and instances of human frustration (not to mention bad design) have resulted from that one small shortcut about  40 years ago?

Keep that in mind next time you want to cut a corner in your code.

(For those who object that dot files serve a purpose, I don't dispute that but counter that it's the files that serve the purpose, not the convention for their names. They could just as easily be in $HOME/cfg or $HOME/lib, which is what we did in Plan 9, which had no dot files. Lessons can be learned.)
unix  history  dotfiles  thereasonwhy  shortcuts  plan9  robpike 
march 2014 by kme

Copy this bookmark:

to read