Author Topic: Comandi utili da terminale  (Read 19312 times)

SuNjACk

  • Guest
Re:Comandi utili da terminale
« Reply #165 on: June 10, 2010, 10:28:02 PM »
quella function ce l'ho anch'io ma il mio può aprire più archivi in una volta sola :asd:

AirPort

  • Guest
Re:Comandi utili da terminale
« Reply #166 on: June 11, 2010, 12:30:59 AM »
Bah, niente in confronto al mio .bash_aliases

Code: [Select]
alias ls='ls --color=auto'
 :lki: :lki:

vaillant86

  • Guest
Re:Comandi utili da terminale
« Reply #167 on: June 11, 2010, 08:08:45 AM »
Per bloccare un pacchetto alla sua versione corrente tramite apt-get
Code: [Select]
echo nomepacchetto hold | sudo dpkg --set-selections
Per sbloccarlo
Code: [Select]
echo nomepacchetto install | sudo dpkg --set-selections
Per vedere lo stato dei pacchetti (bloccati o meno)

Code: [Select]
sudo dpkg --get-selections > lista.txt

domx

  • Guest
Re:Comandi utili da terminale
« Reply #168 on: June 11, 2010, 08:14:07 AM »
Per bloccare un pacchetto alla sua versione corrente tramite apt-get
Code: [Select]
echo nomepacchetto hold | sudo dpkg --set-selections
Per sbloccarlo
Code: [Select]
echo nomepacchetto install | sudo dpkg --set-selections
Per vedere lo stato dei pacchetti (bloccati o meno)

Code: [Select]
sudo dpkg --get-selections > lista.txt
su arch non funge...
eppure mi sembra che installai il pacchetto che conteneva dpkg :thinking: :thinking:

AirPort

  • Guest
Re:Comandi utili da terminale
« Reply #169 on: June 11, 2010, 08:33:22 AM »
Per bloccare un pacchetto alla sua versione corrente tramite apt-get
Code: [Select]
echo nomepacchetto hold | sudo dpkg --set-selections
Per sbloccarlo
Code: [Select]
echo nomepacchetto install | sudo dpkg --set-selections
Per vedere lo stato dei pacchetti (bloccati o meno)

Code: [Select]
sudo dpkg --get-selections > lista.txt
su arch non funge...
eppure mi sembra che installai il pacchetto che conteneva dpkg :thinking: :thinking:

Vorrei anche vedere...

carlotux

  • Guest
Re:Comandi utili da terminale
« Reply #170 on: June 11, 2010, 09:51:40 AM »
Andate su altre distro, e certo che molti comandi e abitudini sono diverse da ubuntu.

SuNjACk

  • Guest
Re:Comandi utili da terminale
« Reply #171 on: June 11, 2010, 11:20:01 AM »
Son riuscito ad ottenere anche l'autocompletamento per i miei alias :asd:

Code: (~/.bash_completion) [Select]
# This function checks whether we have a given program on the system.
# No need for bulky functions in memory if we don't.
#
have()
{
unset -v have
PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin type $1 &>/dev/null &&
have="yes"
}

_comp_dpkg_installed_packages()
{
grep -A 1 "Package: $1" /var/lib/dpkg/status | \
grep -B 1 -E "ok installed|half-installed|unpacked| \
half-configured|config-files" | \
grep "Package: $1" | cut -d\  -f2
}

# Get the word to complete
# This is nicer than ${COMP_WORDS[$COMP_CWORD]}, since it handles cases
# where the user is completing in the middle of a word.
# (For example, if the line is "ls foobar",
# and the cursor is here -------->   ^
# it will complete just "foo", not "foobar", which is what the user wants.)
#
#
# Accepts an optional parameter indicating which characters out of
# $COMP_WORDBREAKS should NOT be considered word breaks. This is useful
# for things like scp where we want to return host:path and not only path.
_get_cword()
{
if [[ "${#COMP_WORDS[COMP_CWORD]}" -eq 0 ]] || [[ "$COMP_POINT" == "${#COMP_LINE}" ]]; then
echo "${COMP_WORDS[COMP_CWORD]}"
else
local i
local cur="$COMP_LINE"
local index="$COMP_POINT"
for (( i = 0; i <= COMP_CWORD; ++i )); do
while [[ "${#cur}" -ge ${#COMP_WORDS[i]} ]] && [[ "${cur:0:${#COMP_WORDS[i]}}" != "${COMP_WORDS[i]}" ]]; do
cur="${cur:1}"
index="$(( index - 1 ))"
done
if [[ "$i" -lt "$COMP_CWORD" ]]; then
local old_size="${#cur}"
cur="${cur#${COMP_WORDS[i]}}"
local new_size="${#cur}"
index="$(( index - old_size + new_size ))"
fi
done

if [[ "${COMP_WORDS[COMP_CWORD]:0:${#cur}}" != "$cur" ]]; then
# We messed up! At least return the whole word so things
# keep working
echo "${COMP_WORDS[COMP_CWORD]}"
else
echo "${cur:0:$index}"
fi
fi
}

# apt-i (alias) completion.
#
have apt-i &&
_apt_i()
{
local cur prev special i

COMPREPLY=()
cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]}

for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
special=${COMP_WORDS[i]}
done

if [ -n "$special" ]; then
COMPREPLY=( $( apt-cache pkgnames $cur 2> /dev/null ) )
return 0
fi

return 0
} &&
complete -F _apt_i -o filenames apt-i

# also use _apt_i() for apt-show (alias)
have apt-show && complete -F _apt_i -o filenames apt-show
# for apt-showpkg (alias)
have apt-showpkg && complete -F _apt_i -o filenames apt-showpkg
# for "deps"
have deps && complete -F _apt_i -o filenames deps

# apt-r (alias) completion
#
have apt-r &&
_apt_r()
{
local cur prev special i

COMPREPLY=()
cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]}

for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
special=${COMP_WORDS[i]}
done

if [ -n "$special" ]; then
COMPREPLY=( $( _comp_dpkg_installed_packages \
$cur ) )
return 0
fi

return 0
} &&
complete -F _apt_r -o filenames apt-r

sgnablo

  • Guest
Re:Comandi utili da terminale
« Reply #172 on: June 11, 2010, 11:36:22 AM »
figo! ma come funziona?

SuNjACk

  • Guest
Re:Comandi utili da terminale
« Reply #173 on: June 11, 2010, 03:56:40 PM »
figo! ma come funziona?

ho aggiunto al mio .bashrc

Code: [Select]
if [ -f $HOME/.bash_completion ]; then
    . $HOME/.bash_completion
fi

sgnablo

  • Guest
Re:Comandi utili da terminale
« Reply #174 on: June 11, 2010, 05:34:39 PM »
l'ho provato, non mi va :( .. dovrebbe completare col tab, giusto?
ps: ho addirittura riavviato X, ma niente...
« Last Edit: June 11, 2010, 05:36:50 PM by sgnablo »

SuNjACk

  • Guest
Re:Comandi utili da terminale
« Reply #175 on: June 11, 2010, 06:37:31 PM »
funziona "solo" con
apt-i, apt-show, apt-showpkg, deps : completa con i nomi di tutti i pacchetti disponibili

apt-r : completa con i nomi dei pacchetti disponibili

Gabo2

  • Guest
Re:Comandi utili da terminale
« Reply #176 on: June 27, 2010, 01:16:38 PM »
Non c'è qualche santo che li raccoglie e ci fa ..chessò...un pdf? :embas:

tonywhite

  • Guest
Re:Comandi utili da terminale
« Reply #177 on: June 27, 2010, 02:23:22 PM »
Non c'è qualche santo che li raccoglie e ci fa ..chessò...un pdf? :embas:

Voto Bucky  :asd:

sgnablo

  • Guest
Re:Comandi utili da terminale
« Reply #178 on: June 27, 2010, 02:23:59 PM »
io voto gabo :asd:

tonywhite

  • Guest
Re:Comandi utili da terminale
« Reply #179 on: June 27, 2010, 02:31:59 PM »
io voto gabo :asd:

Ora cambio il mio voto e scelgo te. Che fai? Uno script che elenca gli scipt elencati in questo thread e ci fai un pdf?  :asd: