bash ls

jbo75

Active Member
Kann man in der bash den Befehl ls -lhG permanent für ls definieren?
Ich hab schon im Wiki nachgeschaut und alias ls="ls -hlG" probiert.
Das klappt zwar, aber halt nur temporär.
 
Code:
echo 'alias ls="ls -Ghl"' >> ~/.bash_profile
. ~/.bash_profile

-Update-
.bashrc ersetzt durch .bash_profile, da die bash ja wahrscheinlich deine login shell ist
 
Zuletzt bearbeitet:
Die ~/.bash_profile wurde korrekt erstellt und es klappt auch, jedoch wieder nur temporär. sobald ich eine neue console öffne ist alles wieder beim alten. Oder muss ich z.B aterm immer mit aterm -e . ~/.bash_profile starten?



edit:

also das aterm -e . ~/.bash_profile hab ich probiert und es klappt nicht.
aber mit der .bashrc klappt es genau so wie ich es will.
Danke ;)
 
Zuletzt bearbeitet:
jbo75 schrieb:
Die ~/.bash_profile wurde korrekt erstellt und es klappt auch, jedoch wieder nur temporär. sobald ich eine neue console öffne ist alles wieder beim alten. Oder muss ich z.B aterm immer mit aterm -e . ~/.bash_profile starten?



edit:

also das aterm -e . ~/.bash_profile hab ich probiert und es klappt nicht.
aber mit der .bashrc klappt es genau so wie ich es will.
Danke ;)

~/.bash_profile wird nur beim Login ausgefuehrt. Du musst dich also neu anmelden um diese Datei neu zu uebernehmen.

Noch ein Tipp: Nimm Zsh :D
 
Was hat denn Zsh für Vorteile?
Ich muss dazu sagen das ich noch recht neu in der Unix Umgebung bin.
Bash habe ich eigentlich nur wegen dem autocomplete mit Tab genommen, das war unter sh immer ein Krampf :;)
 
Probieren geht über Studieren; deshalb hier mal meine .zshrc. Installier Dir die zsh, .zshrc nach ~ und probier mal ein Bisschen, z.B. Tab in fast jeder Lebenslage, **, Verzeichnis ohne cd wechseln, +/- um durch dirs zu navigieren, gutes VI-Lineediting ...

Code:
#################
# .zshrc danlei #
#################


cdpath=(. .. ~ ~/src ~/zsh)

# Use hard limits, except for a smaller stack and no core dumps
unlimit
limit stack 8192
limit core 0
limit -s

umask 022



# Set up aliases
alias mv='nocorrect mv'       # no spelling correction on mv
alias cp='nocorrect cp'       # no spelling correction on cp
alias mkdir='nocorrect mkdir' # no spelling correction on mkdir
alias md='nocorrect mkdir'
alias locate='nocorrect locate'

alias emacs='emacs -nw'


alias ls='ls -G'
alias l='ls'
alias rd='rmdir'
alias ll='ls -lh'
alias la='ls -alh'
alias ld='ls -dh'

# List only directories and symbolic
# links that point to directories
alias lsd='ls -ld *(-/DN)'

# List only file beginning with "."
alias l.='ls -ldh .*'


alias dirs='dirs -v'
alias df='df -h'
alias du='du -h'
alias c='clear'


# cd by .. or ... or mv file ..../.
alias -g ...='../..'
alias -g ....='../../..'
alias -g .....='../../../..'

# allow + and - for switching between dirs
alias -- +='pushd +0'
alias -- -='pushd -1'
alias -- ++='pushd +1'
alias -- --='pushd -2'
alias -- +++='pushd +2'
alias -- ---='pushd -3'

# set up run-help
#unalias run-help
#autoload run-help


# Shell functions
setenv() { typeset -x "${1}${1:+=}${(@)argv[2,$#]}" }  # csh compatibility
freload() { while (( $# )); do; unfunction $1; autoload -U $1; shift; done }

# Where to look for autoloaded function definitions
fpath=($fpath ~/.zfunc)

# Autoload all shell functions from all directories in $fpath (following
# symlinks) that have the executable bit on (the executable bit is not
# necessary, but gives you an easy way to stop the autoloading of a
# particular shell function). $fpath should not be empty for this to work.
for func in $^fpath/*(N-.x:t); autoload $func

# automatically remove duplicates from these arrays
typeset -U path cdpath fpath manpath

# Hosts to use for completion (see later zstyle)
hosts=(`hostname` ftp.math.gatech.edu prep.ai.mit.edu \
wuarchive.wustl.edu www.bsdforen.de www.google.de)

# Set prompts
autoload colors
colors
# Nice colored prompt, which displays red exid code, if not 0
PROMPT="%{${fg[red]}%}%(?..(%?%))%{${fg[cyan]}%}[%n@%m %~]%# %{${fg[white]}%}" 

# Some environment variables
export MAIL=/var/spool/mail/$USERNAME
#export HELPDIR=/usr/lib/zsh/help  # directory for run-help function to find docs 

MAILCHECK=300
HISTSIZE=1000
DIRSTACKSIZE=35
SAVEHIST=1000
HISTFILE="$HOME/.zhistory"

# Watch for my friends
#watch=( $(<~/.friends) )       # watch for people in .friends file
watch=(notme)                   # watch for everybody but me
LOGCHECK=300                    # check every 5 min for login/logout activity
WATCHFMT='%n %a %l from %m at %t.'


# Set/unset  shell options
setopt   notify correct pushdtohome cdablevars autolist
setopt   correctall autocd recexact longlistjobs histignorespace 
setopt   autoresume histignoredups pushdsilent pushdignoredups noclobber 
setopt   histnostore histnofunctions nohistbeep nobeep autocd multios sharehistory 
setopt   autopushd pushdminus extendedglob rcquotes mailwarning histreduceblanks
#setopt	 globdots noflowcontrol

unsetopt bgnice autoparamslash


# Autoload zsh modules when they are referenced
zmodload -a zsh/stat stat
zmodload -a zsh/zpty zpty
zmodload -a zsh/zprof zprof
zmodload -a -p zsh/mapfile mapfile

# Setup new style completion system. To see examples of the old style
#(compctl based) programmable completion, check Misc/compctl-examples in the zsh
# distribution.
autoload -U compinit
compinit

# Completion Styles

# list of completers to use
zstyle ':completion:*::::' completer _expand _complete _ignored _approximate

# allow one error for every three characters typed in approximate completer
zstyle -e ':completion:*:approximate:*' max-errors \
    'reply=( $(( ($#PREFIX+$#SUFFIX)/3 )) numeric )'
    
# insert all expansions for expand completer
zstyle ':completion:*:expand:*' tag-order all-expansions

# formatting and messages
zstyle ':completion:*' verbose yes
zstyle ':completion:*:descriptions' format '%B%d%b'
zstyle ':completion:*:messages' format '%d'
zstyle ':completion:*:warnings' format 'No matches for: %d'
zstyle ':completion:*:corrections' format '%B%d (errors: %e)%b'
zstyle ':completion:*' group-name ''

# match uppercase from lowercase
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'

# offer indexes before parameters in subscripts
zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters

# command for process lists, the local web server details and host completion
#zstyle ':completion:*:processes' command 'ps -o pid,s,nice,stime,args'
#zstyle ':completion:*:urls' local 'www' '/var/www/htdocs' 'public_html'
zstyle '*' hosts $hosts

# Filename suffixes to ignore during completion (except after rm, see alias also)
zstyle ':completion:*:*:(^rm):*:*files' ignored-patterns '*?.o' '*?.c~' \
'*?.old' '*?.pro'

# ignore completion functions (until the _ignored completer)
zstyle ':completion:*:functions' ignored-patterns '_*'

# Newsserver
export NNTPSERVER=news.t-online.de
#export NNTPSERVER=freenews.netfront.net
#export NNTPSERVER=post.newsfeeds.com


# Keybindings
bindkey -v	# VI 
bindkey '^r' history-incremental-search-backward
bindkey '^x' push-line
bindkey '^p' copy-prev-word
bindkey '^d' describe-key-briefly
bindkey '^j' accept-line-and-down-history

Der Prompt ist sicherlich nicht jedes Puristen Sache, aber ich habe bei nem Farbigen einfach den besseren Überblick, besonders bei 1024x768. Da stört auch der komplette Pfad meist nicht -- ist ja genug Platz (Wenn nicht hilft \n).

EDIT: Da hat ein Stück gefehlt, jetzt ists komplett...
 
Zuletzt bearbeitet:
Die Zsh hat out-of-the-box Completion fuer massenhaft Kram, auch fuer sysctl, BSDs pkg_* usw. usf.
 
Ich hab jetzt mal etwas mit der Zsh rumgespielt und finde sie wirklich gut.
Aber jetzt kommt schon wieder die nächste Frage ;)
Die Funktion "sched" ist ne feine Sache, nur leider ist die Ausgabe gebuffert, d.h. es wird erst nach einer neuen Eingabe ausgegeben. Ich wollte so eigentlich einen Wecker realisieren, nur gebuffert bringt das leider nix. Gibt es eine Möglichkeit "sched" auch ungebuffert auszuführen? Ein man zu "sched" hab ich nicht gefunden und google brachte leider auch nix :/
Oder gibts evtl. eine andere Funktion welche man NICHT als root ausführen muss ("at" hab ich mir auch schon angeschaut)?
Ich weiß, man kann auch einfach nen cronjob machen, aber da sich meine Weckzeiten ständig ändern wäre eine Funktion wie "sched" wirklich die beste Lösung.
 
Zurück
Oben